activerecord-postgres-array icon indicating copy to clipboard operation
activerecord-postgres-array copied to clipboard

Extra single quotes in sql

Open Paxa opened this issue 12 years ago • 1 comments

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" = '[email protected]' WHERE "users"."id" = 1

Working variant:

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

Paxa avatar Feb 06 '13 13:02 Paxa

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

tlconnor avatar Feb 21 '13 07:02 tlconnor