think-model-sqlite 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parser.js +15 -1
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -153,9 +153,23 @@ module.exports = class SQLiteParser extends Parser {
|
|
|
153
153
|
parseKey(key) {
|
|
154
154
|
if (!/^\w+$/.test(key)) return key;
|
|
155
155
|
const keyUpperCase = key.toUpperCase();
|
|
156
|
-
if (keywords.indexOf(keyUpperCase) > -1) return `"${key}"`;
|
|
156
|
+
if (keywords.indexOf(keyUpperCase) > -1 || /^\d/.test(key)) return `"${key}"`;
|
|
157
157
|
return key;
|
|
158
158
|
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* build insert sql
|
|
162
|
+
* @param {Object} options
|
|
163
|
+
*/
|
|
164
|
+
buildInsertSql(options) {
|
|
165
|
+
const sql = super.buildInsertSql(options);
|
|
166
|
+
|
|
167
|
+
// FIX `INSERT IGNORE` generated in think-model-abstract
|
|
168
|
+
// For sqlite, the equivalent syntax for `insert ignore` is `insert or ignore`
|
|
169
|
+
// SEE https://www.sqlite.org/lang_insert.html
|
|
170
|
+
return sql.replace(/^INSERT IGNORE/, 'INSERT OR IGNORE');
|
|
171
|
+
}
|
|
172
|
+
|
|
159
173
|
/**
|
|
160
174
|
* escape string
|
|
161
175
|
* @param {String} str []
|