-
-
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
Add a function for SQL EXISTS
expressions.
#534
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with doc nits fixed
use result::QueryResult; | ||
use types::Bool; | ||
|
||
/// Creates a SQL `EXISTS` expression. The argument must be a complete SQL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start new paragraph after first sentence for nice looking docs :)
/// usefulness. | ||
/// | ||
/// # Example | ||
/// ```rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add newline after headline
|
||
fn collect_binds(&self, out: &mut DB::BindCollector) -> QueryResult<()> { | ||
try!(self.0.collect_binds(out)); | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the inner self.0.collect_binds(out)
suffice here without the try and Ok unit stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I quite frequently end up adding fields to these things, so I've been consistently writing it like this (and never relying on the return value of the last delegating line) to make it easier to add more fields in the future with less diff noise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I appreciate les diff noise :)
While this is useful for some cases where you don't want to load the rows, this won't fill every use case for the expression, as right now you wouldn't be able to build a query that references the outer table. For us to do that and have it be type safe we'd need overlapping impls for `SelectableExpression` (story of my life), which requires rust-lang/rust#29864 being implemented. Fixes #414.
While this is useful for some cases where you don't want to load the
rows, this won't fill every use case for the expression, as right now
you wouldn't be able to build a query that references the outer table.
For us to do that and have it be type safe we'd need overlapping impls
for
SelectableExpression
(story of my life), which requiresrust-lang/rust#29864 being implemented.
Fixes #414.