mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 10:13:57 +00:00
sql dumper
This commit is contained in:
@@ -40,6 +40,11 @@ class SqlDumper {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
putFormattedList(c, collection) {
|
||||||
|
this.putCollection(", ", collection, item =>
|
||||||
|
this.putFormattedValue(c, item)
|
||||||
|
);
|
||||||
|
}
|
||||||
/** @param format {string} */
|
/** @param format {string} */
|
||||||
put(format, ...args) {
|
put(format, ...args) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
@@ -58,7 +63,20 @@ class SqlDumper {
|
|||||||
case "%":
|
case "%":
|
||||||
c = format[i];
|
c = format[i];
|
||||||
i++;
|
i++;
|
||||||
|
switch (c) {
|
||||||
|
case "%":
|
||||||
|
this.putRaw("%");
|
||||||
|
break;
|
||||||
|
case ",":
|
||||||
|
c = format[i];
|
||||||
|
i++;
|
||||||
|
this.putFormattedList(c, args[argIndex]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
this.putFormattedValue(c, args[argIndex]);
|
this.putFormattedValue(c, args[argIndex]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
argIndex++;
|
argIndex++;
|
||||||
break;
|
break;
|
||||||
case "&":
|
case "&":
|
||||||
@@ -160,25 +178,16 @@ class SqlDumper {
|
|||||||
this.put("%i", col.columnName);
|
this.put("%i", col.columnName);
|
||||||
this.columnDefinition(col);
|
this.columnDefinition(col);
|
||||||
});
|
});
|
||||||
// bool first = true;
|
if (table.primaryKey) {
|
||||||
// _primaryKeyWrittenInCreateTable = false;
|
this.put(",&n");
|
||||||
// foreach (var col in table.Columns)
|
if (table.primaryKey.constraintName) {
|
||||||
// {
|
this.put("^constraint %i", table.primaryKey.constraintName);
|
||||||
// if (!first) Put(", &n");
|
}
|
||||||
// first = false;
|
this.put(
|
||||||
// Put("%i ", col.Name);
|
" ^primary ^key (%,i)",
|
||||||
// ColumnDefinition(col, true, true, true);
|
table.primaryKey.columns.map(x => x.columnName)
|
||||||
// }
|
);
|
||||||
// if (table.PrimaryKey != null && !_primaryKeyWrittenInCreateTable)
|
}
|
||||||
// {
|
|
||||||
// if (!first) Put(", &n");
|
|
||||||
// first = false;
|
|
||||||
// if (table.PrimaryKey.ConstraintName != null)
|
|
||||||
// {
|
|
||||||
// Put("^constraint %i", table.PrimaryKey.ConstraintName);
|
|
||||||
// }
|
|
||||||
// Put(" ^primary ^key (%,i)", table.PrimaryKey.Columns);
|
|
||||||
// }
|
|
||||||
// foreach (var cnt in table.ForeignKeys)
|
// foreach (var cnt in table.ForeignKeys)
|
||||||
// {
|
// {
|
||||||
// if (!first) Put(", &n");
|
// if (!first) Put(", &n");
|
||||||
|
|||||||
2
packages/types/dbinfo.d.ts
vendored
2
packages/types/dbinfo.d.ts
vendored
@@ -14,7 +14,7 @@ export interface ConstraintInfo extends NamedObjectInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ColumnsConstraintInfo extends ConstraintInfo {
|
export interface ColumnsConstraintInfo extends ConstraintInfo {
|
||||||
columns: ConstraintInfo[];
|
columns: ColumnReference[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrimaryKeyInfo extends ColumnsConstraintInfo {}
|
export interface PrimaryKeyInfo extends ColumnsConstraintInfo {}
|
||||||
|
|||||||
Reference in New Issue
Block a user