Skip to content

Commit f663e1a

Browse files
committed
[query][s]: Fix string and num query issue
1 parent c911eb9 commit f663e1a

File tree

1 file changed

+5
-14
lines changed
  • ckanext/dataexplorer/public/vendor/recline

1 file changed

+5
-14
lines changed

ckanext/dataexplorer/public/vendor/recline/recline.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4948,7 +4948,6 @@ this.recline.View = this.recline.View || {};
49484948
query += ` FROM \`${query_obj["resource_id"]}\` `;
49494949

49504950
if ("filters" || "q" in query_obj) {
4951-
// console.log("query_obj", query_obj["fields"]);
49524951
let where_str = this.where_clauses(query_obj["fields"], query_obj);
49534952
query += ` ${where_str} `;
49544953
}
@@ -4972,10 +4971,9 @@ this.recline.View = this.recline.View || {};
49724971
let where_filters = "";
49734972

49744973
for (const [key, value] of Object.entries(filters)) {
4975-
console.log(Object.entries(filters));
49764974
let single_where_statament = "";
49774975
value.forEach((value_item) => {
4978-
if (this.get_field_type(fields, key) == "num") {
4976+
if (this.get_field_type(value_item) == "num") {
49794977
single_where_statament += `${key} = ${value_item} OR `;
49804978
} else {
49814979
single_where_statament += `${key} = "${value_item}" OR `;
@@ -4990,8 +4988,7 @@ this.recline.View = this.recline.View || {};
49904988
if (q != "") {
49914989
let where_q = " WHERE ";
49924990
for (const [key, value] of Object.entries(filters)) {
4993-
console.log(Object.entries(filters));
4994-
if (this.get_field_type(fields, key) == "string") {
4991+
if (this.get_field_type(value) == "string") {
49954992
where_q_str += ` LOWER(${key}) like LOWER("${value.slice(
49964993
0,
49974994
-2
@@ -5008,20 +5005,14 @@ this.recline.View = this.recline.View || {};
50085005
}
50095006
return where_str;
50105007
},
5011-
get_field_type: function (fields, key) {
5012-
let string_types = ["STRING"];
5013-
let field_type = [];
5014-
fields.forEach((lfield) => {
5015-
if (lfield["id"] === key) {
5016-
field_type = lfield["type"];
5017-
}
5018-
});
5008+
get_field_type: function (value) {
50195009

5020-
if (field_type[0] in string_types) {
5010+
if (isNaN(Number(value))) {
50215011
return "string";
50225012
} else {
50235013
return "num";
50245014
}
5015+
50255016
},
50265017
});
50275018
})(jQuery, recline.View);

0 commit comments

Comments
 (0)