Last active
August 29, 2015 14:13
-
-
Save apneadiving/15a3de9fa6d9031bedfd to your computer and use it in GitHub Desktop.
where_values binding issue?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Author::Work < AR::Base | |
scope :with_text, -> { where.not(text: nil) } | |
scope :started, -> { where(status: 0) } | |
scope :in_progress, -> { started.with_text } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> Author::Work.in_progress.to_sql | |
=> "SELECT \"author_works\".* FROM \"author_works\" WHERE \"author_works\".\"status\" = 0 AND (\"author_works\".\"text\" IS NOT NULL)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> Author::Work.in_progress.where_values.map &:to_sql | |
=> ["\"author_works\".\"status\" = $1", "\"author_works\".\"text\" IS NOT NULL"] | |
# see the $1 ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment