diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-25 09:18:39 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-25 09:18:39 -0700 |
commit | 2fc8d7ea90c901600319d2ad4d3dbfece3ced410 (patch) | |
tree | bf7a86fe96311c564843eb3662cd3af5222e1042 | |
parent | f545a5081ec7052dd9319cab84ab52d41ee267bd (diff) | |
parent | 35d0b6029fe499254d74a3cd5dc4c0397d3a50ee (diff) | |
download | rails-2fc8d7ea90c901600319d2ad4d3dbfece3ced410.tar.gz rails-2fc8d7ea90c901600319d2ad4d3dbfece3ced410.tar.bz2 rails-2fc8d7ea90c901600319d2ad4d3dbfece3ced410.zip |
Merged pull request #302 from metaskills/empty_inserts.
Use existing #empty_insert_statement_value for an insert with no columns.
3 files changed, 1 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 5ff81aa023..70da9d5f1e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -287,10 +287,6 @@ module ActiveRecord execute "INSERT INTO #{quote_table_name(table_name)} (#{key_list.join(', ')}) VALUES (#{value_list.join(', ')})", 'Fixture Insert' end - def null_insert_value - Arel.sql 'DEFAULT' - end - def empty_insert_statement_value "VALUES(DEFAULT)" end diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index e1518f9a0f..ed5006dcec 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -346,10 +346,6 @@ module ActiveRecord alter_table(table_name, :rename => {column_name.to_s => new_column_name.to_s}) end - def null_insert_value - Arel.sql 'NULL' - end - def empty_insert_statement_value "VALUES(NULL)" end diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 45a7000cce..8e5f66ec1d 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -60,7 +60,7 @@ module ActiveRecord end if values.empty? # empty insert - im.values = im.create_values [connection.null_insert_value], [] + im.values = Arel.sql(connection.empty_insert_statement_value) else im.insert substitutes end |