You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue occurs when using #update_column, #update_columns and #update_all on a column of native postgres array type.
SomeTable.first.update_column(:array_column, ['value_1', 'value_2'])
>> UPDATE "some_tables" SET "array_column" = 'value_1','value_2'...
I think the issue is here where the value is passed in to the method with no information about the column type and therefore postgres specific quoting can not be invoked.
If my thinking is correct I can try to fix this
The text was updated successfully, but these errors were encountered:
This is a combination of 3 commits:
--- 5651009
Do not consider PG array columns as number or text columns
The code uses these checks in several places to know what to do with a
particular column, for instance AR attribute query methods has a branch
like this:
if column.number?
!value.zero?
end
This should never be true for array columns, since it would be the same
as running [].zero?, which results in a NoMethodError exception.
Fixing this by ensuring that array columns in PostgreSQL never return
true for number?/text? checks.
Since most of the array support was based on the postgres_ext lib, it's
worth noting it does the same thing for numeric array columns too:
https://github.com/dockyard/postgres_ext/blob/v1.0.0/lib/postgres_ext/active_record/connection_adapters/postgres_adapter.rb#L72
This extended the same logic for text columns to ensure consistency.
--- 73bba4c
Serialize postgres' hstore, json and array types correctly in AR update methods.
Fixes#12261. Closes#12395.
--- 9e1740a
Tidy up fix for PG extensions quoting
Always pass in the column for quote_bound_value and quote using it in
case it exists there.
The issue occurs when using #update_column, #update_columns and #update_all on a column of native postgres array type.
I think the issue is here where the value is passed in to the method with no information about the column type and therefore postgres specific quoting can not be invoked.
If my thinking is correct I can try to fix this
The text was updated successfully, but these errors were encountered: