Sha256: 22fb9a79ac5d8c636dfb5fb50ad33586b5833bd80bc9f671294e64643a9c8502

Contents?: true

Size: 768 Bytes

Versions: 14

Compression:

Stored size: 768 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    class SQLServerAdapter
      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.dup.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
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
composite_primary_keys-11.0.3 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.2 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-10.0.5 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.1 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.0 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-10.0.4 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.0.rc2 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-10.0.3 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.0.rc1 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.0.beta4 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.0.beta3 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.0.beta2 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-11.0.0.beta1 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
composite_primary_keys-10.0.2 lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb