mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 23:35:59 +00:00
generate update script
This commit is contained in:
18
packages/sqltree/src/utility.ts
Normal file
18
packages/sqltree/src/utility.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { EngineDriver, SqlDumper } from '@dbgate/types';
|
||||
import { Command } from './types';
|
||||
import { dumpSqlCommand } from './dumpSqlCommand';
|
||||
|
||||
export function treeToSql<T>(driver: EngineDriver, object: T, func: (dmp: SqlDumper, obj: T) => void) {
|
||||
const dmp = driver.createDumper();
|
||||
func(dmp, object);
|
||||
return dmp.s;
|
||||
}
|
||||
|
||||
export function scriptToSql(driver: EngineDriver, script: Command[]): string {
|
||||
const dmp = driver.createDumper();
|
||||
for (const cmd of script) {
|
||||
dumpSqlCommand(dmp, cmd);
|
||||
dmp.endCommand();
|
||||
}
|
||||
return dmp.s;
|
||||
}
|
||||
Reference in New Issue
Block a user