Skip to content

Commit

Permalink
In SQL Server only the first column added should have the ADD keywo…
Browse files Browse the repository at this point in the history
…rd (#1086)
  • Loading branch information
aidanharan authored Sep 14, 2023
1 parent 1ece12b commit a49ffff
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
end
end

# In SQL Server only the first column added should have the `ADD` keyword.
def add_timestamps(table_name, **options)
fragments = add_timestamps_for_alter(table_name, **options)
fragments[1..].each { |fragment| fragment.sub!('ADD ', '') }
execute "ALTER TABLE #{quote_table_name(table_name)} #{fragments.join(', ')}"
end

def columns_for_distinct(columns, orders)
order_columns = orders.reject(&:blank?).map { |s|
s = s.to_sql unless s.is_a?(String)
Expand Down

0 comments on commit a49ffff

Please sign in to comment.