Compare commits

..

No commits in common. "57544dffd2541c58269490339ec21ae4f597f884" and "d647fba5a9e995054543ca3deeadb4c5ff0b81ae" have entirely different histories.

5 changed files with 8 additions and 22 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "dblang",
"version": "0.9.2",
"version": "0.9.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dblang",
"version": "0.9.2",
"version": "0.9.0",
"license": "UNLICENSED",
"dependencies": {
"mariadb": "^3.0.2",

View file

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

View file

@ -132,12 +132,10 @@ export class uniqueConstraint implements Constraint {
this.attrs = attrs;
}
check(table: Table): boolean | string {
let prim = true;
for (let i = 0; i < this.attrs.length; i++) {
if (!this.attrs[i].ops.primaryKey) prim = false;
if (this.attrs[i].ops.primaryKey) return "Can not combine unique Constraint and primary key";
if (this.attrs[i].table != table) return "Referencing Attributes must be in host Table.";
}
if (prim) return "Can not combine unique Constraint and primary key";
return false;
}
uses(attr: Attribute): boolean {

View file

@ -604,13 +604,6 @@ export class Handler {
},
}
catcherrors = {
insert: (err: any) => {
if(err?.code == "ER_DUP_ENTRY") return {affectedRows: 0, insertId: -1};
throw err;
}
}
responses = {
readResponse: (resp: any) => new readResponse(resp),
writeResponse: (resp: any) => new writeResponse(resp.affectedRows),

View file

@ -138,13 +138,8 @@ export class insertQuery {
const handler = db.getHandler();
const builder = this.serialize(handler);
const s = handler.builders.query(builder);
let readResp: any;
try {
readResp = await db.query(s, printQuery);
} catch (err) {
readResp = handler.catcherrors.insert(err);
}
return handler.responses.insertResponse(readResp);
let readResp = await db.query(s, printQuery);
return db.getHandler().responses.insertResponse(readResp);
}
}
@ -173,7 +168,7 @@ export class updateQuery {
const builder = this.serialize(handler);
const s = handler.builders.query(builder);
let readResp = await db.query(s, printQuery);
return handler.responses.writeResponse(readResp);
return db.getHandler().responses.writeResponse(readResp);
}
}
@ -195,6 +190,6 @@ export class removeQuery {
const builder = this.serialize(handler);
const s = handler.builders.query(builder);
let readResp = await db.query(s, printQuery);
return handler.responses.writeResponse(readResp);
return db.getHandler().responses.writeResponse(readResp);
}
}