From 56fb927c74e6d7fd1a2c3f21a1bed83f2f38ec2c Mon Sep 17 00:00:00 2001 From: jusax23 Date: Fri, 24 Mar 2023 18:51:09 +0100 Subject: [PATCH 1/2] fix bugged primary key change with auto_increment --- src/defaultHandler.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/defaultHandler.ts b/src/defaultHandler.ts index 77c88f1..fce041a 100644 --- a/src/defaultHandler.ts +++ b/src/defaultHandler.ts @@ -126,9 +126,9 @@ export class Handler { const k = key[i]; if ( ((k.REFERENCED_TABLE_NAME ?? k.referenced_table_name) == table - && (k.REFERENCED_COLUMN_NAME ?? k.referenced_column_name).toLowerCase() == attr.toLowerCase()) + && (k.REFERENCED_COLUMN_NAME ?? k.referenced_column_name).toLowerCase() == attr.toLowerCase()) || (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) + && (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))); key.splice(i--, 1); @@ -223,6 +223,15 @@ export class Handler { } } } + if (changePrimary) for (let j = 0; j < keys.length; j++) { + const a = table.dbLangTableAttributes[keys[j]]; + 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 (changePrimary) { create.appendEnding(handler.querys.removePrimaryKey(handler, table.dbLangTableName)); -- 2.39.5 From 5d97a3211fab6f092c1afe4c4050fa749e7e2ffc Mon Sep 17 00:00:00 2001 From: jusax23 Date: Fri, 24 Mar 2023 18:51:54 +0100 Subject: [PATCH 2/2] version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a4951eb..dd13aae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dblang", - "version": "0.9.2", + "version": "0.9.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dblang", - "version": "0.9.2", + "version": "0.9.3", "license": "UNLICENSED", "dependencies": { "mariadb": "^3.0.2", diff --git a/package.json b/package.json index a3a4aa5..ad3d83e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dblang", - "version": "0.9.2", + "version": "0.9.3", "description": "", "main": "dist/db.js", "types": "dist/db.d.ts", -- 2.39.5