spice-js 2.6.16 → 2.6.17

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.
@@ -847,11 +847,13 @@ class SpiceModel {
847
847
  if (column == "meta().id") {
848
848
  column = undefined;
849
849
  } else if (!column.startsWith("`") && !column.endsWith("`")) {
850
+ "`" + column + "`";
851
+ }
852
+
853
+ if (column) {
850
854
  if (!column.includes(".") && !column.startsWith(that.type)) {
851
- column = "`" + that.type + "`.`" + column + "`";
855
+ column = "`" + that.type + "`." + column;
852
856
  }
853
-
854
- return column;
855
857
  }
856
858
 
857
859
  return column;
@@ -868,7 +870,10 @@ class SpiceModel {
868
870
  if (columns && columns != "") {
869
871
  columns = columns.replace(/`/g, "");
870
872
  columns = columns.replace(/meta\(\)\.id/g, "id");
871
- var columnList = columns.split(","); // Convert comma-separated string to array
873
+ var columnList = columns.split(",").map(column => {
874
+ //if colums has a . then remove the first part of the string
875
+ return column.includes(".") ? _.last(column.split(".")) : column;
876
+ }); // Convert comma-separated string to array
872
877
 
873
878
  columnList.push("_permissions"); // Always include _permissions
874
879
 
@@ -894,7 +899,7 @@ class SpiceModel {
894
899
 
895
900
  var nestings = [...extractNestings((_args4 = args) == null ? void 0 : _args4.query, _this11.type), ...extractNestings((_args5 = args) == null ? void 0 : _args5.columns, _this11.type), ...extractNestings((_args6 = args) == null ? void 0 : _args6.sort, _this11.type)];
896
901
 
897
- var mappedNestings = _.compact(_.map(nestings, nesting => {
902
+ var mappedNestings = _.compact(_.map(_.uniq(nestings), nesting => {
898
903
  var prop = _this11.props[nesting];
899
904
 
900
905
  if (prop) {
@@ -953,6 +958,20 @@ class SpiceModel {
953
958
 
954
959
  if (!args.sort) {
955
960
  args.sort = "`" + _this11.type + "`.created_at DESC";
961
+ } else {
962
+ var sort_array = args.sort.split(","); // check the first string in each item in the array to see if it contains a . if not then add the type
963
+
964
+ var new_sort_array = [];
965
+
966
+ for (var i = 0; i < sort_array.length; i++) {
967
+ if (!sort_array[i].includes(".")) {
968
+ new_sort_array.push("`" + _this11.type + "`.`" + sort_array[i] + "`");
969
+ } else {
970
+ new_sort_array.push(sort_array[i]);
971
+ }
972
+ }
973
+
974
+ args.sort = _.join(new_sort_array, ",");
956
975
  }
957
976
 
958
977
  if (args.skip_hooks != true) {
@@ -1019,10 +1038,6 @@ class SpiceModel {
1019
1038
  }
1020
1039
  } else {
1021
1040
  results = yield _this11.database.search(_this11.type, args.columns || "", query || "", args.limit, args.offset, args.sort, args.do_count, args.statement_consistent, args._join);
1022
-
1023
- if (_this11.type == "user") {
1024
- console.log("results from DB No Chache available", results);
1025
- }
1026
1041
  }
1027
1042
  }
1028
1043
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.6.16",
3
+ "version": "2.6.17",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {