commit
f290b61f44
3 changed files with 13 additions and 10 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "dblang",
|
"name": "dblang",
|
||||||
"version": "0.9.3",
|
"version": "0.9.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "dblang",
|
"name": "dblang",
|
||||||
"version": "0.9.3",
|
"version": "0.9.5",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mariadb": "^3.0.2",
|
"mariadb": "^3.0.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "dblang",
|
"name": "dblang",
|
||||||
"version": "0.9.3",
|
"version": "0.9.5",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/db.js",
|
"main": "dist/db.js",
|
||||||
"types": "dist/db.d.ts",
|
"types": "dist/db.d.ts",
|
||||||
|
|
|
@ -121,7 +121,7 @@ export class Handler {
|
||||||
return found == fromAttrs.length && found == toAttrs.length;
|
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++) {
|
for (let i = 0; i < key.length; i++) {
|
||||||
const k = key[i];
|
const k = key[i];
|
||||||
if (
|
if (
|
||||||
|
@ -130,7 +130,7 @@ export class Handler {
|
||||||
|| (start && (k.TABLE_NAME ?? k.table_name) == table
|
|| (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)));
|
pool.appendEnding(handler.querys.removeForeignKey(handler, (k.TABLE_NAME ?? k.table_name), (k.CONSTRAINT_NAME ?? k.constraint_name)));
|
||||||
key.splice(i--, 1);
|
key.splice(i--, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,13 @@ export class Handler {
|
||||||
const a = table.dbLangTableAttributes[keys[j]];
|
const a = table.dbLangTableAttributes[keys[j]];
|
||||||
const attrData = tableD[keys[j]];
|
const attrData = tableD[keys[j]];
|
||||||
if (attrData == null) {
|
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;
|
if (a.ops.primaryKey) changePrimary = true;
|
||||||
} else if (
|
} else if (
|
||||||
!handler.builders.compareDatatypes(handler, a.type, attrData.Type) ||
|
!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.notNull || !!a.ops.autoIncrement || !!a.ops.primaryKey) != (attrData.Null == "NO") ||
|
||||||
(!!a.ops.autoIncrement) != (attrData.Extra == "auto_increment")
|
(!!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);
|
freeForUpdate(a.name, a.table.dbLangTableName);
|
||||||
if (a.ops.autoIncrement) {
|
if (a.ops.autoIncrement) {
|
||||||
a.ops.autoIncrement = false;
|
a.ops.autoIncrement = false;
|
||||||
|
@ -231,6 +233,7 @@ export class Handler {
|
||||||
a.ops.autoIncrement = true;
|
a.ops.autoIncrement = true;
|
||||||
connst.appendEnding(handler.querys.changeColumn(handler, a));
|
connst.appendEnding(handler.querys.changeColumn(handler, a));
|
||||||
}
|
}
|
||||||
|
freeForUpdate(a.name, a.table.dbLangTableName, true, create);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changePrimary) {
|
if (changePrimary) {
|
||||||
|
|
Loading…
Reference in a new issue