spice-js 2.6.14 → 2.6.15

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.
@@ -833,12 +833,37 @@ class SpiceModel {
833
833
 
834
834
  return _asyncToGenerator(function* () {
835
835
  try {
836
- var _args4;
836
+ var _args4, _args5, _args6;
837
837
 
838
838
  if (!args) {
839
839
  args = {};
840
840
  }
841
841
 
842
+ function prepColumns(columns) {
843
+ if (columns && columns != "") {
844
+ var columnList = columns.split(","); // Convert comma-separated string to array
845
+
846
+ return _.join(_.compact(_.map(columnList, column => {
847
+ if (column == "meta().id") {
848
+ column = undefined;
849
+ } else if (!column.startsWith("`") && !column.endsWith("`")) {
850
+ if (!column.includes(".") && !column.startsWith(that.type)) {
851
+ column = "`" + that.type + "`.`" + column + "`";
852
+ }
853
+
854
+ return column;
855
+ }
856
+
857
+ return column;
858
+ })), ",");
859
+ }
860
+
861
+ return columns;
862
+ }
863
+
864
+ var query = "";
865
+ args.columns = prepColumns(args.columns);
866
+
842
867
  function filterResultsByColumns(data, columns) {
843
868
  if (columns && columns != "") {
844
869
  columns = columns.replace(/`/g, "");
@@ -867,7 +892,7 @@ class SpiceModel {
867
892
  return returnVal;
868
893
  }
869
894
 
870
- var nestings = extractNestings((_args4 = args) == null ? void 0 : _args4.query, _this11.type);
895
+ 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)];
871
896
 
872
897
  var mappedNestings = _.compact(_.map(nestings, nesting => {
873
898
  var prop = _this11.props[nesting];
@@ -900,27 +925,6 @@ class SpiceModel {
900
925
 
901
926
  args._join = _join;
902
927
 
903
- function prepColumns(columns) {
904
- if (columns && columns != "") {
905
- var columnList = columns.split(","); // Convert comma-separated string to array
906
-
907
- return _.join(_.compact(_.map(columnList, column => {
908
- if (column == "meta().id") {
909
- column = undefined;
910
- } else if (!column.startsWith("`") && !column.endsWith("`")) {
911
- return "`" + column + "`";
912
- }
913
-
914
- return column;
915
- })), ",");
916
- }
917
-
918
- return columns;
919
- }
920
-
921
- var query = "";
922
- args.columns = prepColumns(args.columns);
923
-
924
928
  if (args.is_full_text && args.is_full_text === "true" || args.is_custom_query && args.is_custom_query === "true") {
925
929
  query = args.query;
926
930
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.6.14",
3
+ "version": "2.6.15",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -743,6 +743,31 @@ export default class SpiceModel {
743
743
  args = {};
744
744
  }
745
745
 
746
+ function prepColumns(columns) {
747
+ if (columns && columns != "") {
748
+ let columnList = columns.split(","); // Convert comma-separated string to array
749
+ return _.join(
750
+ _.compact(
751
+ _.map(columnList, (column) => {
752
+ if (column == "meta().id") {
753
+ column = undefined;
754
+ } else if (!column.startsWith("`") && !column.endsWith("`")) {
755
+ if (!column.includes(".") && !column.startsWith(that.type)) {
756
+ column = `\`${that.type}\`.\`${column}\``;
757
+ }
758
+ return column;
759
+ }
760
+ return column;
761
+ })
762
+ ),
763
+ ","
764
+ );
765
+ }
766
+ return columns;
767
+ }
768
+
769
+ let query = "";
770
+ args.columns = prepColumns(args.columns);
746
771
  function filterResultsByColumns(data, columns) {
747
772
  if (columns && columns != "") {
748
773
  columns = columns.replace(/`/g, "");
@@ -764,7 +789,11 @@ export default class SpiceModel {
764
789
  return returnVal;
765
790
  }
766
791
 
767
- let nestings = extractNestings(args?.query, this.type);
792
+ let nestings = [
793
+ ...extractNestings(args?.query, this.type),
794
+ ...extractNestings(args?.columns, this.type),
795
+ ...extractNestings(args?.sort, this.type),
796
+ ];
768
797
  let mappedNestings = _.compact(
769
798
  _.map(nestings, (nesting) => {
770
799
  let prop = this.props[nesting];
@@ -793,28 +822,6 @@ export default class SpiceModel {
793
822
  let _join = createJoinSection(mappedNestings);
794
823
  args._join = _join;
795
824
 
796
- function prepColumns(columns) {
797
- if (columns && columns != "") {
798
- let columnList = columns.split(","); // Convert comma-separated string to array
799
- return _.join(
800
- _.compact(
801
- _.map(columnList, (column) => {
802
- if (column == "meta().id") {
803
- column = undefined;
804
- } else if (!column.startsWith("`") && !column.endsWith("`")) {
805
- return `\`${column}\``;
806
- }
807
- return column;
808
- })
809
- ),
810
- ","
811
- );
812
- }
813
- return columns;
814
- }
815
-
816
- let query = "";
817
- args.columns = prepColumns(args.columns);
818
825
  if (
819
826
  (args.is_full_text && args.is_full_text === "true") ||
820
827
  (args.is_custom_query && args.is_custom_query === "true")