tlconnor/activerecord-postgres-array

Extra single quotes in sql

Paxa opened this issue · 1 comments

Paxa commented

Code:

user.roles = (user.roles || []) + [role_name]
user.save

Get:

PG::Error: ERROR:  array value must start with "{" or dimension information
LINE 1: ..._name" = 'Admin', "last_name" = 'Shop', "roles" = '''{"admin...
                                                             ^
: UPDATE "users" SET "encrypted_password" = '$2a$10$cWhCkffLHVGnv9S47nJZr.ycMe.3Gc./rcEqCq7paG1JZ.fhV3y8y', "first_name" = 'Admin', "middle_name" = 'Admin', "last_name" = 'Shop', "roles" = '''{"admin",customer}''', "confirmed_at" = '2013-02-06 08:07:13.428599', "created_at" = '2013-02-06 08:07:13.461182', "updated_at" = '2013-02-06 08:07:13.461182', "unconfirmed_email" = 'admin@example.com' WHERE "users"."id" = 1

Working variant:

user.roles = [] + (user.roles || []) + [role_name]

Can you please retest against the latest version? I have added a test case for the above and it appears to be working correctly.