Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Do not stringify null parameters #151

Merged
merged 1 commit into from Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/javascripts/discourse/components/param-input.js.es6
Expand Up @@ -58,7 +58,7 @@ export default Ember.Component.extend({
return this.params[this.get("info.identifier")];
},
set(key, value) {
this.params[this.get("info.identifier")] = value.toString();
this.params[this.get("info.identifier")] = value?.toString();
return value;
},
}),
Expand Down
6 changes: 4 additions & 2 deletions assets/stylesheets/explorer.scss
Expand Up @@ -238,7 +238,8 @@ table.group-reports {

.query-params {
border: 1px solid var(--header_primary-medium);
.param > input {
.param > input,
.param > .select-kit {
margin: 9px;
}
.invalid > input {
Expand All @@ -257,7 +258,8 @@ table.group-reports {
width: 100px !important; // override an inline style
}
}
input {
input,
.select-kit {
width: 190px;
}
}
Expand Down
26 changes: 26 additions & 0 deletions test/javascripts/acceptance/run-query-test.js.es6
Expand Up @@ -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,
},
],
});
});
Expand Down Expand Up @@ -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"));
});
});