File tree Expand file tree Collapse file tree 2 files changed +4
-24
lines changed
lib/active_record/connection_adapters/sqlserver Expand file tree Collapse file tree 2 files changed +4
-24
lines changed Original file line number Diff line number Diff line change @@ -401,15 +401,6 @@ def query_requires_identity_insert?(sql)
401
401
id_column = identity_columns ( raw_table_name ) . first
402
402
403
403
id_column && sql =~ /^\s *(INSERT|EXEC sp_executesql N'INSERT)[^(]+\( [^)]*\b (#{ id_column . name } )\b ,?[^)]*\) /i ? SQLServer ::Utils . extract_identifiers ( raw_table_name ) . quoted : false
404
-
405
- rescue StandardError => e
406
-
407
- puts "*" * 100
408
- puts "sql: #{ sql } "
409
- puts "raw_table_name: #{ raw_table_name } "
410
- puts "*" * 100
411
-
412
- raise e
413
404
end
414
405
415
406
def insert_sql? ( sql )
Original file line number Diff line number Diff line change @@ -673,29 +673,18 @@ def get_table_name(sql)
673
673
674
674
# Parses the raw table name that is used in the SQL. Table name could include database/schema/etc.
675
675
def get_raw_table_name ( sql )
676
-
677
676
s = sql . gsub ( /^\s *EXEC sp_executesql N'/i , "" )
678
677
679
- # binding.pry
680
-
681
678
if s . match? ( /^\s *INSERT INTO.*/i )
682
- s = s . split ( /INSERT INTO/i ) [ 1 ] . split ( /OUTPUT INSERTED/i ) [ 0 ] . split ( /(DEFAULT)?\s +VALUES/i ) [ 0 ]
683
-
684
- s . match ( /\s *([^(]*)/i ) [ 0 ]
679
+ s . split ( /INSERT INTO/i ) [ 1 ]
680
+ . split ( /OUTPUT INSERTED/i ) [ 0 ]
681
+ . split ( /(DEFAULT)?\s +VALUES/i ) [ 0 ]
682
+ . match ( /\s *([^(]*)/i ) [ 0 ]
685
683
elsif s . match? ( /^\s *UPDATE\s +.*/i )
686
684
s . match ( /UPDATE\s +([^\( \s ]+)\s */i ) [ 1 ]
687
685
else
688
686
s . match ( /FROM\s +((\[ [^\( \] ]+\] )|[^\( \s ]+)\s */i ) [ 1 ]
689
687
end . strip
690
-
691
- # table_name
692
-
693
- # case sql
694
- # when /^\s*(INSERT|EXEC sp_executesql N'INSERT)(\s+INTO)?\s+(\[[^\(\]]+\])\s*|^\s*update\s+([^\(\s]+)\s*/i
695
- # Regexp.last_match[3] || Regexp.last_match[4]
696
- # when /FROM\s+((\[[^\(\]]+\])|[^\(\s]+)\s*/i
697
- # Regexp.last_match[1]
698
- # end.strip
699
688
end
700
689
701
690
def default_constraint_name ( table_name , column_name )
You can’t perform that action at this time.
0 commit comments