From 0a1cb7c85f95aaff489b24a40ee4cadb0eed3b5e Mon Sep 17 00:00:00 2001 From: jusax23 Date: Tue, 28 Mar 2023 18:28:52 +0200 Subject: [PATCH 1/2] bug fix --- src/defaultHandler.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/defaultHandler.ts b/src/defaultHandler.ts index 6eb9455..f8ec5ff 100644 --- a/src/defaultHandler.ts +++ b/src/defaultHandler.ts @@ -121,7 +121,7 @@ export class Handler { return found == fromAttrs.length && found == toAttrs.length; } - function freeForUpdate(attr: string, table: string, start = false) { + function freeForUpdate(attr: string, table: string, start = false, pool = del) { for (let i = 0; i < key.length; i++) { const k = key[i]; if ( @@ -130,7 +130,7 @@ export class Handler { || (start && (k.TABLE_NAME ?? k.table_name) == table && (k.COLUMN_NAME ?? k.column_name).toLowerCase() == attr.toLowerCase() && (k.REFERENCED_COLUMN_NAME ?? k.referenced_column_name) != null) ) { - del.appendEnding(handler.querys.removeForeignKey(handler, (k.TABLE_NAME ?? k.table_name), (k.CONSTRAINT_NAME ?? k.constraint_name))); + pool.appendEnding(handler.querys.removeForeignKey(handler, (k.TABLE_NAME ?? k.table_name), (k.CONSTRAINT_NAME ?? k.constraint_name))); key.splice(i--, 1); } } @@ -195,7 +195,13 @@ export class Handler { const a = table.dbLangTableAttributes[keys[j]]; const attrData = tableD[keys[j]]; if (attrData == null) { - create.appendEnding(handler.querys.addColumn(handler, a)); + if (a.ops.autoIncrement) { + a.ops.autoIncrement = false; + create.appendEnding(handler.querys.addColumn(handler, a)); + a.ops.autoIncrement = true; + connst.appendEnding(handler.querys.addColumn(handler, a)); + } + else create.appendEnding(handler.querys.addColumn(handler, a)); if (a.ops.primaryKey) changePrimary = true; } else if ( !handler.builders.compareDatatypes(handler, a.type, attrData.Type) || @@ -203,10 +209,6 @@ export class Handler { (!!a.ops.notNull || !!a.ops.autoIncrement || !!a.ops.primaryKey) != (attrData.Null == "NO") || (!!a.ops.autoIncrement) != (attrData.Extra == "auto_increment") ) { - /*console.log(!handler.builders.compareDatatypes(handler, a.type, attrData.Type), "|", - a.ops.default, attrData.Default, "|", - (!!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) { a.ops.autoIncrement = false; @@ -231,6 +233,7 @@ export class Handler { a.ops.autoIncrement = true; connst.appendEnding(handler.querys.changeColumn(handler, a)); } + freeForUpdate(a.name, a.table.dbLangTableName, true, create); } } if (changePrimary) { @@ -257,7 +260,7 @@ export class Handler { } if (!create.isEmpty()) del.append(create); if (!connst.isEmpty()) del.append(connst); - if (!del.isEmpty()) await db.query(handler.builders.query(del)); + if (!del.isEmpty()) await db.query(handler.builders.query(del), true); } querys = { From c2dc88062f9161db67b0ce0cf389f4286b6150da Mon Sep 17 00:00:00 2001 From: jusax23 Date: Tue, 28 Mar 2023 18:30:57 +0200 Subject: [PATCH 2/2] version, log remove --- package-lock.json | 4 ++-- package.json | 2 +- src/defaultHandler.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index dd13aae..4933727 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dblang", - "version": "0.9.3", + "version": "0.9.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dblang", - "version": "0.9.3", + "version": "0.9.5", "license": "UNLICENSED", "dependencies": { "mariadb": "^3.0.2", diff --git a/package.json b/package.json index ad3d83e..85e65b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dblang", - "version": "0.9.3", + "version": "0.9.5", "description": "", "main": "dist/db.js", "types": "dist/db.d.ts", diff --git a/src/defaultHandler.ts b/src/defaultHandler.ts index f8ec5ff..db30121 100644 --- a/src/defaultHandler.ts +++ b/src/defaultHandler.ts @@ -260,7 +260,7 @@ export class Handler { } if (!create.isEmpty()) del.append(create); if (!connst.isEmpty()) del.append(connst); - if (!del.isEmpty()) await db.query(handler.builders.query(del), true); + if (!del.isEmpty()) await db.query(handler.builders.query(del)); } querys = {