FIX: Do not stringify null parameters (#151)

Sometimes the query page did not load if one of the query was null
because it called null.toString() and raised an exception.
This commit is contained in:
Bianca Nenciu
2022-01-17 13:45:40 +02:00
committed by GitHub
parent 58cfe737f7
commit c6dd79c805
3 changed files with 31 additions and 3 deletions
@@ -117,6 +117,26 @@ acceptance("Data Explorer Plugin | Run Query", function (needs) {
hidden: false,
user_id: -1,
},
{
id: -7,
sql: "-- [params]\n-- user_id :user\n\nSELECT :user_id\n\n",
name: "Invalid Query",
description: "",
param_info: [
{
identifier: "user",
type: "user_id",
default: null,
nullable: false,
},
],
created_at: "2022-01-14T16:40:05.458Z",
username: "bianca",
group_ids: [],
last_run_at: "2022-01-14T16:47:34.244Z",
hidden: false,
user_id: 1,
},
],
});
});
@@ -201,4 +221,10 @@ acceptance("Data Explorer Plugin | Run Query", function (needs) {
let paramsMonthsAgo = JSON.parse(searchParams.get("params")).months_ago;
assert.equal(paramsMonthsAgo, monthsAgoValue);
});
test("it loads the page if one of the parameter is null", async function (assert) {
await visit('admin/plugins/explorer?id=-7&params={"user":null}');
assert.ok(exists(".query-params .user-chooser"));
assert.ok(exists(".query-run .btn.btn-primary"));
});
});