({
name,
when,
operation,
columnNames,
tableName,
statement,
}: Record<string, string>)
| 1 | import { parseCreateTriggerScript } from "./sql-parse-trigger"; |
| 2 | |
| 3 | function generateSql({ |
| 4 | name, |
| 5 | when, |
| 6 | operation, |
| 7 | columnNames, |
| 8 | tableName, |
| 9 | statement, |
| 10 | }: Record<string, string>) { |
| 11 | let whenString = ""; |
| 12 | if (when) { |
| 13 | whenString = `${when} `; |
| 14 | } |
| 15 | let columnNameString = ""; |
| 16 | if (columnNames) { |
| 17 | columnNameString = ` ${columnNames}`; |
| 18 | } |
| 19 | return ` |
| 20 | CREATE TRIGGER ${name} |
| 21 | ${whenString}${operation}${columnNameString} ON ${tableName} |
| 22 | BEGIN |
| 23 | ${statement} |
| 24 | END; |
| 25 | `; |
| 26 | } |
| 27 | |
| 28 | describe("parse trigger", () => { |
| 29 | const name = "cust_addr_chng"; |
no outgoing calls
no test coverage detected