|
88 | 88 | case "0065": this.message = "AUTO_INCREMENT column must be a key."; break; |
89 | 89 | case "0066": this.message = "AUTO_INCREMENT column must be an INT type."; break; |
90 | 90 | case "0067": this.message = "API is out of memory, cannot store more data."; break; |
| 91 | + case "0068": this.message = "Invalid ENUM value."; break; |
| 92 | + case "0069": this.message = "NUMERIC or INT type invalid or out of range."; break; |
91 | 93 | default: this.message = "Unknown error."; break; |
92 | 94 | } |
93 | 95 | this.toString = function () { |
|
117 | 119 | aliases: ["NUMBER", "DECIMAL", "FLOAT"], |
118 | 120 | serialize: function(value, args){ |
119 | 121 | return !isNaN(parseFloat(value)) && isFinite(value) ? |
120 | | - parseFloat(value) : 0; |
| 122 | + parseFloat(value) : |
| 123 | + _throw(new jSQL_Error("0069")) ; |
121 | 124 | }, |
122 | 125 | unserialize: function(value, args){ |
123 | 126 | return !isNaN(parseFloat(value)) && isFinite(value) ? |
124 | | - parseFloat(value) : 0; |
| 127 | + parseFloat(value) : |
| 128 | + _throw(new jSQL_Error("0069")) ; |
125 | 129 | } |
126 | 130 | },{ |
127 | 131 | type: "ENUM", |
128 | | - serialize: function(value, args){ return "tits"; |
| 132 | + serialize: function(value, args){ |
129 | 133 | for(var i=args.length; i--;) |
130 | | - if(value == removeQuotes(args[i])) return removeQuotes(args[i]); |
131 | | - return removeQuotes(args[0]); |
| 134 | + if(value.toUpperCase() == removeQuotes(args[i]).toUpperCase()) return removeQuotes(args[i]); |
| 135 | + return _throw(new jSQL_Error("0068")); |
132 | 136 | }, |
133 | | - unserialize: function(value, args){ return "tits"; |
| 137 | + unserialize: function(value, args){ |
134 | 138 | for(var i=args.length; i--;) |
135 | | - if(value == removeQuotes(args[i])) return removeQuotes(args[i]); |
136 | | - return removeQuotes(args[0]); |
| 139 | + if(value.toUpperCase() == removeQuotes(args[i]).toUpperCase()) return removeQuotes(args[i]); |
| 140 | + return _throw(new jSQL_Error("0068")); |
137 | 141 | } |
138 | 142 | },{ |
139 | 143 | type: "TINYINT", |
|
151 | 155 | serialize: function(value, args){ |
152 | 156 | return !isNaN(parseInt(value)) && isFinite(value) && |
153 | 157 | value >= -32768 && value <= 32767 ? |
154 | | - parseInt(value) : 0; |
| 158 | + parseInt(value) : |
| 159 | + _throw(new jSQL_Error("0069")) ; |
155 | 160 | }, |
156 | 161 | unserialize: function(value, args){ |
157 | 162 | return !isNaN(parseInt(value)) && isFinite(value) ? |
158 | | - parseInt(value) : 0; |
| 163 | + parseInt(value) : |
| 164 | + _throw(new jSQL_Error("0069")) ; |
159 | 165 | } |
160 | 166 | },{ |
161 | 167 | type: "MEDIUMINT", |
162 | 168 | serialize: function(value, args){ |
163 | 169 | return !isNaN(parseInt(value)) && isFinite(value) && |
164 | 170 | value >= -8388608 && value <= 8388607 ? |
165 | | - parseInt(value) : 0; |
| 171 | + parseInt(value) : |
| 172 | + _throw(new jSQL_Error("0069")) ; |
166 | 173 | }, |
167 | 174 | unserialize: function(value, args){ |
168 | 175 | return !isNaN(parseInt(value)) && isFinite(value) ? |
169 | | - parseInt(value) : 0; |
| 176 | + parseInt(value) : |
| 177 | + _throw(new jSQL_Error("0069")) ; |
170 | 178 | } |
171 | 179 | },{ |
172 | 180 | type: "INT", |
173 | 181 | serialize: function(value, args){ |
174 | 182 | return !isNaN(parseInt(value)) && isFinite(value) && |
175 | 183 | value >= -2147483648 && value <= 2147483647 ? |
176 | | - parseInt(value) : 0; |
| 184 | + parseInt(value) : _throw(new jSQL_Error("0069")); |
177 | 185 | }, |
178 | 186 | unserialize: function(value, args){ |
179 | 187 | return !isNaN(parseInt(value)) && isFinite(value) ? |
180 | | - parseInt(value) : 0; |
| 188 | + parseInt(value) : _throw(new jSQL_Error("0069")); |
181 | 189 | } |
182 | 190 | },{ |
183 | 191 | type: "BIGINT", |
184 | 192 | serialize: function(value, args){ |
185 | 193 | return !isNaN(parseInt(value)) && isFinite(value) && |
186 | 194 | value >= -9007199254740991 && value <= 9007199254740991 ? |
187 | | - parseInt(value) : 0; |
| 195 | + parseInt(value) : _throw(new jSQL_Error("0069")); |
188 | 196 | }, |
189 | 197 | unserialize: function(value, args){ |
190 | 198 | return !isNaN(parseInt(value)) && isFinite(value) ? |
191 | | - parseInt(value) : 0; |
| 199 | + parseInt(value) : _throw(new jSQL_Error("0069")); |
192 | 200 | } |
193 | 201 | },{ |
194 | 202 | type: "JSON", |
|
581 | 589 | var storeVal = jSQL.types.getByType(type.type.toUpperCase()).serialize(value, type.args); |
582 | 590 | if((!isNaN(parseFloat(storeVal)) && isFinite(storeVal)) || typeof storeVal === "string") |
583 | 591 | return storeVal; |
584 | | - console.log(storeVal); |
585 | 592 | return _throw(new jSQL_Error("0020")); |
586 | 593 | }; |
587 | 594 |
|
|
753 | 760 | this.data[i] = preparedVals.shift(); |
754 | 761 | } |
755 | 762 | } |
756 | | - console.log(this.data); |
757 | 763 | jSQL.tables[this.table].insertRow(this.data, this.ignoreFlag); |
758 | 764 | return this; |
759 | 765 | }; |
|
2561 | 2567 | self.api.init([{name: "jSQL_data_schema", rows:[]}], successCallback); |
2562 | 2568 | APIIsSet = true; |
2563 | 2569 | }catch(ex){ |
2564 | | - console.log(ex); |
2565 | 2570 | APIIsSet = false; |
2566 | 2571 | } |
2567 | 2572 | if(!APIIsSet) loop(1+i); |
|
0 commit comments