(defaultValue: any, collate: string)
| 541 | }; |
| 542 | |
| 543 | function clearDefaults(defaultValue: any, collate: string) { |
| 544 | if (typeof collate === 'undefined' || collate === null) { |
| 545 | collate = `utf8mb4`; |
| 546 | } |
| 547 | |
| 548 | let resultDefault = defaultValue; |
| 549 | collate = `_${collate}`; |
| 550 | if (defaultValue.startsWith(collate)) { |
| 551 | resultDefault = resultDefault |
| 552 | .substring(collate.length, defaultValue.length) |
| 553 | .replace(/\\/g, ''); |
| 554 | if (resultDefault.startsWith("'") && resultDefault.endsWith("'")) { |
| 555 | return `('${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}')`; |
| 556 | } else { |
| 557 | return `'${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}'`; |
| 558 | } |
| 559 | } else { |
| 560 | return `(${resultDefault})`; |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | export const fromDatabase = async ( |
| 565 | db: DB, |
no test coverage detected