|
1 | 1 |
|
2 |
| -import { spec } from "node:test/reporters"; |
3 | 2 | import { getInstance } from "../base";
|
4 | 3 |
|
5 | 4 | import { JobManager } from "../config";
|
@@ -235,10 +234,26 @@ export default class Schemas {
|
235 | 234 | * @param schema Not user input
|
236 | 235 | * @param object Not user input
|
237 | 236 | */
|
238 |
| - static async generateSQL(schema: string, object: string, internalType: string): Promise<string> { |
239 |
| - const lines = await JobManager.runSQL<{ SRCDTA: string }>([ |
240 |
| - `CALL QSYS2.GENERATE_SQL(?, ?, ?, CREATE_OR_REPLACE_OPTION => '1', PRIVILEGES_OPTION => '0')` |
241 |
| - ].join(` `), { parameters: [object, schema, internalType] }); |
| 237 | + static async generateSQL(schema: string, object: string, internalType: string, basic?: boolean): Promise<string> { |
| 238 | + let statement = `CALL QSYS2.GENERATE_SQL(?, ?, ?, CREATE_OR_REPLACE_OPTION => '1', PRIVILEGES_OPTION => '0')`; |
| 239 | + |
| 240 | + if (basic) { |
| 241 | + let options: string[] = [ |
| 242 | + `CREATE_OR_REPLACE_OPTION => '0'`, |
| 243 | + `PRIVILEGES_OPTION => '0'`, |
| 244 | + `COMMENT_OPTION => '0'`, |
| 245 | + `LABEL_OPTION => '0'`, |
| 246 | + `HEADER_OPTION => '0'`, |
| 247 | + `TRIGGER_OPTION => '0'`, |
| 248 | + `CONSTRAINT_OPTION => '0'`, |
| 249 | + // `PRIVILEGES_OPTION => '0'`, |
| 250 | + // `ACTIVATE_ACCESS_CONTROL_OPTION => '0'`, |
| 251 | + `MASK_AND_PERMISSION_OPTION => '0'`, |
| 252 | + ]; |
| 253 | + statement = `CALL QSYS2.GENERATE_SQL(?, ?, ?, ${options.join(`, `)})`; |
| 254 | + } |
| 255 | + |
| 256 | + const lines = await JobManager.runSQL<{ SRCDTA: string }>(statement, { parameters: [object, schema, internalType] }); |
242 | 257 |
|
243 | 258 | const generatedStatement = lines.map(line => line.SRCDTA).join(`\n`);
|
244 | 259 |
|
|
0 commit comments