-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow queries which mix aggregate and non-aggregate expressions
This query would result in an error on PG (I believe MySQL allows it, but it's a nonsense query). This should only be allowed if the column appears in the group by statement, and I believe I'll be able to reflect that in the type system once I get to that point.
- Loading branch information
Showing
4 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
20 changes: 20 additions & 0 deletions
20
tests/compile-fail/cannot_mix_aggregate_and_non_aggregate_selects.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#[macro_use] | ||
extern crate yaqb; | ||
|
||
use yaqb::*; | ||
use yaqb::expression::count; | ||
|
||
table! { | ||
users { | ||
id -> Serial, | ||
} | ||
} | ||
|
||
fn main() { | ||
use self::users::columns::*; | ||
use self::users::table as users; | ||
|
||
let connection = Connection::establish("").unwrap(); | ||
let source = users.select((id, count(star))); | ||
//~^ ERROR E0277 | ||
} |