Skip to content

Commit

Permalink
[Mysql] small updated to quote table names. Mysql 8 has keywords that…
Browse files Browse the repository at this point in the history
… might match table names which cause an exception when selecting with the dleted/deleted at columns. (#512)
  • Loading branch information
Kyle Ferrara committed Mar 23, 2022
1 parent ef1225e commit cc19cef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def only_deleted
# these will not match != sentinel value because "NULL != value" is
# NULL under the sql standard
# Scoping with the table_name is mandatory to avoid ambiguous errors when joining tables.
scoped_quoted_paranoia_column = "#{self.table_name}.#{connection.quote_column_name(paranoia_column)}"
scoped_quoted_paranoia_column = "#{connection.quote_table_name(self.table_name)}.#{connection.quote_column_name(paranoia_column)}"
with_deleted.where("#{scoped_quoted_paranoia_column} IS NULL OR #{scoped_quoted_paranoia_column} != ?", paranoia_sentinel_value)
end
alias_method :deleted, :only_deleted
Expand Down

0 comments on commit cc19cef

Please sign in to comment.