Method: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#insert_sql
- Defined in:
- lib/active_record/connection_adapters/postgresql_adapter.rb
#insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) ⇒ Object
Executes an INSERT query and returns the new record’s ID
584 585 586 587 588 589 590 591 592 593 594 595 596 |
# File 'lib/active_record/connection_adapters/postgresql_adapter.rb', line 584 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 |