Skip to content

Commit 8ba511b

Browse files
committed
Build deno [autogenerated commit]
1 parent f632503 commit 8ba511b

File tree

4 files changed

+133
-108
lines changed

4 files changed

+133
-108
lines changed

.deno/ast-mapper.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface IAstPartialMapper {
5252
from?: (from: a.From) => a.From | nil
5353
fromCall?: (from: a.FromCall) => a.From | nil
5454
fromStatement?: (from: a.FromStatement) => a.From | nil
55-
fromValues?: (from: a.FromValues) => a.From | nil;
55+
values?: (from: a.ValuesStatement) => a.SelectStatement | nil;
5656
fromTable?: (from: a.FromTable) => a.From | nil
5757
selectionColumn?: (val: a.SelectedColumn) => a.SelectedColumn | nil
5858
expr?: (val: a.Expr) => a.Expr | nil
@@ -68,6 +68,7 @@ export interface IAstPartialMapper {
6868
callOverlay?: (val: a.ExprOverlay) => a.Expr | nil
6969
array?: (val: a.ExprList) => a.Expr | nil
7070
constant?: (value: a.ExprLiteral) => a.Expr | nil
71+
default?: (value: a.ExprDefault) => a.Expr | nil;
7172
ref?: (val: a.ExprRef) => a.Expr | nil
7273
unary?: (val: a.ExprUnary) => a.Expr | nil
7374
binary?: (val: a.ExprBinary) => a.Expr | nil
@@ -272,6 +273,8 @@ export class AstDefaultMapper implements IAstMapper {
272273
return this.do(val);
273274
case 'create function':
274275
return this.createFunction(val);
276+
case 'values':
277+
return this.values(val);
275278
default:
276279
throw NotSupported.never(val);
277280
}
@@ -432,18 +435,10 @@ export class AstDefaultMapper implements IAstMapper {
432435
if (!into) {
433436
return null; // nowhere to insert into
434437
}
435-
const values = arrayNilMap(val.values, valSet => {
436-
return arrayNilMap(valSet, v => {
437-
if (v === 'default') {
438-
return v;
439-
}
440-
return this.expr(v);
441-
});
442-
});
443438

444-
const select = val.select && this.select(val.select);
439+
const select = val.insert && this.select(val.insert);
445440

446-
if (!values?.length && !select) {
441+
if (!select) {
447442
// nothing to insert
448443
return null;
449444
}
@@ -462,8 +457,7 @@ export class AstDefaultMapper implements IAstMapper {
462457

463458
return assignChanged(val, {
464459
into,
465-
values,
466-
select,
460+
insert: select,
467461
returning,
468462
onConflict: !ocdo ? val.onConflict : assignChanged(val.onConflict, {
469463
do: ocdo,
@@ -811,6 +805,8 @@ export class AstDefaultMapper implements IAstMapper {
811805
return this.union(val);
812806
case 'with':
813807
return this.with(val);
808+
case 'values':
809+
return this.values(val);
814810
default:
815811
throw NotSupported.never(val);
816812
}
@@ -894,8 +890,6 @@ export class AstDefaultMapper implements IAstMapper {
894890
return this.fromTable(from);
895891
case 'statement':
896892
return this.fromStatement(from);
897-
case 'values':
898-
return this.fromValues(from);
899893
case 'call':
900894
return this.fromCall(from);
901895
default:
@@ -924,7 +918,7 @@ export class AstDefaultMapper implements IAstMapper {
924918
})
925919
}
926920

927-
fromValues(from: a.FromValues): a.From | nil {
921+
values(from: a.ValuesStatement): a.SelectStatement | nil {
928922
const values = arrayNilMap(from.values, x => arrayNilMap(x, y => this.expr(y)));
929923
if (!values?.length) {
930924
return null; // nothing to select from
@@ -945,13 +939,13 @@ export class AstDefaultMapper implements IAstMapper {
945939
}
946940

947941
fromTable(from: a.FromTable): a.From | nil {
948-
const nfrom = this.tableRef(from);
942+
const nfrom = this.tableRef(from.name);
949943
if (!nfrom) {
950944
return null; // nothing to select from
951945
}
952946
const join = from.join && this.join(from.join);
953947
return assignChanged(from, {
954-
...nfrom,
948+
name: nfrom,
955949
join,
956950
})
957951
}
@@ -1021,6 +1015,10 @@ export class AstDefaultMapper implements IAstMapper {
10211015
return this.callOverlay(val);
10221016
case 'substring':
10231017
return this.callSubstring(val);
1018+
case 'values':
1019+
return this.values(val);
1020+
case 'default':
1021+
return this.default(val);
10241022
default:
10251023
throw NotSupported.never(val);
10261024
}
@@ -1166,6 +1164,9 @@ export class AstDefaultMapper implements IAstMapper {
11661164
return value;
11671165
}
11681166

1167+
default(value: a.ExprDefault): a.Expr | nil {
1168+
return value;
1169+
}
11691170

11701171
/** Called when a reference is used */
11711172
ref(val: a.ExprRef): a.Expr | nil {

.deno/syntax/ast.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type Statement = SelectStatement
3737
| CommentStatement
3838
| CreateSchemaStatement
3939
| RaiseStatement
40+
| ValuesStatement
4041
| CreateFunctionStatement
4142
| DoStatement
4243
| BeginStatement
@@ -156,6 +157,7 @@ export interface ShowStatement extends PGNode {
156157
export interface TruncateTableStatement extends PGNode {
157158
type: 'truncate table';
158159
tables: QName[];
160+
identity?: 'restart' | 'continue';
159161
}
160162
export interface DropTableStatement extends PGNode {
161163
type: 'drop table';
@@ -212,10 +214,7 @@ export interface InsertStatement extends PGNode {
212214
returning?: SelectedColumn[] | nil;
213215
columns?: Name[] | nil;
214216
overriding?: 'system' | 'user';
215-
/** Insert values */
216-
values?: (Expr | 'default')[][] | nil;
217-
/** Insert into select */
218-
select?: SelectStatement | nil;
217+
insert: SelectStatement;
219218
onConflict?: OnConflictAction | nil;
220219
}
221220

@@ -512,6 +511,7 @@ export interface WithStatement extends PGNode {
512511

513512
export type SelectStatement = SelectFromStatement
514513
| SelectFromUnion
514+
| ValuesStatement
515515
| WithStatement;
516516

517517
export interface SelectFromStatement extends PGNode {
@@ -560,7 +560,9 @@ export interface SelectedColumn extends PGNode {
560560
alias?: Name;
561561
}
562562

563-
export type From = FromTable | FromStatement | FromValues | FromCall
563+
export type From = FromTable
564+
| FromStatement
565+
| FromCall
564566

565567

566568
export interface FromCall extends ExprCall, PGNode {
@@ -570,28 +572,32 @@ export interface FromCall extends ExprCall, PGNode {
570572

571573

572574

573-
export interface FromValues {
575+
export interface ValuesStatement extends PGNode {
574576
type: 'values';
575-
alias: Name;
576577
values: Expr[][];
577-
columnNames?: Name[] | nil;
578-
join?: JoinClause | nil;
579578
}
580579

581580

581+
582582
export interface QNameAliased extends QName, PGNode {
583583
alias?: string;
584584
}
585585

586-
export interface FromTable extends QNameAliased, PGNode {
586+
export interface QNameMapped extends QNameAliased {
587+
columnNames?: Name[] | nil;
588+
}
589+
590+
export interface FromTable extends PGNode {
587591
type: 'table',
592+
name: QNameMapped;
588593
join?: JoinClause | nil;
589594
}
590595

591596
export interface FromStatement extends PGNode {
592597
type: 'statement';
593598
statement: SelectStatement;
594-
alias: Name;
599+
alias: string;
600+
columnNames?: Name[] | nil;
595601
db?: null | nil;
596602
join?: JoinClause | nil;
597603
}
@@ -614,6 +620,7 @@ export type Expr = ExprRef
614620
| ExprNull
615621
| ExprExtract
616622
| ExprInteger
623+
| ExprDefault
617624
| ExprMember
618625
| ExprValueKeyword
619626
| ExprArrayIndex
@@ -804,6 +811,10 @@ export interface ExprInteger extends PGNode {
804811
value: number;
805812
}
806813

814+
export interface ExprDefault extends PGNode {
815+
type: 'default';
816+
}
817+
807818
export interface ExprNumeric extends PGNode {
808819
type: 'numeric';
809820
value: number;

0 commit comments

Comments
 (0)