Skip to content

Commit

Permalink
Add 5199 support postgresql order by nulls (sqldelight#5229)
Browse files Browse the repository at this point in the history
* Add PostgreSql Order By Nulls

Add grammar

* Add fixture tests
  • Loading branch information
griffio authored May 10, 2024
1 parent 3d30972 commit 2e033dc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ overrides ::= type_name
| extension_stmt
| create_index_stmt
| select_stmt
| ordering_term

column_constraint ::= [ CONSTRAINT {identifier} ] (
PRIMARY KEY [ ASC | DESC ] {conflict_clause} |
Expand Down Expand Up @@ -532,3 +533,9 @@ set_timezone ::= 'TIME' 'ZONE'
| 'LOCAL'
| set_value
)

ordering_term ::= <<expr '-1'>> [ ASC | DESC ] [ 'NULLS' ( 'FIRST' | 'LAST' ) ] {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlOrderingTermImpl"
implements = "com.alecstrong.sql.psi.core.psi.SqlOrderingTerm"
override = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATE TABLE table_name(
column1 TEXT,
column2 DATE,
column3 INTEGER
);

SELECT column1, column2
FROM table_name
ORDER BY column1 NULLS FIRST, column2 DESC;

SELECT column1, column2
FROM table_name
ORDER BY column1 DESC NULLS LAST, column2;

SELECT column1, column2, column3
FROM table_name
ORDER BY column1 NULLS FIRST, column2 NULLS LAST, column3;

SELECT
column1,
column2,
column3
FROM
table_name
ORDER BY
column1 ASC,
column2 DESC,
column3;

0 comments on commit 2e033dc

Please sign in to comment.