master
yutent 2024-07-23 18:54:00 +08:00
parent f0366b9d2d
commit 4d79480e72
4 changed files with 19 additions and 13 deletions

View File

@ -29,7 +29,7 @@ class Mysqli {
host,
port,
user,
charset,
charset = 'utf8mb4',
passwd: password,
db: database,
timezone,
@ -39,7 +39,6 @@ class Mysqli {
let name = i < 1 ? 'MASTER' : 'SLAVE' + i
let collate
charset = charset || 'utf8mb4'
collate =
charset + (charset === 'utf8mb4' ? '_0900_ai_ci' : '_general_ci')

View File

@ -79,7 +79,6 @@ class Api {
if (!this.db && db) {
return Promise.reject('No database selected.')
}
let defer = Promise.defer()
return this.query(`DROP DATABASE IF EXISTS ${db || this.db}`)
}

View File

@ -128,7 +128,18 @@ class Method {
}
}
let { table, leftJoin, rightJoin, join, filter, fields, sort, skip, size, limit } = this.cache
let {
table,
leftJoin,
rightJoin,
join,
filter,
fields,
sort,
skip,
size,
limit
} = this.cache
// 没有使用 slice方法的前提下, 通过skip/limit补全
if (!limit) {

View File

@ -8,10 +8,7 @@ const { escape } = require('mysql')
function hideProperty(host, name, value) {
Object.defineProperty(host, name, {
value: value,
writable: true,
enumerable: false,
configurable: true
value: value
})
}
@ -19,11 +16,9 @@ function getType(val) {
if (val === null) {
return String(val)
}
return Object.prototype.toString
.call(val)
.slice(8, -1)
.toLowerCase()
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase()
}
function parse$or(arr) {
let sql = ''
for (let it of arr) {
@ -299,7 +294,9 @@ class SqlErr {
hideProperty(this, 'stack', msg)
console.error(
line +
`\n[${new Date().format('Y/m/d_H:i:s')}][Last Query SQL]: ${sql}\nQuery ${msg}\n` +
`\n[${new Date().format(
'Y/m/d_H:i:s'
)}][Last Query SQL]: ${sql}\nQuery ${msg}\n` +
line
)
}