Skip to content

Commit 134a922

Browse files
committed
parser: update with proper nodes for special cased functions
previously we weren't exposing special functions like any, some, all, extract, substring, etc. now they're in the ast also improved the structure for a handful of these functions
1 parent dbb9781 commit 134a922

18 files changed

+9830
-6289
lines changed

PLAN.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,23 @@ type checking should allow us to give type errors without the user having to run
206206

207207
support more advanced lint rules
208208

209+
#### type check `create type t as range`
210+
211+
```sql
212+
create type timerange as range (
213+
subtype = time,
214+
subtype_diff = time_subtype_diff
215+
);
216+
```
217+
218+
if set, `subtype_diff` must be of type `function time_subtype_diff(time without time zone, time without time zone)`
219+
220+
```ts
221+
function createRangeType<T>(subtype: T, subtype_diff: (T, T) => float8)
222+
```
223+
224+
https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-DEFINING
225+
209226
### PGO
210227

211228
- https://github.com/rust-lang/rust-analyzer/pull/19582#issue-2992471459
@@ -590,6 +607,26 @@ select '{"foo": 1,}'::json;
590607
-- ^ invalid json, unexpected trailing comma
591608
```
592609

610+
```sql
611+
create type foo as (
612+
a int8,
613+
b int8
614+
);
615+
select foo '(1)';
616+
-- ^ malformed record literal, missing column b
617+
```
618+
619+
```sql
620+
select '[1,,2)'::numrange;
621+
-- ^ malformed range literal, extra comma
622+
623+
create table reservation (room int, during tsrange);
624+
insert into reservation values
625+
(1108, '[2010-01-01 14:30,, 2010-01-01 15:30)');
626+
-- ^ malformed range literal, extra comma
627+
628+
```
629+
593630
### Rule: column label is the same as an existing column
594631

595632
```sql
@@ -772,6 +809,18 @@ select * from json_table(
772809
);
773810
```
774811
812+
#### `nextval`
813+
814+
```sql
815+
-- via https://www.postgresql.org/docs/current/datatype-oid.html
816+
nextval('foo') -- operates on sequence foo
817+
nextval('FOO') -- same as above
818+
nextval('"Foo"') -- operates on sequence Foo
819+
nextval('myschema.foo') -- operates on myschema.foo
820+
nextval('"myschema".foo') -- same as above
821+
nextval('foo') -- searches search path for foo
822+
```
823+
775824
### Autocomplete
776825
777826
- [datagrip postfix completion](https://blog.jetbrains.com/datagrip/2019/03/11/top-9-sql-features-of-datagrip-you-have-to-know/#postfix_completion)

crates/squawk_ide/src/expand_selection.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const DELIMITED_LIST_KINDS: &[SyntaxKind] = &[
5454
SyntaxKind::REVOKE_COMMAND_LIST,
5555
SyntaxKind::ROLE_LIST,
5656
SyntaxKind::ROW_LIST,
57+
SyntaxKind::XML_ATTRIBUTE_LIST,
58+
SyntaxKind::XML_NAMESPACE_LIST,
5759
SyntaxKind::SET_COLUMN_LIST,
5860
SyntaxKind::SET_EXPR_LIST,
5961
SyntaxKind::SET_OPTIONS_LIST,

crates/squawk_parser/src/generated/syntax_kind.rs

Lines changed: 42 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)