Skip to content

Commit d183dd0

Browse files
authored
Merge pull request #688 from X1ting/fix/fix-tablename-in-insert
#sql_for_insert set table name in case when pk is not nil
2 parents ed8b170 + e55be77 commit d183dd0

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ before_install:
2121
- tsql -C
2222
install:
2323
- export PATH=/opt/local/bin:$PATH
24-
- gem install bundler
24+
- gem install bundler -v 1.17.3
2525
- bundle --version
2626
- bundle install
2727
script:

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def sql_for_insert(sql, pk, id_value, sequence_name, binds)
194194
end
195195
sql = if pk && use_output_inserted? && !database_prefix_remote_server?
196196
quoted_pk = SQLServer::Utils.extract_identifiers(pk).quoted
197+
table_name ||= get_table_name(sql)
197198
exclude_output_inserted = exclude_output_inserted_table_name?(table_name, sql)
198199
if exclude_output_inserted
199200
id_sql_type = exclude_output_inserted.is_a?(TrueClass) ? 'bigint' : exclude_output_inserted

0 commit comments

Comments
 (0)