Escape reserved separator identifiers in MySQL SQL
This commit is contained in:
@@ -151,7 +151,7 @@ export function createMysqlAdapter(context) {
|
||||
const extension = seed();
|
||||
for (const rule of extension.admissionNumberRules) await pool.execute(
|
||||
`INSERT INTO admission_number_rules (
|
||||
id, code, name, description, separator, segments_json, example, active, created_at
|
||||
id, code, name, description, \`separator\`, segments_json, example, active, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[rule.id, rule.code, rule.name, rule.description, rule.separator || '', JSON.stringify(rule.segments || []),
|
||||
rule.example || '', rule.active === false ? 0 : 1, rule.createdAt]
|
||||
@@ -226,7 +226,7 @@ export function createMysqlAdapter(context) {
|
||||
const [ruleRows] = await connection.execute('SELECT id FROM number_rules LIMIT 1');
|
||||
if (!ruleRows.length) for (const rule of extension.numberRules) {
|
||||
await connection.execute(
|
||||
'INSERT INTO number_rules (id, name, separator, active, created_by, updated_at) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
'INSERT INTO number_rules (id, name, `separator`, active, created_by, updated_at) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
[rule.id, rule.name, rule.separator || '', rule.active ? 1 : 0, optional(rule.createdBy), rule.updatedAt]
|
||||
);
|
||||
for (const [index, segment] of rule.segments.entries()) await connection.execute(
|
||||
|
||||
@@ -708,7 +708,7 @@ export const mysqlSchema = [
|
||||
code VARCHAR(80) NOT NULL,
|
||||
name VARCHAR(160) NOT NULL,
|
||||
description VARCHAR(500) NOT NULL,
|
||||
separator VARCHAR(10) NOT NULL DEFAULT '',
|
||||
\`separator\` VARCHAR(10) NOT NULL DEFAULT '',
|
||||
segments_json JSON NOT NULL,
|
||||
example VARCHAR(120) NOT NULL,
|
||||
active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
@@ -824,7 +824,7 @@ export const mysqlSchema = [
|
||||
`CREATE TABLE IF NOT EXISTS number_rules (
|
||||
id VARCHAR(64) NOT NULL,
|
||||
name VARCHAR(120) NOT NULL,
|
||||
separator VARCHAR(10) NOT NULL DEFAULT '',
|
||||
\`separator\` VARCHAR(10) NOT NULL DEFAULT '',
|
||||
active BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_by VARCHAR(64) NULL,
|
||||
updated_at VARCHAR(35) NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user