@@ -17,84 +17,85 @@ function jSQL_Error(error_no) {
1717 var e = new Error ( ) ;
1818 if ( e . stack ) this . stack = e . stack ;
1919 /* istanbul ignore next */
20- switch ( error_no ) {
21- case "0001" : this . message = "Corrupted function stored in data." ; break ;
22- case "0003" : this . message = "Invalid datatype definition." ; break ;
23- case "0004" : this . message = "DataType must have a `type` property." ; break ;
24- case "0005" : this . message = "DataType must have a `serialize` function." ; break ;
25- case "0006" : this . message = "DataType must have an `unserialize` function." ; break ;
26- case "0007" : this . message = "Unsupported data type." ; break ;
27- case "0010" : this . message = "Invalid constraint." ; break ;
28- case "0011" : this . message = "This table already has a primary key." ; break ;
29- case "0012" : this . message = "renameColumn expects and old column name and a new one, both must be strings." ; break ;
30- case "0013" : this . message = "Column does not exist." ; break ;
31- case "0014" : this . message = "Data must be an array." ; break ;
32- case "0015" : this . message = "Data not structured properly." ; break ;
33- case "0016" : this . message = "Cannot insert a null value in a primary column." ; break ;
34- case "0017" : this . message = "Primary Key violated." ; break ;
35- case "0018" : this . message = "Cannot insert a null value in a unique column." ; break ;
36- case "0019" : this . message = "Unique key violated." ; break ;
37- case "0020" : this . message = "Data type's serialize() method did not return a string." ; break ;
38- case "0021" : this . message = "Table does not exist." ; break ;
39- case "0022" : this . message = "Method does not apply to query type." ; break ;
40- case "0023" : this . message = "Fetch expects paramter one to be 'ASSOC', 'ARRAY', or undefined." ; break ;
41- case "0024" : this . message = "Expected number or quoted string." ; break ;
42- case "0025" : this . message = "Expected 'ORDER BY'." ; break ;
43- case "0026" : this . message = "Must call ORDER BY before using ASC." ; break ;
44- case "0027" : this . message = "Must call ORDER BY before using DESC." ; break ;
45- case "0028" : this . message = "Unintelligible query. Expected 'FROM'." ; break ;
46- case "0029" : this . message = "Unintelligible query. Expected 'TABLE'." ; break ;
47- case "0030" : this . message = "Unintelligible query. Expected 'INTO'." ; break ;
48- case "0031" : this . message = "Unintelligible query. Expected 'VALUES'." ; break ;
49- case "0032" : this . message = "Unintelligible query. Too many values." ; break ;
50- case "0033" : this . message = "Unintelligible query. Columns mismatch." ; break ;
51- case "0034" : this . message = "Invalid Column definition." ; break ;
52- case "0035" : this . message = "Unintelligible query. Expected 'NOT'." ; break ;
53- case "0036" : this . message = "Unintelligible query. Expected 'EXISTS'." ; break ;
54- case "0037" : this . message = "Unintelligible query. expected ')'." ; break ;
55- case "0038" : this . message = "Invalid Arg definition." ; break ;
56- case "0039" : this . message = "Unintelligible query. Expected 'SET'." ; break ;
57- case "0040" : this . message = "Unintelligible query. Expected 'FROM'." ; break ;
58- case "0041" : this . message = "Unintelligible query. WTF?" ; break ;
59- case "0042" : this . message = "Must add a conditional before adding another 'Where' condition." ; break ;
60- case "0043" : this . message = "Column name must be a string." ; break ;
61- case "0044" : this . message = "Must add a 'where' clause before the 'equals' call." ; break ;
62- case "0045" : this . message = "Must add a 'where' clause before the 'preparedLike' call." ; break ;
63- case "0046" : this . message = "Must add a 'where' clause before the 'doesNotEqual' call." ; break ;
64- case "0047" : this . message = "Must add a 'where' clause before the 'lessThan' call." ; break ;
65- case "0048" : this . message = "Must add a 'where' clause before the 'greaterThan' call." ; break ;
66- case "0049" : this . message = "Must add a 'where' clause before the 'contains' call." ; break ;
67- case "0050" : this . message = "Must add a 'where' clause before the 'endsWith' call." ; break ;
68- case "0051" : this . message = "Must add a 'where' clause before the 'beginsWith' call." ; break ;
69- case "0052" : this . message = "Must use orderBy clause before using ASC." ; break ;
70- case "0053" : this . message = "Must use orderBy clause before using DESC." ; break ;
71- case "0054" : this . message = "Could not execute query." ; break ;
72- case "0055" : this . message = "Error creating table." ; break ;
73- case "0056" : this . message = "Error opening database." ; break ;
74- case "0057" : this . message = "indexedDB is not supported in this browser." ; break ;
75- case "0058" : this . message = "Could not add data after 10 seconds." ; break ;
76- case "0059" : this . message = "Error updating datastore version." ; break ;
77- case "0060" : this . message = "Could not connect to the indexedDB datastore." ; break ;
78- case "0061" : this . message = "Could not initiate a transaction." ; break ;
79- case "0062" : this . message = "Could not initiate a request." ; break ;
80- case "0063" : this . message = "Browser doesn't support Web SQL or IndexedDB." ; break ;
81- case "0064" : this . message = "Unable towrite to datastore file." ; break ;
82- case "0065" : this . message = "AUTO_INCREMENT column must be a key." ; break ;
83- case "0066" : this . message = "AUTO_INCREMENT column must be an INT type." ; break ;
84- case "0067" : this . message = "API is out of memory, cannot store more data." ; break ;
85- case "0068" : this . message = "Invalid ENUM value." ; break ;
86- case "0069" : this . message = "NUMERIC or INT type invalid or out of range." ; break ;
87- case "0070" : this . message = "Unknown Lexer Error." ; break ;
88- case "0071" : this . message = "Unknown Parser Error." ; break ;
89- case "0072" : this . message = "Inserting null into a non-null column." ; break ;
90- default : this . message = "Unknown error." ; break ;
91- }
20+ if ( jSQL_Error . message_codes [ error_no ] ) this . message = jSQL_Error . message_codes [ error_no ] ;
21+ else this . message = "Unknown error." ;
9222 this . toString = function ( ) {
9323 if ( undefined === this . error ) return "jSQL Error - " + this . message ;
9424 return "jSQL Error #" + this . error + " - " + this . message ;
9525 } ;
9626}
9727
28+ jSQL_Error . message_codes = {
29+ "0001" : "Corrupted function stored in data." ,
30+ "0003" : "Invalid datatype definition." ,
31+ "0004" : "DataType must have a `type` property." ,
32+ "0005" : "DataType must have a `serialize` function." ,
33+ "0006" : "DataType must have an `unserialize` function." ,
34+ "0007" : "Unsupported data type." ,
35+ "0010" : "Invalid constraint." ,
36+ "0011" : "This table already has a primary key." ,
37+ "0012" : "renameColumn expects and old column name and a new one, both must be strings." ,
38+ "0013" : "Column does not exist." ,
39+ "0014" : "Data must be an array." ,
40+ "0015" : "Data not structured properly." ,
41+ "0016" : "Cannot insert a null value in a primary column." ,
42+ "0017" : "Primary Key violated." ,
43+ "0018" : "Cannot insert a null value in a unique column." ,
44+ "0019" : "Unique key violated." ,
45+ "0020" : "Data type's serialize() method did not return a string." ,
46+ "0021" : "Table does not exist." ,
47+ "0022" : "Method does not apply to query type." ,
48+ "0023" : "Fetch expects paramter one to be 'ASSOC', 'ARRAY', or undefined." ,
49+ "0024" : "Expected number or quoted string." ,
50+ "0025" : "Expected 'ORDER BY'." ,
51+ "0026" : "Must call ORDER BY before using ASC." ,
52+ "0027" : "Must call ORDER BY before using DESC." ,
53+ "0028" : "Unintelligible query. Expected 'FROM'." ,
54+ "0029" : "Unintelligible query. Expected 'TABLE'." ,
55+ "0030" : "Unintelligible query. Expected 'INTO'." ,
56+ "0031" : "Unintelligible query. Expected 'VALUES'." ,
57+ "0032" : "Unintelligible query. Too many values." ,
58+ "0033" : "Unintelligible query. Columns mismatch." ,
59+ "0034" : "Invalid Column definition." ,
60+ "0035" : "Unintelligible query. Expected 'NOT'." ,
61+ "0036" : "Unintelligible query. Expected 'EXISTS'." ,
62+ "0037" : "Unintelligible query. expected ')'." ,
63+ "0038" : "Invalid Arg definition." ,
64+ "0039" : "Unintelligible query. Expected 'SET'." ,
65+ "0040" : "Unintelligible query. Expected 'FROM'." ,
66+ "0041" : "Unintelligible query. WTF?" ,
67+ "0042" : "Must add a conditional before adding another 'Where' condition." ,
68+ "0043" : "Column name must be a string." ,
69+ "0044" : "Must add a 'where' clause before the 'equals' call." ,
70+ "0045" : "Must add a 'where' clause before the 'preparedLike' call." ,
71+ "0046" : "Must add a 'where' clause before the 'doesNotEqual' call." ,
72+ "0047" : "Must add a 'where' clause before the 'lessThan' call." ,
73+ "0048" : "Must add a 'where' clause before the 'greaterThan' call." ,
74+ "0049" : "Must add a 'where' clause before the 'contains' call." ,
75+ "0050" : "Must add a 'where' clause before the 'endsWith' call." ,
76+ "0051" : "Must add a 'where' clause before the 'beginsWith' call." ,
77+ "0052" : "Must use orderBy clause before using ASC." ,
78+ "0053" : "Must use orderBy clause before using DESC." ,
79+ "0054" : "Could not execute query." ,
80+ "0055" : "Error creating table." ,
81+ "0056" : "Error opening database." ,
82+ "0057" : "indexedDB is not supported in this browser." ,
83+ "0058" : "Could not add data after 10 seconds." ,
84+ "0059" : "Error updating datastore version." ,
85+ "0060" : "Could not connect to the indexedDB datastore." ,
86+ "0061" : "Could not initiate a transaction." ,
87+ "0062" : "Could not initiate a request." ,
88+ "0063" : "Browser doesn't support Web SQL or IndexedDB." ,
89+ "0064" : "Unable towrite to datastore file." ,
90+ "0065" : "AUTO_INCREMENT column must be a key." ,
91+ "0066" : "AUTO_INCREMENT column must be an INT type." ,
92+ "0067" : "API is out of memory, cannot store more data." ,
93+ "0068" : "Invalid ENUM value." ,
94+ "0069" : "NUMERIC or INT type invalid or out of range." ,
95+ "0070" : "Unknown Lexer Error." ,
96+ "0071" : "Unknown Parser Error." ,
97+ "0072" : "Inserting null into a non-null column."
98+ } ;
9899
99100function jSQL_Lexer_Error ( pos , context ) {
100101 var max_ellipse_len = 25 ;
@@ -650,7 +651,7 @@ jSQLTable.prototype.updateKeysOnInsert = function(row, ignore){
650651 var key_columns = Array . isArray ( ukey . column ) ? ukey . column : [ ukey . column ] ;
651652 var col , vals = [ ] ;
652653 for ( var uk = 0 ; uk < key_columns . length ; uk ++ ) {
653- col = key_columns [ uk ]
654+ col = key_columns [ uk ] ;
654655 var index = this . colmap [ col ] ;
655656 if ( null === row [ index ] ) {
656657 if ( ignore === true ) return false ;
0 commit comments