Merge pull request 'bug fix' (#22) from dev into main
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

Reviewed-on: #22
This commit is contained in:
jusax23 2023-03-28 18:31:35 +02:00
commit f290b61f44
3 changed files with 13 additions and 10 deletions

4
package-lock.json generated
View file

@ -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",

View file

@ -1,6 +1,6 @@
{
"name": "dblang",
"version": "0.9.3",
"version": "0.9.5",
"description": "",
"main": "dist/db.js",
"types": "dist/db.d.ts",

View file

@ -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) {
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) {