Skip to content

Commit 303ff80

Browse files
committed
Build release
1 parent b8cdae1 commit 303ff80

File tree

8 files changed

+123
-60
lines changed

8 files changed

+123
-60
lines changed

.deno/ast-mapper.ts

+40-37
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface IAstPartialMapper {
2929
transaction?: (val: a.CommitStatement | a.RollbackStatement | a.StartTransactionStatement) => a.Statement | nil
3030
createIndex?: (val: a.CreateIndexStatement) => a.Statement | nil
3131
alterTable?: (st: a.AlterTableStatement) => a.Statement | nil
32+
tableAlteration?: (change: a.TableAlteration, table: a.QNameAliased) => a.TableAlteration | nil
3233
dropColumn?: (change: a.TableAlterationDropColumn, table: a.QNameAliased) => a.TableAlteration | nil
3334
renameConstraint?: (change: a.TableAlterationRenameConstraint, table: a.QNameAliased) => a.TableAlteration | nil
3435
setTableOwner?: (change: a.TableAlterationOwner, table: a.QNameAliased) => a.TableAlteration | nil
@@ -642,55 +643,57 @@ export class AstDefaultMapper implements IAstMapper {
642643
if (!table) {
643644
return null; // no table
644645
}
645-
let change: a.TableAlteration | nil;
646-
switch (st.change.type) {
647-
case 'add column': {
648-
change = this.addColumn(st.change, st.table);
649-
break;
650-
}
651-
case 'add constraint': {
652-
change = this.addConstraint(st.change, st.table);
653-
break;
654-
}
655-
case 'alter column': {
656-
change = this.alterColumn(st.change, st.table);
657-
break;
658-
}
659-
case 'rename': {
660-
change = this.renameTable(st.change, st.table);
661-
break;
662-
}
663-
case 'rename column': {
664-
change = this.renameColumn(st.change, st.table);
665-
break;
666-
}
667-
case 'rename constraint': {
668-
change = this.renameConstraint(st.change, st.table);
669-
break;
670-
}
671-
case 'drop column': {
672-
change = this.dropColumn(st.change, st.table);
673-
break;
674-
}
675-
case 'owner': {
676-
change = this.setTableOwner(st.change, st.table);
677-
break;
646+
let changes: a.TableAlteration[] = [];
647+
let hasChanged: boolean = false;
648+
for (let i = 0; i < (st.changes?.length || 0); i++) {
649+
const currentChange: a.TableAlteration = st.changes[i];
650+
const change: a.TableAlteration | nil = this.tableAlteration(currentChange, st.table);
651+
652+
hasChanged = hasChanged || (change != currentChange);
653+
654+
if (!!change) {
655+
changes.push(change);
678656
}
679-
default:
680-
throw NotSupported.never(st.change);
681657
}
682658

683-
if (!change) {
659+
if (!changes.length) {
684660
return null; // no change left
685661
}
686662

663+
if (!hasChanged) {
664+
return st;
665+
}
666+
687667
return assignChanged(st, {
688668
table,
689-
change,
669+
changes,
690670
});
691671

692672
}
693673

674+
tableAlteration(change: a.TableAlteration, table: a.QNameAliased): a.TableAlteration | nil {
675+
switch (change.type) {
676+
case 'add column':
677+
return this.addColumn(change, table);
678+
case 'add constraint':
679+
return this.addConstraint(change, table);
680+
case 'alter column':
681+
return this.alterColumn(change, table);
682+
case 'rename':
683+
return this.renameTable(change, table);
684+
case 'rename column':
685+
return this.renameColumn(change, table);
686+
case 'rename constraint':
687+
return this.renameConstraint(change, table);
688+
case 'drop column':
689+
return this.dropColumn(change, table);
690+
case 'owner':
691+
return this.setTableOwner(change, table);
692+
default:
693+
throw NotSupported.never(change);
694+
}
695+
}
696+
694697
dropColumn(change: a.TableAlterationDropColumn, table: a.QNameAliased): a.TableAlteration | nil {
695698
return change;
696699
}

.deno/literal-syntaxes/array.ne.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated automatically by nearley, version 2.19.7
1+
// Generated automatically by nearley, version 2.20.1
22
// https://github.com/Hardmath123/nearley
33
// Bypasses TS6133. Allow declared but unused functions.
44
// @ts-ignore
@@ -13,15 +13,16 @@ import {lexerAny} from './array-lexer.ts';
1313
const get = (i: number) => (x: any[]) => x[i];
1414
const last = (x: any[]) => x && x[x.length - 1];
1515

16-
interface NearleyToken { value: any;
16+
interface NearleyToken {
17+
value: any;
1718
[key: string]: any;
1819
};
1920

2021
interface NearleyLexer {
2122
reset: (chunk: string, info: any) => void;
2223
next: () => NearleyToken | undefined;
2324
save: () => any;
24-
formatError: (token: NearleyToken) => string;
25+
formatError: (token: never) => string;
2526
has: (tokenType: string) => boolean;
2627
};
2728

.deno/literal-syntaxes/geometric.ne.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated automatically by nearley, version 2.19.7
1+
// Generated automatically by nearley, version 2.20.1
22
// https://github.com/Hardmath123/nearley
33
// Bypasses TS6133. Allow declared but unused functions.
44
// @ts-ignore
@@ -28,15 +28,16 @@ import {lexerAny} from './geometric-lexer.ts';
2828
return e;
2929
}
3030

31-
interface NearleyToken { value: any;
31+
interface NearleyToken {
32+
value: any;
3233
[key: string]: any;
3334
};
3435

3536
interface NearleyLexer {
3637
reset: (chunk: string, info: any) => void;
3738
next: () => NearleyToken | undefined;
3839
save: () => any;
39-
formatError: (token: NearleyToken) => string;
40+
formatError: (token: never) => string;
4041
has: (tokenType: string) => boolean;
4142
};
4243

.deno/literal-syntaxes/interval-iso.ne.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated automatically by nearley, version 2.19.7
1+
// Generated automatically by nearley, version 2.20.1
22
// https://github.com/Hardmath123/nearley
33
// Bypasses TS6133. Allow declared but unused functions.
44
// @ts-ignore
@@ -15,15 +15,16 @@ declare var H: any;
1515
declare var S: any;
1616
import {lexerAny} from './interval-iso-lexer.ts';
1717

18-
interface NearleyToken { value: any;
18+
interface NearleyToken {
19+
value: any;
1920
[key: string]: any;
2021
};
2122

2223
interface NearleyLexer {
2324
reset: (chunk: string, info: any) => void;
2425
next: () => NearleyToken | undefined;
2526
save: () => any;
26-
formatError: (token: NearleyToken) => string;
27+
formatError: (token: never) => string;
2728
has: (tokenType: string) => boolean;
2829
};
2930

.deno/literal-syntaxes/interval.ne.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated automatically by nearley, version 2.19.7
1+
// Generated automatically by nearley, version 2.20.1
22
// https://github.com/Hardmath123/nearley
33
// Bypasses TS6133. Allow declared but unused functions.
44
// @ts-ignore
@@ -16,15 +16,16 @@ declare var dot: any;
1616
declare var colon: any;
1717
import {lexerAny} from './interval-lexer.ts';
1818

19-
interface NearleyToken { value: any;
19+
interface NearleyToken {
20+
value: any;
2021
[key: string]: any;
2122
};
2223

2324
interface NearleyLexer {
2425
reset: (chunk: string, info: any) => void;
2526
next: () => NearleyToken | undefined;
2627
save: () => any;
27-
formatError: (token: NearleyToken) => string;
28+
formatError: (token: never) => string;
2829
has: (tokenType: string) => boolean;
2930
};
3031

.deno/syntax/ast.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export interface AlterTableStatement extends PGNode {
231231
table: QNameAliased;
232232
only?: boolean;
233233
ifExists?: boolean;
234-
change: TableAlteration;
234+
changes: TableAlteration[];
235235
}
236236

237237
export interface TableAlterationRename extends PGNode {
@@ -542,6 +542,7 @@ export interface SelectFromStatement extends PGNode {
542542
limit?: LimitStatement | nil;
543543
orderBy?: OrderByStatement[] | nil;
544544
distinct?: 'all' | 'distinct' | Expr[] | nil;
545+
for?: ForStatement;
545546
}
546547

547548
export interface SelectFromUnion extends PGNode {
@@ -555,6 +556,10 @@ export interface OrderByStatement extends PGNode {
555556
order?: 'ASC' | 'DESC' | nil;
556557
}
557558

559+
export interface ForStatement extends PGNode {
560+
type: 'update' | 'no key update' | 'share' | 'key share';
561+
}
562+
558563
export interface LimitStatement extends PGNode {
559564
limit?: Expr | nil;
560565
offset?: Expr | nil;

.deno/syntax/main.ne.ts

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated automatically by nearley, version 2.19.7
1+
// Generated automatically by nearley, version 2.20.1
22
// https://github.com/Hardmath123/nearley
33
// Bypasses TS6133. Allow declared but unused functions.
44
// @ts-ignore
@@ -43,6 +43,7 @@ declare var kw_group: any;
4343
declare var kw_limit: any;
4444
declare var kw_offset: any;
4545
declare var kw_fetch: any;
46+
declare var kw_for: any;
4647
declare var kw_order: any;
4748
declare var kw_asc: any;
4849
declare var kw_desc: any;
@@ -102,7 +103,6 @@ declare var kw_user: any;
102103
declare var kw_current_user: any;
103104
declare var lparen: any;
104105
declare var kw_placing: any;
105-
declare var kw_for: any;
106106
declare var rparen: any;
107107
declare var kw_create: any;
108108
declare var kw_table: any;
@@ -304,15 +304,16 @@ function setSeqOpts(ret: any, opts: any) {
304304
}
305305
}
306306

307-
interface NearleyToken { value: any;
307+
interface NearleyToken {
308+
value: any;
308309
[key: string]: any;
309310
};
310311

311312
interface NearleyLexer {
312313
reset: (chunk: string, info: any) => void;
313314
next: () => NearleyToken | undefined;
314315
save: () => any;
315-
formatError: (token: NearleyToken) => string;
316+
formatError: (token: never) => string;
316317
has: (tokenType: string) => boolean;
317318
};
318319

@@ -460,6 +461,7 @@ const grammar: Grammar = {
460461
{"name": "kw_prepare", "symbols": [(lexerAny.has("word") ? {type: "word"} : word)], "postprocess": notReservedKw('prepare')},
461462
{"name": "kw_raise", "symbols": [(lexerAny.has("word") ? {type: "word"} : word)], "postprocess": notReservedKw('raise')},
462463
{"name": "kw_continue", "symbols": [(lexerAny.has("word") ? {type: "word"} : word)], "postprocess": notReservedKw('continue')},
464+
{"name": "kw_share", "symbols": [(lexerAny.has("word") ? {type: "word"} : word)], "postprocess": notReservedKw('share')},
463465
{"name": "kw_ifnotexists", "symbols": ["kw_if", (lexerAny.has("kw_not") ? {type: "kw_not"} : kw_not), "kw_exists"]},
464466
{"name": "kw_ifexists", "symbols": ["kw_if", "kw_exists"]},
465467
{"name": "kw_not_null", "symbols": [(lexerAny.has("kw_not") ? {type: "kw_not"} : kw_not), (lexerAny.has("kw_null") ? {type: "kw_null"} : kw_null)]},
@@ -574,8 +576,10 @@ const grammar: Grammar = {
574576
{"name": "select_statement$ebnf$3", "symbols": [], "postprocess": () => null},
575577
{"name": "select_statement$ebnf$4", "symbols": ["select_order_by"], "postprocess": id},
576578
{"name": "select_statement$ebnf$4", "symbols": [], "postprocess": () => null},
577-
{"name": "select_statement", "symbols": ["select_what", "select_statement$ebnf$1", "select_statement$ebnf$2", "select_statement$ebnf$3", "select_statement$ebnf$4", "select_limit"], "postprocess": x => {
578-
let [what, from, where, groupBy, orderBy, limit] = x;
579+
{"name": "select_statement$ebnf$5", "symbols": ["select_for"], "postprocess": id},
580+
{"name": "select_statement$ebnf$5", "symbols": [], "postprocess": () => null},
581+
{"name": "select_statement", "symbols": ["select_what", "select_statement$ebnf$1", "select_statement$ebnf$2", "select_statement$ebnf$3", "select_statement$ebnf$4", "select_limit", "select_statement$ebnf$5"], "postprocess": x => {
582+
let [what, from, where, groupBy, orderBy, limit, selectFor] = x;
579583
from = unwrap(from);
580584
groupBy = groupBy && (groupBy.length === 1 && groupBy[0].type === 'list' ? groupBy[0].expressions : groupBy);
581585
return track(x, {
@@ -585,6 +589,7 @@ const grammar: Grammar = {
585589
...limit ? { limit } : {},
586590
...orderBy ? { orderBy } : {},
587591
...where ? { where } : {},
592+
...selectFor ? { for: selectFor[1] } : {},
588593
type: 'select',
589594
});
590595
} },
@@ -736,6 +741,11 @@ const grammar: Grammar = {
736741
...offset ? {offset} : {},
737742
});
738743
}},
744+
{"name": "select_for$subexpression$1", "symbols": ["kw_update"], "postprocess": x => track(x, {type: 'update'})},
745+
{"name": "select_for$subexpression$1", "symbols": ["kw_no", "kw_key", "kw_update"], "postprocess": x => track(x, {type: 'no key update'})},
746+
{"name": "select_for$subexpression$1", "symbols": ["kw_share"], "postprocess": x => track(x, {type: 'share'})},
747+
{"name": "select_for$subexpression$1", "symbols": ["kw_key", "kw_share"], "postprocess": x => track(x, {type: 'key share'})},
748+
{"name": "select_for", "symbols": [(lexerAny.has("kw_for") ? {type: "kw_for"} : kw_for), "select_for$subexpression$1"]},
739749
{"name": "select_order_by$subexpression$1", "symbols": [(lexerAny.has("kw_order") ? {type: "kw_order"} : kw_order), "kw_by"]},
740750
{"name": "select_order_by$ebnf$1", "symbols": []},
741751
{"name": "select_order_by$ebnf$1$subexpression$1", "symbols": ["comma", "select_order_by_expr"], "postprocess": last},
@@ -1826,13 +1836,19 @@ const grammar: Grammar = {
18261836
{"name": "altertable_statement$ebnf$1", "symbols": [], "postprocess": () => null},
18271837
{"name": "altertable_statement$ebnf$2", "symbols": [(lexerAny.has("kw_only") ? {type: "kw_only"} : kw_only)], "postprocess": id},
18281838
{"name": "altertable_statement$ebnf$2", "symbols": [], "postprocess": () => null},
1829-
{"name": "altertable_statement", "symbols": ["kw_alter", (lexerAny.has("kw_table") ? {type: "kw_table"} : kw_table), "altertable_statement$ebnf$1", "altertable_statement$ebnf$2", "table_ref", "altertable_action"], "postprocess": x => track(x, {
1839+
{"name": "altertable_statement", "symbols": ["kw_alter", (lexerAny.has("kw_table") ? {type: "kw_table"} : kw_table), "altertable_statement$ebnf$1", "altertable_statement$ebnf$2", "table_ref", "altertable_actions"], "postprocess": x => track(x, {
18301840
type: 'alter table',
18311841
... x[2] ? {ifExists: true} : {},
18321842
... x[3] ? {only: true} : {},
18331843
table: unwrap(x[4]),
1834-
change: unwrap(x[5]),
1844+
changes: unbox(x[5]).map(unwrap),
18351845
}) },
1846+
{"name": "altertable_actions$ebnf$1", "symbols": []},
1847+
{"name": "altertable_actions$ebnf$1$subexpression$1", "symbols": ["comma", "altertable_action"], "postprocess": last},
1848+
{"name": "altertable_actions$ebnf$1", "symbols": ["altertable_actions$ebnf$1", "altertable_actions$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
1849+
{"name": "altertable_actions", "symbols": ["altertable_action", "altertable_actions$ebnf$1"], "postprocess": ([head, tail]) => {
1850+
return [head, ...(tail || [])];
1851+
} },
18361852
{"name": "altertable_action", "symbols": ["altertable_rename_table"]},
18371853
{"name": "altertable_action", "symbols": ["altertable_rename_column"]},
18381854
{"name": "altertable_action", "symbols": ["altertable_rename_constraint"]},

0 commit comments

Comments
 (0)