-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
99 lines (73 loc) · 2.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Created by lynmatten on 06.09.15.
*/
var mysqlOrig = require('mysql');
/** provides a Mock für mysql and substitutes relevant parts with a Mock class. The rest will be passed to the original mysql module **/
var sqlMock = [];
exports.passMockObject = function(mockObj) {
if(mockObj != undefined && Array.isArray(mockObj) ) {
sqlMock = mockObj;
}
};
/**
* Create a new Connection instance.
* @param {object} config
* @public
*/
exports.createConnection = function createConnection(config) {
return mysqlOrig.createConnection(config);
};
/**
* Create a new Pool instance.
* @param {object} config
* @public
*/
exports.createPool = function createPool(config) {
var mysqlPoolMock = require('./lib/mysqlPoolMock.js');
return new mysqlPoolMock(config, sqlMock);
};
/**
* Create a new PoolCluster instance.
* @param {object} config
* @public
*/
exports.createPoolCluster = function createPoolCluster(config) {
return mysqlOrig.createPoolCluster(config);
};
/**
* Create a new Query instance.
* @public
*/
exports.createQuery = function createQuery(sql, values, callback) {
mysqlOrig.createQuery(sql, values, callback);
};
/**
* Escape a value for SQL.
* @param {*} value
* @param {boolean} [stringifyObjects=false]
* @param {string} [timeZone=local]
* @public
*/
exports.escape = function escape(value, stringifyObjects, timeZone) {
return mysqlOrig.escape(value, stringifyObjects, timeZone);
};
/**
* Escape an identifier for SQL.
* @param {*} value
* @param {boolean} [forbidQualified]
* @public
*/
exports.escapeId = function escapeId(value, forbidQualified) {
return mysqlOrig.escapeId(value, forbidQualified);
};
/**
* Format SQL and replacement values into a SQL string.
* @param {string} sql
* @param {array} [values]
* @param {boolean} [stringifyObjects=false]
* @param {string} [timeZone=local]
* @public
*/
exports.format = function format(sql, values, stringifyObjects, timeZone) {
return mysqlOrig.format(sql, values, stringifyObjects, timeZone);
};