mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-25 01:45:59 +00:00
This commit is contained in:
@@ -4,6 +4,7 @@ const sql = require('./sql');
|
|||||||
|
|
||||||
const DatabaseAnalayser = require('../default/DatabaseAnalyser');
|
const DatabaseAnalayser = require('../default/DatabaseAnalyser');
|
||||||
const { isTypeString, isTypeNumeric } = require('@dbgate/tools');
|
const { isTypeString, isTypeNumeric } = require('@dbgate/tools');
|
||||||
|
const { rangeStep } = require('lodash/fp');
|
||||||
|
|
||||||
function getColumnInfo({
|
function getColumnInfo({
|
||||||
isNullable,
|
isNullable,
|
||||||
@@ -44,7 +45,8 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
|||||||
if (this.singleObjectFilter) {
|
if (this.singleObjectFilter) {
|
||||||
const { typeField, pureName } = this.singleObjectFilter;
|
const { typeField, pureName } = this.singleObjectFilter;
|
||||||
if (!typeFields || !typeFields.includes(typeField)) return null;
|
if (!typeFields || !typeFields.includes(typeField)) return null;
|
||||||
return res.replace('=[OBJECT_NAME_CONDITION]', ` = ${pureName}`).replace('#DATABASE#', this.pool._database_name);
|
res = res.replace('=[OBJECT_NAME_CONDITION]', ` = '${pureName}'`).replace('#DATABASE#', this.pool._database_name);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
if (!this.modifications || !typeFields || this.modifications.length == 0) {
|
if (!this.modifications || !typeFields || this.modifications.length == 0) {
|
||||||
res = res.replace('=[OBJECT_NAME_CONDITION]', ' is not null');
|
res = res.replace('=[OBJECT_NAME_CONDITION]', ' is not null');
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ const driver = {
|
|||||||
return connection;
|
return connection;
|
||||||
},
|
},
|
||||||
async query(connection, sql) {
|
async query(connection, sql) {
|
||||||
|
if (sql == null) {
|
||||||
|
return {
|
||||||
|
rows: [],
|
||||||
|
columns: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
connection.query(sql, function (error, results, fields) {
|
connection.query(sql, function (error, results, fields) {
|
||||||
if (error) reject(error);
|
if (error) reject(error);
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ const driver = {
|
|||||||
return client;
|
return client;
|
||||||
},
|
},
|
||||||
async query(client, sql) {
|
async query(client, sql) {
|
||||||
|
if (sql == null) {
|
||||||
|
return {
|
||||||
|
rows: [],
|
||||||
|
columns: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
const res = await client.query(sql);
|
const res = await client.query(sql);
|
||||||
return { rows: res.rows, columns: res.fields };
|
return { rows: res.rows, columns: res.fields };
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user