fixing json default value typescript parsing errors

This commit is contained in:
Dustin 2020-03-13 17:03:42 -05:00
parent 9ecc3dbbb0
commit 3cf7272b5b
5 changed files with 17 additions and 19 deletions

View File

@ -89,7 +89,10 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
entities.forEach(ent => {
response
.filter(filterVal => {
return filterVal.TABLE_NAME === ent.tscName && filterVal.TABLE_SCHEMA === ent.schema;
return (
filterVal.TABLE_NAME === ent.tscName &&
filterVal.TABLE_SCHEMA === ent.schema
);
})
.forEach(resp => {
const tscName = resp.COLUMN_NAME;
@ -298,7 +301,9 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
entities.forEach(ent => {
const entityIndices = response.filter(
filterVal => filterVal.TableName === ent.tscName && filterVal.TableSchema === ent.schema
filterVal =>
filterVal.TableName === ent.tscName &&
filterVal.TableSchema === ent.schema
);
const indexNames = new Set(entityIndices.map(v => v.IndexName));
indexNames.forEach(indexName => {
@ -514,9 +519,7 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
if (defaultValue.startsWith("(") && defaultValue.endsWith(")")) {
defaultValue = defaultValue.slice(1, -1);
}
if (defaultValue.startsWith(`'`)) {
return `() => "${defaultValue}"`;
}
return `() => "${defaultValue}"`;
return `() => \`${defaultValue}\``;
}
}

View File

@ -529,6 +529,7 @@ export default class MysqlDriver extends AbstractDriver {
if (dataType === "set") {
return `() => ['${defaultValue.split(",").join("','")}']`;
}
return `() => "'${defaultValue}'"`;
return `() => \`${defaultValue}\``;
}
}

View File

@ -416,9 +416,7 @@ export default class OracleDriver extends AbstractDriver {
if (defaultVal.endsWith(" ")) {
defaultVal = defaultVal.slice(0, -1);
}
if (defaultVal.startsWith(`'`)) {
return `() => "${defaultVal}"`;
}
return `() => "${defaultVal}"`;
return `() => \`${defaultVal}\``;
}
}

View File

@ -655,9 +655,7 @@ export default class PostgresDriver extends AbstractDriver {
return undefined;
}
defaultValue = defaultValue.replace(/'::[\w ]*/, "'");
if (defaultValue.startsWith(`'`)) {
return `() => "${defaultValue}"`;
}
return `() => "${defaultValue}"`;
return `() => \`${defaultValue}\``;
}
}

View File

@ -436,9 +436,7 @@ export default class SqliteDriver extends AbstractDriver {
if (!defVal) {
return undefined;
}
if (defVal.startsWith(`'`)) {
return `() => "${defVal}"`;
}
return `() => "${defVal}"`;
return `() => \`${defVal}\``;
}
}