Compare commits

..

No commits in common. "c532ebcbb766796e6fe07552dc77502cfa4a6524" and "bf8b9e8f06bd3cf3aa426d1c45a3a334d84e2c34" have entirely different histories.

2 changed files with 7 additions and 11 deletions

View file

@ -14,7 +14,7 @@ export class DB {
type: dbType; type: dbType;
mariaPool!: mariadb.Pool; mariaPool!: mariadb.Pool;
//pgPool!: pg.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; this.type = databaseType;
if (databaseType == dbType.mariadb) { if (databaseType == dbType.mariadb) {
this.mariaPool = mariadb.createPool({ host, user, password, database, connectionLimit, multipleStatements: true }); 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]]; const attrData = tableD[keys[j]];
if (attrData == null) { if (attrData == null) {
create.appendEnding(handler.querys.addColumn(handler, a)); create.appendEnding(handler.querys.addColumn(handler, a));
if (a.ops.primaryKey) changePrimary = true; changePrimary = true;
} else if ( } else if (
!handler.builders.compareDatatypes(handler, a.type, attrData.Type) || !handler.builders.compareDatatypes(handler, a.type, attrData.Type) ||
a.ops.default != attrData.Default || a.ops.default != attrData.Default ||
@ -193,18 +193,14 @@ export class Handler {
(!!a.ops.notNull || !!a.ops.autoIncrement || !!a.ops.primaryKey), (attrData.Null == "NO"), "|", (!!a.ops.notNull || !!a.ops.autoIncrement || !!a.ops.primaryKey), (attrData.Null == "NO"), "|",
(!!a.ops.autoIncrement), (attrData.Extra == "auto_increment"));*/ (!!a.ops.autoIncrement), (attrData.Extra == "auto_increment"));*/
freeForUpdate(a.name, a.table.dbLangTableName); 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)); create.appendEnding(handler.querys.changeColumn(handler, a));
a.ops.autoIncrement = true;
connst.appendEnding(handler.querys.changeColumn(handler, a));
}
else create.appendEnding(handler.querys.changeColumn(handler, a));
} }
if (attrData != null) { if (attrData == null) {
changePrimary = true;
} else {
if ((attrData.Key == "PRI") != (!!a.ops.primaryKey)) { if ((attrData.Key == "PRI") != (!!a.ops.primaryKey)) {
freeForUpdate(a.name, a.table.dbLangTableName); freeForUpdate(a.name, a.table.dbLangTableName);
console.log("206");
changePrimary = true; changePrimary = true;
} }
} }
@ -458,7 +454,7 @@ export class Handler {
let primaAttr = Object.entries(table.dbLangTableAttributes) let primaAttr = Object.entries(table.dbLangTableAttributes)
.filter(([n, attr]) => !!attr.ops.primaryKey); .filter(([n, attr]) => !!attr.ops.primaryKey);
const qb = new QueryBuilder(); const qb = new QueryBuilder();
if (primaAttr.length == 0) return qb; if(primaAttr.length == 0) return qb;
qb.addCode("ALTER TABLE "); qb.addCode("ALTER TABLE ");
qb.addCode(table.serialize(handler)); qb.addCode(table.serialize(handler));
qb.addCode(" add PRIMARY KEY if not exists ("); qb.addCode(" add PRIMARY KEY if not exists (");