think-model-sqlite 1.2.3 → 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.
Files changed (2) hide show
  1. package/lib/parser.js +14 -0
  2. package/package.json +1 -1
package/lib/parser.js CHANGED
@@ -156,6 +156,20 @@ module.exports = class SQLiteParser extends Parser {
156
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 []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "think-model-sqlite",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "SQLite adapter for ThinkJS 3.x",
5
5
  "scripts": {
6
6
  "test": "npm run eslint && npm run test-cov",