-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
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
Virtual blocks fail silently #979
Comments
You don't need a special operator for regexp matching in virtual row blocks, since they can be specified via a hash: It's possible to support what you want fairly easily: class Sequel::SQL::GenericExpression
def =~(regexp)
Sequel.expr(self=>regexp)
end
end I'm not sure what the backwards compatibility effects would be, but I'm guessing they would be minimal, so that's something I would consider. If you think that should be added, please open up a thread on the sequel-talk Google Group and see what the communities' thoughts are. Sequel doesn't raise an error in this case, because the Virtual row blocks don't add any features to Sequel, they are purely a way to make code less verbose. In general, they just offer a way to easily create |
Wow, I did not know that Yeah, I might suggest adding |
…to a hash (Fixes #979) This makes it simpler to use equality/inclusion/pattern match operations in virtual row blocks. On ruby 1.9, it makes it significantly simpler to include inverted conditions inside more complex expressions, which previously required Sequel.~. This does change behavior, since =~ and !~ were already defined, since they are defined in Object. However, it is unlikely that anyone was relying on the previous behavior, since =~ returned nil and !~ returned true.
I wanted to do regex mathching inside a virtual block, and I wrote this:
The query didn't work, and after reading the section about virtual blocks I saw that there is no operator for matching regexes inside of virtual blocks. What surprised me is that Sequel didn't raise any errors. What it did is simply ignore that
WHERE
clause in the final query:Is this an intentional part of the design? Is it possible to make Sequel raise an error for mistakes like these? Because this way writing virtual blocks is very brittle.
The text was updated successfully, but these errors were encountered: