Hi there,

I am using PostgreSQL and I noticed that if a column is an array and set to 
be validated for uniqueness it generates an invalid SQL query such as:

SELECT  1 AS one FROM "postgresql_arrays"  WHERE 
"postgresql_arrays"."nicknames" = '["john", "johnny"]' LIMIT 1

This happens because the validator does not encode/typecast the Ruby Array 
to its database counterpart, and instead is just converted to String with 
to_s.

I have a small patch for this and I would like to hear your opinions. This 
patch does not break existing tests for PostgreSQL, SQLite or MySQL:

https://github.com/w3p/rails/commit/26204692476314298cc6a1ad06c2cddf355a5949

(currently the added test is PostgreSQL-specific, but is located in 
uniqueness_validation_test.rb, so I'd be happy if someone could give some 
guidance into proper test organization for this)

Thanks,

Pedro Padron

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/yi9pojmJdIIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to