mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 10:47:22 +00:00
common: Make sure + - * / % binary operators work the same in all dialects (#1025)
This commit is contained in:
parent
7b3cc18229
commit
8164b7c316
3 changed files with 59 additions and 7 deletions
|
@ -7744,3 +7744,61 @@ fn parse_create_type() {
|
|||
fn parse_create_table_collate() {
|
||||
pg_and_generic().verified_stmt("CREATE TABLE tbl (foo INT, bar TEXT COLLATE \"de_DE\")");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_binary_operators_without_whitespace() {
|
||||
// x + y
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT field+1000 FROM tbl1",
|
||||
"SELECT field + 1000 FROM tbl1",
|
||||
);
|
||||
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT tbl1.field+tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
"SELECT tbl1.field + tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
);
|
||||
|
||||
// x - y
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT field-1000 FROM tbl1",
|
||||
"SELECT field - 1000 FROM tbl1",
|
||||
);
|
||||
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT tbl1.field-tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
"SELECT tbl1.field - tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
);
|
||||
|
||||
// x * y
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT field*1000 FROM tbl1",
|
||||
"SELECT field * 1000 FROM tbl1",
|
||||
);
|
||||
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT tbl1.field*tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
"SELECT tbl1.field * tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
);
|
||||
|
||||
// x / y
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT field/1000 FROM tbl1",
|
||||
"SELECT field / 1000 FROM tbl1",
|
||||
);
|
||||
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT tbl1.field/tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
"SELECT tbl1.field / tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
);
|
||||
|
||||
// x % y
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT field%1000 FROM tbl1",
|
||||
"SELECT field % 1000 FROM tbl1",
|
||||
);
|
||||
|
||||
all_dialects().one_statement_parses_to(
|
||||
"SELECT tbl1.field%tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
"SELECT tbl1.field % tbl2.field FROM tbl1 JOIN tbl2 ON tbl1.id = tbl2.entity_id",
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue