We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is a bug with find when specifying a condition when I put the quotes around the ?.
model = Model.find(:first, :conditions => ["slug = '?'", slug])
returns nil even though the record exists, because if I then try to create it fails with a uniqueness constraint.
Model.create({:slug => slug})
I notice the following in the log output when doing the find (notice the extra space in the condition)
I/APP ( 281): I 05/19/2011 20:02:26:219 0020af00 APP| condition_str : slug = 'arts ' I/APP ( 281): I 05/19/2011 20:02:26:305 0020af00 APP| exception when running query: could not execute statement: 19; Message: column slug is not unique I/APP ( 281): I 05/19/2011 20:02:26:316 0020af00 APP| create Exception: #<ArgumentError: could not execute statement: 19; Message: column slug is not unique> I/APP ( 281): I 05/19/2011 20:02:26:319 0020af00 APP| App error: could not execute statement: 19; Message: column slug is not unique I/APP ( 281): lib/rhom/rhom_db_adapter.rb:109:in `execute' I/APP ( 281): lib/rhom/rhom_db_adapter.rb:109:in `_execute_sql' I/APP ( 281): lib/rhom/rhom_db_adapter.rb:98:in `execute_sql' I/APP ( 281): lib/rhom/rhom_db_adapter.rb:246:in `insert_into_table' I/APP ( 281): lib/rhom/rhom_object_factory.rb:1458:in `create' I/APP ( 281): lib/rhom/rhom_object_factory.rb:1345:in `create'
However, if I move the qoutes around like such:
model = Model.find(:first, :conditions => ["slug = ?", "'#{slug}'"])
And the condition string log output (notice NO extra space in the condition):
I/APP ( 279): I 05/20/2011 11:21:36:325 002d12e0 APP| condition_str : slug = 'arts'
The record is found and therefore I can do an update instead of a create.
The text was updated successfully, but these errors were encountered:
Use this syntax: :conditions => {'slug'=>slug}
Sorry, something went wrong.
No branches or pull requests
There is a bug with find when specifying a condition when I put the quotes around the ?.
returns nil even though the record exists, because if I then try to create it fails with a uniqueness constraint.
I notice the following in the log output when doing the find (notice the extra space in the condition)
However, if I move the qoutes around like such:
And the condition string log output (notice NO extra space in the condition):
The record is found and therefore I can do an update instead of a create.
The text was updated successfully, but these errors were encountered: