Sha256: 679d1f6228254db53ad653e51f6a524d2e76f48f2b813afd30bfb460493771e1

Contents?: true

Size: 1.34 KB

Versions: 36

Compression:

Stored size: 1.34 KB

Contents

# encoding: utf-8

require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
require 'data_objects/spec/shared/command_spec'

describe DataObjects::Postgres::Command do
  it_should_behave_like 'a Command'
  it_should_behave_like 'a Command with async'

  describe 'query with RETURNING while not returning result' do
    before do
      @connection = DataObjects::Connection.new(CONFIG.uri)
      @select_command = @connection.create_command("SELECT name FROM users WHERE id = 900")
      @upsert_command = @connection.create_command("
          WITH upsert AS
            (UPDATE users SET name = ? WHERE id = 900 RETURNING id)
          INSERT INTO users (id, name)
          SELECT 900, 'dbussink' WHERE NOT EXISTS (SELECT 1 FROM upsert)")
    end

    after do
      @connection.close
    end

    it "should work with a writable CTE acting as an Upsert" do
      reader = @select_command.execute_reader
      reader.to_a.size.should == 0
      reader.close

      @upsert_command.execute_non_query('jwkoelewijn')

      reader = @select_command.execute_reader
      reader.next!
      reader.values[0].should == 'dbussink'
      reader.close

      @upsert_command.execute_non_query('jwkoelewijn')

      reader = @select_command.execute_reader
      reader.next!
      reader.values[0].should == 'jwkoelewijn'
      reader.close
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
do_postgres-0.10.12 spec/command_spec.rb
do_postgres-0.10.12-x86-mswin32-60 spec/command_spec.rb
do_postgres-0.10.12-x86-mingw32 spec/command_spec.rb
do_postgres-0.10.12-java spec/command_spec.rb
do_postgres-0.10.11 spec/command_spec.rb
do_postgres-0.10.11-x86-mswin32-60 spec/command_spec.rb
do_postgres-0.10.11-x86-mingw32 spec/command_spec.rb
do_postgres-0.10.11-java spec/command_spec.rb
do_postgres-0.10.10 spec/command_spec.rb
do_postgres-0.10.10-x86-mswin32-60 spec/command_spec.rb
do_postgres-0.10.10-x86-mingw32 spec/command_spec.rb
do_postgres-0.10.10-java spec/command_spec.rb
do_postgres-0.10.9 spec/command_spec.rb
do_postgres-0.10.9-x86-mswin32-60 spec/command_spec.rb
do_postgres-0.10.9-x86-mingw32 spec/command_spec.rb
do_postgres-0.10.9-java spec/command_spec.rb