rails/rails — pull request #8075 by ppadron (2012-10-30 18:02:02+00:00)
Title: ActiveRecord: support for validate_uniqueness_of in PostgreSQL array columns

When setting an array column (or other PostgreSQL-specific data type) to be validated for uniqueness, the resulting SQL query is generated with syntax errors, like this:

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

This happens because Ruby Arrays must be type-casted to their PostgreSQL equivalent. This small patch fixes this issue, calling the adapter's type_cast method.

I have added a test case for this, but since it's PostgreSQL-specific (it skips for other adapters), I'm not sure if it belongs in the validate_uniqueness_test.rb or if I should put it with other PostgreSQL tests.

Thanks,