Class: ActiveRecord::ConnectionAdapters::SQLServerAdapter
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::SQLServerAdapter
- Defined in:
- lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
Instance Method Summary collapse
Instance Method Details
#sql_for_insert(sql, pk, id_value, sequence_name, binds) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb', line 4 def sql_for_insert(sql, pk, id_value, sequence_name, binds) sql = if pk && self.class.use_output_inserted # CPK # quoted_pk = SQLServer::Utils.extract_identifiers(pk).quoted # sql.insert sql.index(/ (DEFAULT )?VALUES/), " OUTPUT INSERTED.#{quoted_pk}" quoted_pks = [pk].flatten.map {|pk| "INSERTED.#{SQLServer::Utils.extract_identifiers(pk).quoted}"} sql.insert sql.index(/ (DEFAULT )?VALUES/), " OUTPUT #{quoted_pks.join(", ")}" else "#{sql}; SELECT CAST(SCOPE_IDENTITY() AS bigint) AS Ident" end # CPK # super [sql, binds] end |