mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 20:46:01 +00:00
insert into tables with identity
This commit is contained in:
@@ -18,7 +18,7 @@ export function dumpSqlSelect(dmp: SqlDumper, cmd: Select) {
|
||||
if (cmd.columns) {
|
||||
if (cmd.selectAll) dmp.put('&n,');
|
||||
dmp.put('&>&n');
|
||||
dmp.putCollection(',&n', cmd.columns, fld => {
|
||||
dmp.putCollection(',&n', cmd.columns, (fld) => {
|
||||
dumpSqlExpression(dmp, fld);
|
||||
if (fld.alias) dmp.put(' ^as %i', fld.alias);
|
||||
});
|
||||
@@ -33,12 +33,12 @@ export function dumpSqlSelect(dmp: SqlDumper, cmd: Select) {
|
||||
}
|
||||
if (cmd.groupBy) {
|
||||
dmp.put('&n^group ^by ');
|
||||
dmp.putCollection(', ', cmd.groupBy, expr => dumpSqlExpression(dmp, expr));
|
||||
dmp.putCollection(', ', cmd.groupBy, (expr) => dumpSqlExpression(dmp, expr));
|
||||
dmp.put('&n');
|
||||
}
|
||||
if (cmd.orderBy) {
|
||||
dmp.put('&n^order ^by ');
|
||||
dmp.putCollection(', ', cmd.orderBy, expr => {
|
||||
dmp.putCollection(', ', cmd.orderBy, (expr) => {
|
||||
dumpSqlExpression(dmp, expr);
|
||||
dmp.put(' %k', expr.direction);
|
||||
});
|
||||
@@ -59,7 +59,7 @@ export function dumpSqlUpdate(dmp: SqlDumper, cmd: Update) {
|
||||
|
||||
dmp.put('&n^set ');
|
||||
dmp.put('&>');
|
||||
dmp.putCollection(', ', cmd.fields, col => {
|
||||
dmp.putCollection(', ', cmd.fields, (col) => {
|
||||
dmp.put('%i=', col.targetColumn);
|
||||
dumpSqlExpression(dmp, col);
|
||||
});
|
||||
@@ -73,7 +73,7 @@ export function dumpSqlUpdate(dmp: SqlDumper, cmd: Update) {
|
||||
}
|
||||
|
||||
export function dumpSqlDelete(dmp: SqlDumper, cmd: Delete) {
|
||||
dmp.put('^delete ');
|
||||
dmp.put('^delete ^from ');
|
||||
dumpSqlSourceRef(dmp, cmd.from);
|
||||
|
||||
if (cmd.where) {
|
||||
@@ -87,9 +87,9 @@ export function dumpSqlInsert(dmp: SqlDumper, cmd: Insert) {
|
||||
dmp.put(
|
||||
'^insert ^into %f (%,i) ^values (',
|
||||
cmd.targetTable,
|
||||
cmd.fields.map(x => x.targetColumn)
|
||||
cmd.fields.map((x) => x.targetColumn)
|
||||
);
|
||||
dmp.putCollection(',', cmd.fields, x => dumpSqlExpression(dmp, x));
|
||||
dmp.putCollection(',', cmd.fields, (x) => dumpSqlExpression(dmp, x));
|
||||
dmp.put(')');
|
||||
}
|
||||
|
||||
@@ -107,5 +107,8 @@ export function dumpSqlCommand(dmp: SqlDumper, cmd: Command) {
|
||||
case 'insert':
|
||||
dumpSqlInsert(dmp, cmd);
|
||||
break;
|
||||
case 'allowIdentityInsert':
|
||||
dmp.allowIdentityInsert(cmd.targetTable, cmd.allow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user