`add_not_null_constraint` does not quote column name in check constraint expression
gstokkink opened this issue · 1 comments
gstokkink commented
Hi :)
Found a small issue when using the add_not_null_constraint
helper: it does not quote the column name in the check constraint expression. So, if your column is also a reserved keyword, adding the check constraint will fail.
For example, the following would not work:
add_not_null_constraint 'foos', 'group'
Here, group
is also a reserved keyword. The generated check constraint expression should be 'group' IS NOT NULL
rather than group IS NOT NULL
.
I believe the fix is simple, all you have to change is this line: https://github.com/fatkodima/online_migrations/blob/master/lib/online_migrations/schema_statements.rb#L510:
expression = "'#{column_name}' IS NOT NULL"
I tried creating a PR myself, but could not get the test suite working locally.
Thanks in advance!