Skip to content

Business intelligence made simple

Fixbug: it shows incorrect error line num when we only query selected SQL

Fred Liang30fca7ed177e
diff --git a/app/views/blazer/queries/_form.html.erb b/app/views/blazer/queries/_form.html.erb
index 455e7b98..bf12c163 100644
--- a/app/views/blazer/queries/_form.html.erb
+++ b/app/views/blazer/queries/_form.html.erb
@@ -106,6 +106,18 @@
return text.replace(/\n/g, "\r\n");
}
+ function getErrorLine() {
+ var error_line = /LINE (\d+)/g.exec($("#results").find('.alert-danger').text());
+
+ if (error_line) {
+ error_line = parseInt(error_line[1], 10);
+ if (editor.getSelectedText().length > 0) {
+ error_line += editor.getSelectionRange().start.row;
+ }
+ return error_line;
+ }
+ }
+
editor.getSession().on("change", adjustHeight);
adjustHeight();
$("#editor").show();
@@ -133,10 +145,8 @@
xhr = runQuery(data, function (data) {
$("#results").html(data);
- error_line = /LINE (\d+)/g.exec($("#results").find('.alert-danger').text());
-
+ error_line = getErrorLine();
if (error_line) {
- error_line = parseInt(error_line[1], 10);
editor.getSession().addGutterDecoration(error_line - 1, "error");
editor.scrollToLine(error_line, true, true, function () {});
editor.gotoLine(error_line, 0, true);