Skip to content

Commit

Permalink
Add Optional NOT (#639)
Browse files Browse the repository at this point in the history
This allows boolean functions to be negated
More useful for ANSI SQL  aggregate  function `every`

SELECT
  column1,
  column2,
  COUNT(*) AS count
FROM
  table_name
GROUP BY
  column1,
  column2
HAVING
  NOT every(column1 IS NOT NULL);
  • Loading branch information
griffio authored Aug 6, 2024
1 parent be6f5d4 commit 2e91f45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/kotlin/com/alecstrong/sql/psi/core/sql.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ binary_and_expr ::= expr AND expr {
binary_or_expr ::= expr OR expr {
implements = "com.alecstrong.sql.psi.core.psi.SqlBinaryExpr"
}
function_expr ::= function_name LP [ [ DISTINCT ] expr ( ( COMMA | FROM | FOR | SEPARATOR ) expr ) * | MULTIPLY ] RP
function_expr ::= [ NOT ] function_name LP [ [ DISTINCT ] expr ( ( COMMA | FROM | FOR | SEPARATOR ) expr ) * | MULTIPLY ] RP
paren_expr ::= LP expr RP {
pin = 1
}
Expand Down
15 changes: 15 additions & 0 deletions core/src/testFixtures/resources/fixtures/not-function-expr/Test.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE test (
test_id INTEGER
);

SELECT
test_id
FROM
test
GROUP BY
test_id
HAVING
NOT COALESCE(TRUE, FALSE);

SELECT NOT COALESCE(TRUE, FALSE) FROM test;

0 comments on commit 2e91f45

Please sign in to comment.