diff --git a/build/js/live-editor.output_sql.js b/build/js/live-editor.output_sql.js index 9d1887e9b..3f4aba724 100644 --- a/build/js/live-editor.output_sql.js +++ b/build/js/live-editor.output_sql.js @@ -818,24 +818,28 @@ window.SQLOutput = Backbone.View.extend({ if (colTypesError) { errorMessage = i18n._("Please use one of the valid column types " + "when creating a table: ") + "\"TEXT\", \"NUMERIC\", \"INTEGER\", \"REAL\", \"NONE\"."; } - var uniqError = sqliteError.indexOf("UNIQUE constraint failed:") > -1; + var uniqStr = "UNIQUE constraint failed:"; + var uniqError = sqliteError.indexOf(uniqStr) > -1; if (uniqError) { - var colName = sqliteError.split(":")[1].trim(); + var colName = sqliteError.split(uniqStr)[1].trim(); errorMessage = i18n._("\"UNIQUE\" constraint failed on column \"%(colName)s\".", { colName: colName }); } - var notNullError = sqliteError.indexOf("NOT NULL constraint") > -1; + var notNullStr = "NOT NULL constraint failed:"; + var notNullError = sqliteError.indexOf(notNullStr) > -1; if (notNullError) { - var colName = sqliteError.split(":")[1].trim(); + var colName = sqliteError.split(notNullStr)[1].trim(); errorMessage = i18n._("\"NOT NULL\" constraint failed on column \"%(colName)s\".", { colName: colName }); } - var dupColError = sqliteError.indexOf("duplicate column name:") > -1; + var dupColStr = "duplicate column name:"; + var dupColError = sqliteError.indexOf(dupColStr) > -1; if (dupColError) { - var colName = errorMessage.split(":")[1].trim(); + var colName = errorMessage.split(dupColStr)[1].trim(); errorMessage = i18n._("You have multiple columns named \"%(colName)s\" - " + "column names must be unique.", { colName: colName }); } - var unknownColError = sqliteError.indexOf("no such column:") > -1; + var unknownColStr = "no such column:"; + var unknownColError = sqliteError.indexOf(unknownColStr) > -1; if (unknownColError) { - var colName = sqliteError.split(":")[1].trim(); + var colName = sqliteError.split(unknownColStr)[1].trim(); errorMessage = i18n._("We can't find the column named \"%(colName)s\".", { colName: colName }); } var noTablesError = sqliteError.indexOf("no tables specified") > -1; @@ -843,9 +847,10 @@ window.SQLOutput = Backbone.View.extend({ errorMessage = i18n._("You didn't specify any tables for your \"SELECT\"."); } // Generic syntax error messages take form: 'near \"%T\": syntax error' - var isSyntaxError = sqliteError.indexOf(": syntax error") > -1; + var syntaxErrStr = ": syntax error"; + var isSyntaxError = sqliteError.indexOf(syntaxErrStr) > -1; if (isSyntaxError) { - var nearPhrase = errorMessage.split(":")[0]; + var nearPhrase = errorMessage.split(syntaxErrStr)[0]; errorMessage = i18n._("There's a syntax error near %(nearThing)s.", { nearThing: nearPhrase.substr(5) }); } diff --git a/js/output/sql/sql-output.js b/js/output/sql/sql-output.js index b438dc1f7..5ed7518c8 100644 --- a/js/output/sql/sql-output.js +++ b/js/output/sql/sql-output.js @@ -75,27 +75,31 @@ window.SQLOutput = Backbone.View.extend({ "when creating a table: ") + "\"TEXT\", \"NUMERIC\", \"INTEGER\", \"REAL\", \"NONE\"."; } - const uniqError = sqliteError.indexOf("UNIQUE constraint failed:") > -1; + const uniqStr = "UNIQUE constraint failed:"; + const uniqError = sqliteError.indexOf(uniqStr) > -1; if (uniqError) { - const colName = sqliteError.split(":")[1].trim(); + const colName = sqliteError.split(uniqStr)[1].trim(); errorMessage = i18n._("\"UNIQUE\" constraint failed on column \"%(colName)s\".", {colName}); } - const notNullError = sqliteError.indexOf("NOT NULL constraint") > -1; + const notNullStr = "NOT NULL constraint failed:" + const notNullError = sqliteError.indexOf(notNullStr) > -1; if (notNullError) { - const colName = sqliteError.split(":")[1].trim(); + const colName = sqliteError.split(notNullStr)[1].trim(); errorMessage = i18n._("\"NOT NULL\" constraint failed on column \"%(colName)s\".", {colName}); } - const dupColError = sqliteError.indexOf("duplicate column name:") > -1; + const dupColStr = "duplicate column name:"; + const dupColError = sqliteError.indexOf(dupColStr) > -1; if (dupColError) { - const colName = errorMessage.split(":")[1].trim(); + const colName = errorMessage.split(dupColStr)[1].trim(); errorMessage = i18n._("You have multiple columns named \"%(colName)s\" - " + "column names must be unique.", {colName}); } - const unknownColError = sqliteError.indexOf("no such column:") > -1; + const unknownColStr = "no such column:"; + const unknownColError = sqliteError.indexOf(unknownColStr) > -1; if (unknownColError) { - const colName = sqliteError.split(":")[1].trim(); + const colName = sqliteError.split(unknownColStr)[1].trim(); errorMessage = i18n._("We can't find the column named \"%(colName)s\".", {colName}); } @@ -104,9 +108,10 @@ window.SQLOutput = Backbone.View.extend({ errorMessage = i18n._("You didn't specify any tables for your \"SELECT\"."); } // Generic syntax error messages take form: 'near \"%T\": syntax error' - const isSyntaxError = sqliteError.indexOf(": syntax error") > -1; + const syntaxErrStr = ": syntax error"; + const isSyntaxError = sqliteError.indexOf(syntaxErrStr) > -1; if (isSyntaxError) { - const nearPhrase = errorMessage.split(":")[0]; + const nearPhrase = errorMessage.split(syntaxErrStr)[0]; errorMessage = i18n._("There's a syntax error near %(nearThing)s.", {nearThing: nearPhrase.substr(5)}); }