Skip to content

Commit 0899b2c

Browse files
committed
Fix extra comma being added after index on export (#141)
1 parent c43adae commit 0899b2c

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

src/utils/toSQL.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export function jsonToMySQL(obj) {
181181
)}", \`${field.name}\`))`
182182
: ""
183183
: ` CHECK(${field.check})`
184-
}${field.comment ? ` COMMENT '${field.comment}'` : ''}`,
184+
}${field.comment ? ` COMMENT '${field.comment}'` : ""}`,
185185
)
186186
.join(",\n")}${
187187
table.fields.filter((f) => f.primary).length > 0
@@ -190,16 +190,16 @@ export function jsonToMySQL(obj) {
190190
.map((f) => `\`${f.name}\``)
191191
.join(", ")})`
192192
: ""
193-
}\n)${table.comment ? ` COMMENT='${table.comment}'` : ''};\n${
193+
}\n)${table.comment ? ` COMMENT='${table.comment}'` : ""};\n${
194194
table.indices.length > 0
195-
? `\n${table.indices.map(
196-
(i) =>
197-
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
198-
i.name
199-
}\`\nON \`${table.name}\` (${i.fields
200-
.map((f) => `\`${f}\``)
201-
.join(", ")});`,
202-
)}`
195+
? `\n${table.indices
196+
.map(
197+
(i) =>
198+
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${i.name}\`\nON \`${table.name}\` (${i.fields
199+
.map((f) => `\`${f}\``)
200+
.join(", ")});`,
201+
)
202+
.join("\n")}`
203203
: ""
204204
}`,
205205
)
@@ -282,14 +282,16 @@ export function jsonToPostgreSQL(obj) {
282282
: ""
283283
}\n);\n${
284284
table.indices.length > 0
285-
? `${table.indices.map(
286-
(i) =>
287-
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX "${
288-
i.name
289-
}"\nON "${table.name}" (${i.fields
290-
.map((f) => `"${f}"`)
291-
.join(", ")});`,
292-
)}`
285+
? `${table.indices
286+
.map(
287+
(i) =>
288+
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX "${
289+
i.name
290+
}"\nON "${table.name}" (${i.fields
291+
.map((f) => `"${f}"`)
292+
.join(", ")});`,
293+
)
294+
.join("\n")}`
293295
: ""
294296
}`,
295297
)
@@ -433,14 +435,16 @@ export function jsonToMariaDB(obj) {
433435
: ""
434436
}\n);${
435437
table.indices.length > 0
436-
? `\n${table.indices.map(
437-
(i) =>
438-
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
439-
i.name
440-
}\`\nON \`${table.name}\` (${i.fields
441-
.map((f) => `\`${f}\``)
442-
.join(", ")});`,
443-
)}`
438+
? `\n${table.indices
439+
.map(
440+
(i) =>
441+
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
442+
i.name
443+
}\`\nON \`${table.name}\` (${i.fields
444+
.map((f) => `\`${f}\``)
445+
.join(", ")});`,
446+
)
447+
.join("\n")}`
444448
: ""
445449
}`,
446450
)

0 commit comments

Comments
 (0)