From b082bece5ed99a1bb1ff9d4af5f9d97a3dcaf6c1 Mon Sep 17 00:00:00 2001 From: Kuldeep Aggarwal Date: Thu, 19 Dec 2013 18:46:17 +0530 Subject: Fix PostgreSQL insert to properly extract table name from multiline string SQL. Previously, executing an insert SQL in PostgreSQL with a command like this: insert into articles( number) values( 5152 ) would not work because the adapter was unable to extract the correct articles table name. --- .../cases/adapters/postgresql/postgresql_adapter_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index 8b017760b1..5372f8821f 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -62,6 +62,18 @@ module ActiveRecord assert_equal expect, id end + def test_multiline_insert_sql + id = @connection.insert_sql(<<-SQL) + insert into ex( + number) + values( + 5152 + ) + SQL + expect = @connection.query('select max(id) from ex').first.first + assert_equal expect, id + end + def test_insert_sql_with_returning_disabled connection = connection_without_insert_returning id = connection.insert_sql("insert into postgresql_partitioned_table_parent (number) VALUES (1)") -- cgit v1.2.3