mythix-orm 1.11.1 → 1.11.3

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.
@@ -93,6 +93,7 @@ class LiteralBase {
93
93
  let Model = connection.getModel(definition.modelName);
94
94
  if (Model) {
95
95
  return new Field({
96
+ ephemeral: true,
96
97
  fieldName: definition.fieldNames[0],
97
98
  Model,
98
99
  });
@@ -52,7 +52,7 @@ function applyOrderClause(extraData, ...args) {
52
52
  function wrapOrderClause(func) {
53
53
  const applyQueryOrder = (_order, replace) => {
54
54
  let query = this;
55
- let order = Nife.toArray(_order).filter(Boolean);
55
+ let order = Nife.arrayFlatten(Nife.toArray(_order).filter(Boolean));
56
56
 
57
57
  let asc = order.filter((thisOrder) => {
58
58
  if (!Nife.instanceOf(thisOrder, 'string'))
@@ -303,7 +303,7 @@ class ModelScope extends QueryEngineBase {
303
303
 
304
304
  if (!Nife.instanceOf(value, 'string')) {
305
305
  console.log(entities);
306
- throw new Error(`QueryEngine::ModelScope::PROJECT: Invalid value provided [${value.toString()}]. All values provided must be strings.`);
306
+ throw new TypeError(`QueryEngine::ModelScope::PROJECT: Invalid value provided [${value.toString()}]. All values provided must be strings, fields, models, or literals.`);
307
307
  }
308
308
 
309
309
  return value;
@@ -328,10 +328,11 @@ class ModelScope extends QueryEngineBase {
328
328
  return this._fetchScope('model');
329
329
  }
330
330
 
331
- DISTINCT = ProxyClass.autoCall(function(fullyQualifiedName) {
332
- let currentQuery = this;
333
- let distinctValue = fullyQualifiedName;
334
- let context = this.getOperationContext();
331
+ DISTINCT = ProxyClass.autoCall(function(_fullyQualifiedName) {
332
+ let fullyQualifiedName = _fullyQualifiedName;
333
+ let currentQuery = this;
334
+ let distinctValue = fullyQualifiedName;
335
+ let context = this.getOperationContext();
335
336
 
336
337
  if (arguments.length === 0) {
337
338
  let rootModel = context.rootModel;
@@ -343,8 +344,17 @@ class ModelScope extends QueryEngineBase {
343
344
 
344
345
  if (!distinctValue)
345
346
  distinctValue = new DistinctLiteral();
346
- } else if (fullyQualifiedName) {
347
+ } else if (Nife.instanceOf(fullyQualifiedName, 'string')) {
348
+ if (fullyQualifiedName.indexOf(':') < 0)
349
+ fullyQualifiedName = `${context.rootModel.getModelName()}:${fullyQualifiedName}`;
350
+
351
+ distinctValue = new DistinctLiteral(fullyQualifiedName);
352
+ } else if (typeof fullyQualifiedName.isField === 'function' && fullyQualifiedName.isField(fullyQualifiedName)) {
353
+ distinctValue = new DistinctLiteral(`${fullyQualifiedName.Model.getModelName()}:${fullyQualifiedName.fieldName}`);
354
+ } else if (LiteralBase.isLiteral(fullyQualifiedName)) {
347
355
  distinctValue = new DistinctLiteral(fullyQualifiedName);
356
+ } else {
357
+ throw new TypeError(`QueryEngine::ModelScope::DISTINCT: Invalid value provided [${(fullyQualifiedName) ? fullyQualifiedName.toString() : fullyQualifiedName}]. All values provided must be strings, fields, or literals.`);
348
358
  }
349
359
 
350
360
  currentQuery._pushOperationOntoStack({ sqlFunc: true, operator: 'DISTINCT', queryProp: 'DISTINCT', value: distinctValue, distinct: distinctValue });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix-orm",
3
- "version": "1.11.1",
3
+ "version": "1.11.3",
4
4
  "description": "ORM for Mythix framework",
5
5
  "main": "lib/index",
6
6
  "type": "commonjs",
@@ -34,18 +34,18 @@
34
34
  "homepage": "https://github.com/th317erd/mythix-orm#readme",
35
35
  "devDependencies": {
36
36
  "@spothero/eslint-plugin-spothero": "github:spothero/eslint-plugin-spothero",
37
- "@types/node": "^18.7.17",
38
- "better-sqlite3": "^7.6.2",
37
+ "@types/node": "^18.11.9",
38
+ "better-sqlite3": "^8.0.0",
39
39
  "colors": "^1.4.0",
40
40
  "diff": "^5.1.0",
41
- "eslint": "^8.23.1",
42
- "jasmine": "^4.4.0",
41
+ "eslint": "^8.28.0",
42
+ "jasmine": "^4.5.0",
43
43
  "nyc": "^15.1.0"
44
44
  },
45
45
  "dependencies": {
46
46
  "events": "^3.3.0",
47
- "inflection": "^1.13.2",
48
- "luxon": "^3.0.4",
47
+ "inflection": "^2.0.0",
48
+ "luxon": "^3.1.0",
49
49
  "nife": "^1.12.1",
50
50
  "sqlstring": "^2.3.3",
51
51
  "uuid": "^9.0.0",