diff --git a/.gitignore b/.gitignore index b707151..d2a9cc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ .DS_Store .AppleDouble .LSOverride -Icon -/dist -/node_modules + +package-lock.json +node_modules/ # Thumbnails ._* diff --git a/index.js b/index.js index c89cd86..d87b6cd 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,9 @@ /** * mysql操作类 - * @authors yutent (yutent@doui.cc) - * @date 2015-11-24 11:31:55 - * + * @author yutent + * @date 2020/11/24 20:04:20 */ -'use strict' + require('es.shim') const mysql = require('mysql') const Api = require('./lib/api') @@ -42,7 +41,7 @@ class Mysqli { charset = charset || 'utf8mb4' collate = - charset + (charset === 'utf8mb4' ? '_unicode_ci' : '_general_ci') + charset + (charset === 'utf8mb4' ? '_0900_ai_ci' : '_general_ci') timezone = timezone || 'local' supportBigNumbers = !!supportBigNumbers diff --git a/lib/api.js b/lib/api.js index e60dccd..5b0e880 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,8 +1,7 @@ /** * - * @authors yutent (yutent@doui.cc) - * @date 2018-04-13 14:30:49 - * @version $Id$ + * @author yutent + * @date 2020/11/24 20:04:39 */ const { SqlErr, parser, fixtable } = require('./utils') diff --git a/lib/method.js b/lib/method.js index f18edfc..5807a09 100644 --- a/lib/method.js +++ b/lib/method.js @@ -1,8 +1,7 @@ /** * - * @authors yutent (yutent@doui.cc) - * @date 2017-12-14 14:01:03 - * @version $Id$ + * @author yutent + * @date 2020/11/24 20:04:58 */ const { SqlErr, parser, escape, fixtable } = require('./utils') @@ -406,7 +405,9 @@ class Method { return this.connect().then(conn => { const defer = Promise.defer() - let sql = `ALTER TABLE ${this.cache.table} ADD ${unique} INDEX \`${name}\` (${opt.field})` + let sql = `ALTER TABLE ${ + this.cache.table + } ADD ${unique} INDEX \`${name}\` (${opt.field})` conn.query(sql, (err, result) => { conn.release() diff --git a/lib/utils.js b/lib/utils.js index bec2874..e2c079f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,9 +1,9 @@ /** * - * @authors yutent (yutent@doui.cc) - * @date 2017-12-14 02:41:15 - * @version $Id$ + * @author yutent + * @date 2020/11/24 20:07:37 */ + const { escape } = require('mysql') function hideProperty(host, name, value) { @@ -275,7 +275,9 @@ const parser = { indexes.push(idx) } } - sql += `\`${it.name}\` ${it.type} ${notnull} ${defaultVal} ${inc} ${autoUpdate},\n` + sql += `\`${it.name}\` ${ + it.type + } ${notnull} ${defaultVal} ${inc} ${autoUpdate},\n` } if (!primary) { throw new Error('Can not create table without primary key.') diff --git a/package.json b/package.json index 689bb03..1dc1dba 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "mysqli", - "version": "3.0.11", + "version": "3.0.12", "description": "MySQL tool", "main": "index.js", "dependencies": { - "es.shim": "^1.1.2", + "es.shim": "^2.0.1", "mysql": "^2.13.0" }, - "repository": "https://github.com/yutent/mysqli.git", + "repository": "https://github.com/bytedo/mysqli.git", "author": "yutent", "license": "MIT" }