Support DELETE with ORDER BY and LIMIT (MySQL) (#992)

This commit is contained in:
Ulrich Schmidt-Goertz 2023-10-02 14:42:58 +02:00 committed by GitHub
parent ed39329060
commit 6ffc3b3a52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 1 deletions

View file

@ -525,6 +525,7 @@ fn parse_where_delete_statement() {
using,
selection,
returning,
..
} => {
assert_eq!(
TableFactor::Table {
@ -565,6 +566,7 @@ fn parse_where_delete_with_alias_statement() {
using,
selection,
returning,
..
} => {
assert_eq!(
TableFactor::Table {

View file

@ -1315,6 +1315,38 @@ fn parse_update_with_joins() {
}
}
#[test]
fn parse_delete_with_order_by() {
let sql = "DELETE FROM customers ORDER BY id DESC";
match mysql().verified_stmt(sql) {
Statement::Delete { order_by, .. } => {
assert_eq!(
vec![OrderByExpr {
expr: Expr::Identifier(Ident {
value: "id".to_owned(),
quote_style: None
}),
asc: Some(false),
nulls_first: None,
}],
order_by
);
}
_ => unreachable!(),
}
}
#[test]
fn parse_delete_with_limit() {
let sql = "DELETE FROM customers LIMIT 100";
match mysql().verified_stmt(sql) {
Statement::Delete { limit, .. } => {
assert_eq!(Some(Expr::Value(number("100"))), limit);
}
_ => unreachable!(),
}
}
#[test]
fn parse_alter_table_drop_primary_key() {
assert_matches!(