diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-15 16:15:58 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-26 13:44:09 -0700 |
commit | e2813479f96e6dbfcfcde667797298611a9c9311 (patch) | |
tree | 8814a7b6eb7eb0e32efab5aca71fed871d748e5e /activerecord | |
parent | ffb999125a60cbdcee2e6709df019d55f21b22a6 (diff) | |
download | rails-e2813479f96e6dbfcfcde667797298611a9c9311.tar.gz rails-e2813479f96e6dbfcfcde667797298611a9c9311.tar.bz2 rails-e2813479f96e6dbfcfcde667797298611a9c9311.zip |
basic bind parameters are working
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 75b4c1e653..80b987fb89 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -532,7 +532,7 @@ module ActiveRecord # Clear the queue @connection.get_last_result - @connection.send_query_prepared(key, []) + @connection.send_query_prepared(key, binds.map { |col, val| val }) @connection.block result = @connection.get_last_result ActiveRecord::Result.new(result.fields, result_as_array(result)) diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index a61482256a..0b295c9613 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -29,6 +29,18 @@ module ActiveRecord assert_equal [['1', 'foo']], result.rows end + + def test_exec_with_binds + string = @connection.quote('foo') + @connection.exec("INSERT INTO ex (id, data) VALUES (1, #{string})") + result = @connection.exec( + 'SELECT id, data FROM ex WHERE id = $1', nil, [[nil, 1]]) + + assert_equal 1, result.rows.length + assert_equal 2, result.columns.length + + assert_equal [['1', 'foo']], result.rows + end end end end |