mirror of
https://github.com/Fabio286/antares.git
synced 2025-04-24 06:57:19 +02:00
fix: no quotes around strings in field default custom value
This commit is contained in:
parent
bebba64d06
commit
29e2d92b5b
@ -79,7 +79,7 @@
|
|||||||
"mysql2": "^2.2.5",
|
"mysql2": "^2.2.5",
|
||||||
"node-sql-parser": "^3.1.0",
|
"node-sql-parser": "^3.1.0",
|
||||||
"pg": "^8.5.1",
|
"pg": "^8.5.1",
|
||||||
"pgsql-ast-parser": "^7.0.2",
|
"pgsql-ast-parser": "^7.2.1",
|
||||||
"source-map-support": "^0.5.16",
|
"source-map-support": "^0.5.16",
|
||||||
"spectre.css": "^0.5.9",
|
"spectre.css": "^0.5.9",
|
||||||
"sql-formatter": "^4.0.2",
|
"sql-formatter": "^4.0.2",
|
||||||
|
@ -1090,7 +1090,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
${addition.zerofill ? 'ZEROFILL' : ''}
|
${addition.zerofill ? 'ZEROFILL' : ''}
|
||||||
${addition.nullable ? 'NULL' : 'NOT NULL'}
|
${addition.nullable ? 'NULL' : 'NOT NULL'}
|
||||||
${addition.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
${addition.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
||||||
${addition.default ? `DEFAULT ${addition.default}` : ''}
|
${addition.default ? `DEFAULT ${typeof addition.default === 'string' ? `'${addition.default}'` : addition.default}` : ''}
|
||||||
${addition.comment ? `COMMENT '${addition.comment}'` : ''}
|
${addition.comment ? `COMMENT '${addition.comment}'` : ''}
|
||||||
${addition.collation ? `COLLATE ${addition.collation}` : ''}
|
${addition.collation ? `COLLATE ${addition.collation}` : ''}
|
||||||
${addition.onUpdate ? `ON UPDATE ${addition.onUpdate}` : ''}
|
${addition.onUpdate ? `ON UPDATE ${addition.onUpdate}` : ''}
|
||||||
@ -1128,7 +1128,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
${change.zerofill ? 'ZEROFILL' : ''}
|
${change.zerofill ? 'ZEROFILL' : ''}
|
||||||
${change.nullable ? 'NULL' : 'NOT NULL'}
|
${change.nullable ? 'NULL' : 'NOT NULL'}
|
||||||
${change.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
${change.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
||||||
${change.default ? `DEFAULT ${change.default}` : ''}
|
${change.default ? `DEFAULT ${typeof change.default === 'string' ? `'${change.default}'` : change.default}` : ''}
|
||||||
${change.comment ? `COMMENT '${change.comment}'` : ''}
|
${change.comment ? `COMMENT '${change.comment}'` : ''}
|
||||||
${change.collation ? `COLLATE ${change.collation}` : ''}
|
${change.collation ? `COLLATE ${change.collation}` : ''}
|
||||||
${change.onUpdate ? `ON UPDATE ${change.onUpdate}` : ''}
|
${change.onUpdate ? `ON UPDATE ${change.onUpdate}` : ''}
|
||||||
|
@ -1047,7 +1047,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
${addition.zerofill ? 'ZEROFILL' : ''}
|
${addition.zerofill ? 'ZEROFILL' : ''}
|
||||||
${addition.nullable ? 'NULL' : 'NOT NULL'}
|
${addition.nullable ? 'NULL' : 'NOT NULL'}
|
||||||
${addition.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
${addition.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
||||||
${addition.default ? `DEFAULT ${addition.default}` : ''}
|
${addition.default ? `DEFAULT ${typeof addition.default === 'string' ? `'${addition.default}'` : addition.default}` : ''}
|
||||||
${addition.comment ? `COMMENT '${addition.comment}'` : ''}
|
${addition.comment ? `COMMENT '${addition.comment}'` : ''}
|
||||||
${addition.collation ? `COLLATE ${addition.collation}` : ''}
|
${addition.collation ? `COLLATE ${addition.collation}` : ''}
|
||||||
${addition.onUpdate ? `ON UPDATE ${addition.onUpdate}` : ''}`);
|
${addition.onUpdate ? `ON UPDATE ${addition.onUpdate}` : ''}`);
|
||||||
@ -1093,7 +1093,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
|
|
||||||
alterColumns.push(`ALTER COLUMN "${change.name}" TYPE ${localType}${length ? `(${length})` : ''}${change.isArray ? '[]' : ''} USING "${change.name}"::${localType}`);
|
alterColumns.push(`ALTER COLUMN "${change.name}" TYPE ${localType}${length ? `(${length})` : ''}${change.isArray ? '[]' : ''} USING "${change.name}"::${localType}`);
|
||||||
alterColumns.push(`ALTER COLUMN "${change.name}" ${change.nullable ? 'DROP NOT NULL' : 'SET NOT NULL'}`);
|
alterColumns.push(`ALTER COLUMN "${change.name}" ${change.nullable ? 'DROP NOT NULL' : 'SET NOT NULL'}`);
|
||||||
alterColumns.push(`ALTER COLUMN "${change.name}" ${change.default ? `SET DEFAULT ${change.default}` : 'DROP DEFAULT'}`);
|
alterColumns.push(`ALTER COLUMN "${change.name}" ${change.default ? `SET DEFAULT ${typeof change.default === 'string' ? `'${change.default}'` : change.default}` : 'DROP DEFAULT'}`);
|
||||||
if (['SERIAL', 'SMALLSERIAL', 'BIGSERIAL'].includes(change.type)) {
|
if (['SERIAL', 'SMALLSERIAL', 'BIGSERIAL'].includes(change.type)) {
|
||||||
const sequenceName = `${table}_${change.name}_seq`.replace(' ', '_');
|
const sequenceName = `${table}_${change.name}_seq`.replace(' ', '_');
|
||||||
createSequences.push(`CREATE SEQUENCE IF NOT EXISTS ${sequenceName} OWNED BY "${table}"."${change.name}"`);
|
createSequences.push(`CREATE SEQUENCE IF NOT EXISTS ${sequenceName} OWNED BY "${table}"."${change.name}"`);
|
||||||
|
@ -453,7 +453,7 @@ export default {
|
|||||||
this.defaultValue.type = 'null';
|
this.defaultValue.type = 'null';
|
||||||
else if (this.localRow.default.match(/^'.*'$/g)) {
|
else if (this.localRow.default.match(/^'.*'$/g)) {
|
||||||
this.defaultValue.type = 'custom';
|
this.defaultValue.type = 'custom';
|
||||||
this.defaultValue.custom = this.localRow.default.replace(/(^')|('$)/g, '');
|
this.defaultValue.custom = this.localRow.default.replaceAll(/(^')|('$)/g, '');
|
||||||
}
|
}
|
||||||
else if (!isNaN(this.localRow.default.replace(/[:.-\s]/g, ''))) {
|
else if (!isNaN(this.localRow.default.replace(/[:.-\s]/g, ''))) {
|
||||||
this.defaultValue.type = 'custom';
|
this.defaultValue.type = 'custom';
|
||||||
@ -537,7 +537,7 @@ export default {
|
|||||||
break;
|
break;
|
||||||
case 'custom':
|
case 'custom':
|
||||||
this.localRow.autoIncrement = false;
|
this.localRow.autoIncrement = false;
|
||||||
this.localRow.default = `'${this.defaultValue.custom}'`;
|
this.localRow.default = this.defaultValue.custom;
|
||||||
break;
|
break;
|
||||||
case 'expression':
|
case 'expression':
|
||||||
this.localRow.autoIncrement = false;
|
this.localRow.autoIncrement = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user