instance method
insert_sql
Ruby on Rails 3.2.22.5
Since v3.1.12 Last seen in v3.2.22.5Available in: v3.1.12 v3.2.22.5
Signature
insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
Executes an INSERT query and returns the new record’s ID
Parameters
-
sqlreq -
nameopt = nil -
pkopt = nil -
id_valueopt = nil -
sequence_nameopt = nil
Source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 581
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
unless pk
# Extract the table from the insert sql. Yuck.
table_ref = extract_table_ref_from_insert_sql(sql)
pk = primary_key(table_ref) if table_ref
end
if pk
select_value("#{sql} RETURNING #{quote_column_name(pk)}")
else
super
end
end
Defined in activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb line 581
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter