Skip to content

Commit

Permalink
Build deno [autogenerated commit]
Browse files Browse the repository at this point in the history
  • Loading branch information
oguimbal committed Apr 28, 2021
1 parent f632503 commit 8ba511b
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 108 deletions.
37 changes: 19 additions & 18 deletions .deno/ast-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface IAstPartialMapper {
from?: (from: a.From) => a.From | nil
fromCall?: (from: a.FromCall) => a.From | nil
fromStatement?: (from: a.FromStatement) => a.From | nil
fromValues?: (from: a.FromValues) => a.From | nil;
values?: (from: a.ValuesStatement) => a.SelectStatement | nil;
fromTable?: (from: a.FromTable) => a.From | nil
selectionColumn?: (val: a.SelectedColumn) => a.SelectedColumn | nil
expr?: (val: a.Expr) => a.Expr | nil
Expand All @@ -68,6 +68,7 @@ export interface IAstPartialMapper {
callOverlay?: (val: a.ExprOverlay) => a.Expr | nil
array?: (val: a.ExprList) => a.Expr | nil
constant?: (value: a.ExprLiteral) => a.Expr | nil
default?: (value: a.ExprDefault) => a.Expr | nil;
ref?: (val: a.ExprRef) => a.Expr | nil
unary?: (val: a.ExprUnary) => a.Expr | nil
binary?: (val: a.ExprBinary) => a.Expr | nil
Expand Down Expand Up @@ -272,6 +273,8 @@ export class AstDefaultMapper implements IAstMapper {
return this.do(val);
case 'create function':
return this.createFunction(val);
case 'values':
return this.values(val);
default:
throw NotSupported.never(val);
}
Expand Down Expand Up @@ -432,18 +435,10 @@ export class AstDefaultMapper implements IAstMapper {
if (!into) {
return null; // nowhere to insert into
}
const values = arrayNilMap(val.values, valSet => {
return arrayNilMap(valSet, v => {
if (v === 'default') {
return v;
}
return this.expr(v);
});
});

const select = val.select && this.select(val.select);
const select = val.insert && this.select(val.insert);

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

return assignChanged(val, {
into,
values,
select,
insert: select,
returning,
onConflict: !ocdo ? val.onConflict : assignChanged(val.onConflict, {
do: ocdo,
Expand Down Expand Up @@ -811,6 +805,8 @@ export class AstDefaultMapper implements IAstMapper {
return this.union(val);
case 'with':
return this.with(val);
case 'values':
return this.values(val);
default:
throw NotSupported.never(val);
}
Expand Down Expand Up @@ -894,8 +890,6 @@ export class AstDefaultMapper implements IAstMapper {
return this.fromTable(from);
case 'statement':
return this.fromStatement(from);
case 'values':
return this.fromValues(from);
case 'call':
return this.fromCall(from);
default:
Expand Down Expand Up @@ -924,7 +918,7 @@ export class AstDefaultMapper implements IAstMapper {
})
}

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

fromTable(from: a.FromTable): a.From | nil {
const nfrom = this.tableRef(from);
const nfrom = this.tableRef(from.name);
if (!nfrom) {
return null; // nothing to select from
}
const join = from.join && this.join(from.join);
return assignChanged(from, {
...nfrom,
name: nfrom,
join,
})
}
Expand Down Expand Up @@ -1021,6 +1015,10 @@ export class AstDefaultMapper implements IAstMapper {
return this.callOverlay(val);
case 'substring':
return this.callSubstring(val);
case 'values':
return this.values(val);
case 'default':
return this.default(val);
default:
throw NotSupported.never(val);
}
Expand Down Expand Up @@ -1166,6 +1164,9 @@ export class AstDefaultMapper implements IAstMapper {
return value;
}

default(value: a.ExprDefault): a.Expr | nil {
return value;
}

/** Called when a reference is used */
ref(val: a.ExprRef): a.Expr | nil {
Expand Down
33 changes: 22 additions & 11 deletions .deno/syntax/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type Statement = SelectStatement
| CommentStatement
| CreateSchemaStatement
| RaiseStatement
| ValuesStatement
| CreateFunctionStatement
| DoStatement
| BeginStatement
Expand Down Expand Up @@ -156,6 +157,7 @@ export interface ShowStatement extends PGNode {
export interface TruncateTableStatement extends PGNode {
type: 'truncate table';
tables: QName[];
identity?: 'restart' | 'continue';
}
export interface DropTableStatement extends PGNode {
type: 'drop table';
Expand Down Expand Up @@ -212,10 +214,7 @@ export interface InsertStatement extends PGNode {
returning?: SelectedColumn[] | nil;
columns?: Name[] | nil;
overriding?: 'system' | 'user';
/** Insert values */
values?: (Expr | 'default')[][] | nil;
/** Insert into select */
select?: SelectStatement | nil;
insert: SelectStatement;
onConflict?: OnConflictAction | nil;
}

Expand Down Expand Up @@ -512,6 +511,7 @@ export interface WithStatement extends PGNode {

export type SelectStatement = SelectFromStatement
| SelectFromUnion
| ValuesStatement
| WithStatement;

export interface SelectFromStatement extends PGNode {
Expand Down Expand Up @@ -560,7 +560,9 @@ export interface SelectedColumn extends PGNode {
alias?: Name;
}

export type From = FromTable | FromStatement | FromValues | FromCall
export type From = FromTable
| FromStatement
| FromCall


export interface FromCall extends ExprCall, PGNode {
Expand All @@ -570,28 +572,32 @@ export interface FromCall extends ExprCall, PGNode {



export interface FromValues {
export interface ValuesStatement extends PGNode {
type: 'values';
alias: Name;
values: Expr[][];
columnNames?: Name[] | nil;
join?: JoinClause | nil;
}



export interface QNameAliased extends QName, PGNode {
alias?: string;
}

export interface FromTable extends QNameAliased, PGNode {
export interface QNameMapped extends QNameAliased {
columnNames?: Name[] | nil;
}

export interface FromTable extends PGNode {
type: 'table',
name: QNameMapped;
join?: JoinClause | nil;
}

export interface FromStatement extends PGNode {
type: 'statement';
statement: SelectStatement;
alias: Name;
alias: string;
columnNames?: Name[] | nil;
db?: null | nil;
join?: JoinClause | nil;
}
Expand All @@ -614,6 +620,7 @@ export type Expr = ExprRef
| ExprNull
| ExprExtract
| ExprInteger
| ExprDefault
| ExprMember
| ExprValueKeyword
| ExprArrayIndex
Expand Down Expand Up @@ -804,6 +811,10 @@ export interface ExprInteger extends PGNode {
value: number;
}

export interface ExprDefault extends PGNode {
type: 'default';
}

export interface ExprNumeric extends PGNode {
type: 'numeric';
value: number;
Expand Down
Loading

0 comments on commit 8ba511b

Please sign in to comment.