Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Nil values uniquines validation #2325

Merged
merged 1 commit into from Jan 6, 2012

Conversation

Projects
None yet
3 participants
Contributor

pyromaniac commented Jul 28, 2011

It casts all nil values to blank string. I think, it is a bug, because rails < 3.1 didn't do it. Here is solution. Thanks.

Contributor

josevalim commented Jan 5, 2012

Please rebase and then ping me once you do?

Contributor

pyromaniac commented Jan 6, 2012

Done. Ping.

@josevalim josevalim added a commit that referenced this pull request Jan 6, 2012

@josevalim josevalim Merge pull request #2325 from pyromaniac/master
Nil values uniquines validation
958d25d

@josevalim josevalim merged commit 958d25d into rails:master Jan 6, 2012

Contributor

josevalim commented Jan 6, 2012

Reverted as it broke the build for mysql isolated tests:

http://travis-ci.org/#!/rails/rails/jobs/484547

Contributor

pyromaniac commented Jan 6, 2012

Ups, i'll try to fix this issue.

Contributor

josevalim commented Jan 6, 2012

Ok. Please send a new pull request and ping me when you do!

@josevalim josevalim added a commit that referenced this pull request Jan 6, 2012

@josevalim josevalim Revert "Merge pull request #2325 from pyromaniac/master"
It breaks the build for mysql.

This reverts commit 958d25d, reversing
changes made to 8f309e3.
705b29b
Contributor

pyromaniac commented Jan 6, 2012

I'm confused. My solution works, but arel generates for all dbs something like this for existance checking:

SELECT 1 FROM "topics" WHERE "topics"."title" IS NULL LIMIT 1

And for mysql it uses:

SELECT 1 FROM "topics" WHERE "topics"."title" = BINARY NULL LIMIT 1

Is it a feature? I think, the first is more proper, no?

Contributor

pyromaniac commented Jan 6, 2012

Done. Works now. Ping.

#4346

Also, i think adapter shoul be fixed here https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L523 like this:

Arel::Nodes::Bin.new(node) unless node.nil?

Contributor

josevalim commented Jan 6, 2012

/cc @jonleighton @tenderlove bros, please check the adapter comment above ^^

Owner

tenderlove commented Jan 6, 2012

I'm not sure what we should do about this. The case_sensitive_modifier does exactly what it says: wraps the node for doing case sensitive searches. How can you do a case sensitive search against NULL? I guess we either need to avoid calling this method when the value is nil, or have the method return the original node in the nil case.

Contributor

josevalim commented Jan 6, 2012

Makes sense, tks bro!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment