fixes #7

Merged
jusax23 merged 2 commits from dev into main 2023-02-19 20:25:17 +01:00
2 changed files with 11 additions and 7 deletions

View file

@ -14,7 +14,7 @@ export class DB {
type: dbType;
mariaPool!: mariadb.Pool;
//pgPool!: pg.Pool;
constructor({ host, user, password, database, connectionLimit = 5, databaseType = dbType.mariadb }: { host: string, user: string, password: string, database: string, connectionLimit: number, databaseType: dbType }) {
constructor({ host, user, password, database, connectionLimit = 5, databaseType = dbType.mariadb }: { host: string, user: string, password: string, database: string, connectionLimit?: number, databaseType?: dbType }) {
this.type = databaseType;
if (databaseType == dbType.mariadb) {
this.mariaPool = mariadb.createPool({ host, user, password, database, connectionLimit, multipleStatements: true });

View file

@ -181,7 +181,7 @@ export class Handler {
const attrData = tableD[keys[j]];
if (attrData == null) {
create.appendEnding(handler.querys.addColumn(handler, a));
changePrimary = true;
if (a.ops.primaryKey) changePrimary = true;
} else if (
!handler.builders.compareDatatypes(handler, a.type, attrData.Type) ||
a.ops.default != attrData.Default ||
@ -193,14 +193,18 @@ export class Handler {
(!!a.ops.notNull || !!a.ops.autoIncrement || !!a.ops.primaryKey), (attrData.Null == "NO"), "|",
(!!a.ops.autoIncrement), (attrData.Extra == "auto_increment"));*/
freeForUpdate(a.name, a.table.dbLangTableName);
if (a.ops.autoIncrement)
if (a.ops.autoIncrement) {
a.ops.autoIncrement = false;
create.appendEnding(handler.querys.changeColumn(handler, a));
a.ops.autoIncrement = true;
connst.appendEnding(handler.querys.changeColumn(handler, a));
}
if (attrData == null) {
changePrimary = true;
} else {
else create.appendEnding(handler.querys.changeColumn(handler, a));
}
if (attrData != null) {
if ((attrData.Key == "PRI") != (!!a.ops.primaryKey)) {
freeForUpdate(a.name, a.table.dbLangTableName);
console.log("206");
changePrimary = true;
}
}