mythix-orm-sql-base 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -39,6 +39,32 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
39
39
|
return literal;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
getLockMode(options) {
|
|
43
|
+
if (!options)
|
|
44
|
+
return { lock: false, read: false, write: false };
|
|
45
|
+
|
|
46
|
+
const throwError = () => {
|
|
47
|
+
throw new Error(`${this.constructor.name}::getLockMode: "lock" must be the name of a model (lock: "ModelName"), or an object specifying the model and the lock mode (lock: { modelName: "ModelName", read: true, write: true, dependents: true, noWait: false }).`);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (Nife.instanceOf(options, 'string')) {
|
|
51
|
+
let Model = this.getModel(options);
|
|
52
|
+
if (!Model)
|
|
53
|
+
throwError();
|
|
54
|
+
|
|
55
|
+
return { lock: true, modelName: options, read: true, write: true };
|
|
56
|
+
} else if (Nife.instanceOf(options, 'object')) {
|
|
57
|
+
let modelName = options.modelName;
|
|
58
|
+
let Model = this.getModel(modelName);
|
|
59
|
+
if (!Model)
|
|
60
|
+
throwError();
|
|
61
|
+
|
|
62
|
+
return Object.assign({ lock: true, read: true, write: true }, options);
|
|
63
|
+
} else {
|
|
64
|
+
throwError();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
42
68
|
prepareArrayValuesForSQL(_array) {
|
|
43
69
|
let array = Nife.arrayFlatten(_array);
|
|
44
70
|
|
|
@@ -449,7 +475,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
449
475
|
|
|
450
476
|
// eslint-disable-next-line no-unused-vars
|
|
451
477
|
async upsert(Model, models, _options) {
|
|
452
|
-
throw new Error(`${this.constructor.name}::upsert: This
|
|
478
|
+
throw new Error(`${this.constructor.name}::upsert: This operation is not supported for this connection type.`);
|
|
453
479
|
}
|
|
454
480
|
|
|
455
481
|
async update(Model, models, _options) {
|
|
@@ -830,6 +856,50 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
830
856
|
async enableForeignKeyConstraints(enable) {
|
|
831
857
|
throw new Error(`${this.constructor.name}::enableForeignKeyConstraints: This operation is not supported for this connection type.`);
|
|
832
858
|
}
|
|
859
|
+
|
|
860
|
+
// Define operations
|
|
861
|
+
|
|
862
|
+
async defineTable() {
|
|
863
|
+
throw new Error(`${this.constructor.name}::defineTable: This operation is not supported for this connection type.`);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
async defineConstraints() {
|
|
867
|
+
throw new Error(`${this.constructor.name}::defineConstraints: This operation is not supported for this connection type.`);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
async defineIndexes() {
|
|
871
|
+
throw new Error(`${this.constructor.name}::defineIndexes: This operation is not supported for this connection type.`);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// Alter operations
|
|
875
|
+
|
|
876
|
+
async renameTable() {
|
|
877
|
+
throw new Error(`${this.constructor.name}::renameTable: This operation is not supported for this connection type.`);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
async renameColumn() {
|
|
881
|
+
throw new Error(`${this.constructor.name}::renameColumn: This operation is not supported for this connection type.`);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
async dropColumn() {
|
|
885
|
+
throw new Error(`${this.constructor.name}::dropColumn: This operation is not supported for this connection type.`);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
async alterColumn() {
|
|
889
|
+
throw new Error(`${this.constructor.name}::alterColumn: This operation is not supported for this connection type.`);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
async addColumn() {
|
|
893
|
+
throw new Error(`${this.constructor.name}::addColumn: This operation is not supported for this connection type.`);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
async addConstraint() {
|
|
897
|
+
throw new Error(`${this.constructor.name}::addConstraint: This operation is not supported for this connection type.`);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
async addIndex() {
|
|
901
|
+
throw new Error(`${this.constructor.name}::addIndex: This operation is not supported for this connection type.`);
|
|
902
|
+
}
|
|
833
903
|
}
|
|
834
904
|
|
|
835
905
|
module.exports = SQLConnectionBase;
|
|
@@ -1112,6 +1112,10 @@ class SQLQueryGeneratorBase extends QueryGeneratorBase {
|
|
|
1112
1112
|
|
|
1113
1113
|
return `RETURNING ${returnFields.join(',')}`;
|
|
1114
1114
|
}
|
|
1115
|
+
|
|
1116
|
+
toConnectionString(queryEngine, options) {
|
|
1117
|
+
return this.generateSelectStatement(queryEngine, options);
|
|
1118
|
+
}
|
|
1115
1119
|
}
|
|
1116
1120
|
|
|
1117
1121
|
module.exports = SQLQueryGeneratorBase;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mythix-orm-sql-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "SQL base support for Mythix ORM",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/th317erd/mythix-orm-sql-base#readme",
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"mythix-orm": "^1.3
|
|
36
|
+
"mythix-orm": "^1.4.3"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"nife": "^1.11.3",
|