meadow 2.0.5 → 2.0.6
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.
- package/.config/configstore/update-notifier-npm.json +1 -1
- package/.config/vscode-sqltools/runningInfo.json +1 -1
- package/package.json +3 -2
- package/source/providers/Meadow-Provider-MSSQL.js +308 -0
- package/source/providers/Meadow-Provider-MySQL.js +78 -78
- package/test/Meadow-Provider-MSSQL-AnimalReadQuery.sql +5 -0
- package/test/Meadow-Provider-MSSQL_tests.js +1194 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meadow",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "A data access library.",
|
|
5
5
|
"main": "source/Meadow.js",
|
|
6
6
|
"scripts": {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"gulp-sourcemaps": "^3.0.0",
|
|
56
56
|
"gulp-terser": "^2.1.0",
|
|
57
57
|
"gulp-util": "^3.0.8",
|
|
58
|
+
"meadow-connection-mssql": "^1.0.1",
|
|
58
59
|
"meadow-connection-mysql": "^1.0.2",
|
|
59
60
|
"mocha": "10.2.0",
|
|
60
61
|
"mysql2": "^3.3.2",
|
|
@@ -64,7 +65,7 @@
|
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
66
67
|
"async": "3.2.4",
|
|
67
|
-
"foxhound": "^2.0.
|
|
68
|
+
"foxhound": "^2.0.4",
|
|
68
69
|
"is-my-json-valid": "2.20.6",
|
|
69
70
|
"npm-check-updates": "^16.10.12",
|
|
70
71
|
"simple-get": "^4.0.1"
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// ##### Part of the **[retold](https://stevenvelozo.github.io/retold/)** system
|
|
2
|
+
/**
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author <steven@velozo.com>
|
|
5
|
+
*/
|
|
6
|
+
var MeadowProvider = function ()
|
|
7
|
+
{
|
|
8
|
+
function createNew(pFable)
|
|
9
|
+
{
|
|
10
|
+
// If a valid Fable object isn't passed in, return a constructor
|
|
11
|
+
if (typeof (pFable) !== 'object')
|
|
12
|
+
{
|
|
13
|
+
return { new: createNew };
|
|
14
|
+
}
|
|
15
|
+
var _Fable = pFable;
|
|
16
|
+
var _GlobalLogLevel = 0;
|
|
17
|
+
if (_Fable.settings.MSSQL)
|
|
18
|
+
{
|
|
19
|
+
_GlobalLogLevel = _Fable.settings.MSSQL.GlobalLogLevel || 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Build a connection pool, shared within this provider.
|
|
24
|
+
* This may be more performant as a shared object.
|
|
25
|
+
*/
|
|
26
|
+
var getSQLPool = function ()
|
|
27
|
+
{
|
|
28
|
+
// New-style default connection pool provider
|
|
29
|
+
// There are no legacy MSSQL open source connectors.
|
|
30
|
+
if (typeof (_Fable.MeadowMSSQLProvider) == 'object' && _Fable.MeadowMSSQLProvider.connected)
|
|
31
|
+
{
|
|
32
|
+
return _Fable.MeadowMSSQLProvider.pool;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// The Meadow marshaller also passes in the Schema as the third parameter, but this is a blunt function ATM.
|
|
39
|
+
var marshalRecordFromSourceToObject = function (pObject, pRecord)
|
|
40
|
+
{
|
|
41
|
+
// For now, crudely assign everything in pRecord to pObject
|
|
42
|
+
// This is safe in this context, and we don't want to slow down marshalling with millions of hasOwnProperty checks
|
|
43
|
+
for (var tmpColumn in pRecord)
|
|
44
|
+
{
|
|
45
|
+
pObject[tmpColumn] = pRecord[tmpColumn];
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var Create = function (pQuery, fCallback)
|
|
50
|
+
{
|
|
51
|
+
var tmpResult = pQuery.parameters.result;
|
|
52
|
+
|
|
53
|
+
pQuery.setDialect('MSSQL').buildCreateQuery();
|
|
54
|
+
|
|
55
|
+
// TODO: Test the query before executing
|
|
56
|
+
if (pQuery.logLevel > 0 ||
|
|
57
|
+
_GlobalLogLevel > 0)
|
|
58
|
+
{
|
|
59
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
63
|
+
{
|
|
64
|
+
pDBConnection.query(
|
|
65
|
+
pQuery.query.body,
|
|
66
|
+
pQuery.query.parameters,
|
|
67
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
68
|
+
function (pError, pRows)
|
|
69
|
+
{
|
|
70
|
+
pDBConnection.release();
|
|
71
|
+
tmpResult.error = pError;
|
|
72
|
+
tmpResult.value = false;
|
|
73
|
+
try
|
|
74
|
+
{
|
|
75
|
+
tmpResult.value = pRows.insertId;
|
|
76
|
+
}
|
|
77
|
+
catch (pErrorGettingRowcount)
|
|
78
|
+
{
|
|
79
|
+
_Fable.log.warn('Error getting insert ID during create query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
tmpResult.executed = true;
|
|
83
|
+
return fCallback();
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// This is a synchronous read, good for a few records.
|
|
90
|
+
// TODO: Add a pipe-able read for huge sets
|
|
91
|
+
var Read = function (pQuery, fCallback)
|
|
92
|
+
{
|
|
93
|
+
var tmpResult = pQuery.parameters.result;
|
|
94
|
+
|
|
95
|
+
pQuery.setDialect('MSSQL').buildReadQuery();
|
|
96
|
+
|
|
97
|
+
if (pQuery.logLevel > 0 ||
|
|
98
|
+
_GlobalLogLevel > 0)
|
|
99
|
+
{
|
|
100
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let tmpPreparedStatement = _Fable.MeadowMSSQLProvider.preparedStatement;
|
|
104
|
+
// Now define the inputs for the prepared statement based on the parameters and the schema.
|
|
105
|
+
|
|
106
|
+
//tmpPreparedStatement.input('param', _Fable.MeadowMSSQLProvider.MSSQL.Int);
|
|
107
|
+
tmpPreparedStatement.prepare(pQuery.query.body,
|
|
108
|
+
(pPrepareError) =>
|
|
109
|
+
{
|
|
110
|
+
tmpPreparedStatement.execute(pQuery.query.parameters,
|
|
111
|
+
(pPreparedExecutionError, pPreparedResult) =>
|
|
112
|
+
{
|
|
113
|
+
_Fable.log.info(`Prepared statement returned...`, pPreparedResult);
|
|
114
|
+
// release the connection after queries are executed
|
|
115
|
+
tmpPreparedStatement.unprepare(
|
|
116
|
+
(pPreparedStatementUnprepareError) =>
|
|
117
|
+
{
|
|
118
|
+
_Fable.log.trace(`Prepared statement unprepared.`);
|
|
119
|
+
return fCallback(pPreparedStatementUnprepareError);
|
|
120
|
+
});
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
124
|
+
{
|
|
125
|
+
pDBConnection.query(
|
|
126
|
+
pQuery.query.body,
|
|
127
|
+
pQuery.query.parameters,
|
|
128
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
129
|
+
function (pError, pRows)
|
|
130
|
+
{
|
|
131
|
+
pDBConnection.release();
|
|
132
|
+
tmpResult.error = pError;
|
|
133
|
+
tmpResult.value = pRows;
|
|
134
|
+
tmpResult.executed = true;
|
|
135
|
+
return fCallback();
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var Update = function (pQuery, fCallback)
|
|
142
|
+
{
|
|
143
|
+
var tmpResult = pQuery.parameters.result;
|
|
144
|
+
|
|
145
|
+
pQuery.setDialect('MSSQL').buildUpdateQuery();
|
|
146
|
+
|
|
147
|
+
if (pQuery.logLevel > 0 ||
|
|
148
|
+
_GlobalLogLevel > 0)
|
|
149
|
+
{
|
|
150
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
154
|
+
{
|
|
155
|
+
pDBConnection.query(
|
|
156
|
+
pQuery.query.body,
|
|
157
|
+
pQuery.query.parameters,
|
|
158
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
159
|
+
function (pError, pRows)
|
|
160
|
+
{
|
|
161
|
+
pDBConnection.release();
|
|
162
|
+
tmpResult.error = pError;
|
|
163
|
+
tmpResult.value = pRows;
|
|
164
|
+
tmpResult.executed = true;
|
|
165
|
+
return fCallback();
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var Delete = function (pQuery, fCallback)
|
|
172
|
+
{
|
|
173
|
+
var tmpResult = pQuery.parameters.result;
|
|
174
|
+
|
|
175
|
+
pQuery.setDialect('MSSQL').buildDeleteQuery();
|
|
176
|
+
|
|
177
|
+
if (pQuery.logLevel > 0 ||
|
|
178
|
+
_GlobalLogLevel > 0)
|
|
179
|
+
{
|
|
180
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
184
|
+
{
|
|
185
|
+
pDBConnection.query
|
|
186
|
+
(
|
|
187
|
+
pQuery.query.body,
|
|
188
|
+
pQuery.query.parameters,
|
|
189
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
190
|
+
function (pError, pRows)
|
|
191
|
+
{
|
|
192
|
+
pDBConnection.release();
|
|
193
|
+
tmpResult.error = pError;
|
|
194
|
+
tmpResult.value = false;
|
|
195
|
+
try
|
|
196
|
+
{
|
|
197
|
+
tmpResult.value = pRows.affectedRows;
|
|
198
|
+
}
|
|
199
|
+
catch (pErrorGettingRowcount)
|
|
200
|
+
{
|
|
201
|
+
_Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
202
|
+
}
|
|
203
|
+
tmpResult.executed = true;
|
|
204
|
+
return fCallback();
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
var Undelete = function (pQuery, fCallback)
|
|
211
|
+
{
|
|
212
|
+
var tmpResult = pQuery.parameters.result;
|
|
213
|
+
|
|
214
|
+
pQuery.setDialect('MSSQL').buildUndeleteQuery();
|
|
215
|
+
|
|
216
|
+
if (pQuery.logLevel > 0 ||
|
|
217
|
+
_GlobalLogLevel > 0)
|
|
218
|
+
{
|
|
219
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
223
|
+
{
|
|
224
|
+
pDBConnection.query
|
|
225
|
+
(
|
|
226
|
+
pQuery.query.body,
|
|
227
|
+
pQuery.query.parameters,
|
|
228
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
229
|
+
function (pError, pRows)
|
|
230
|
+
{
|
|
231
|
+
pDBConnection.release();
|
|
232
|
+
tmpResult.error = pError;
|
|
233
|
+
tmpResult.value = false;
|
|
234
|
+
try
|
|
235
|
+
{
|
|
236
|
+
tmpResult.value = pRows.affectedRows;
|
|
237
|
+
}
|
|
238
|
+
catch (pErrorGettingRowcount)
|
|
239
|
+
{
|
|
240
|
+
_Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
241
|
+
}
|
|
242
|
+
tmpResult.executed = true;
|
|
243
|
+
return fCallback();
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
var Count = function (pQuery, fCallback)
|
|
250
|
+
{
|
|
251
|
+
var tmpResult = pQuery.parameters.result;
|
|
252
|
+
|
|
253
|
+
pQuery.setDialect('MSSQL').buildCountQuery();
|
|
254
|
+
|
|
255
|
+
if (pQuery.logLevel > 0 ||
|
|
256
|
+
_GlobalLogLevel > 0)
|
|
257
|
+
{
|
|
258
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
262
|
+
{
|
|
263
|
+
pDBConnection.query(
|
|
264
|
+
pQuery.query.body,
|
|
265
|
+
pQuery.query.parameters,
|
|
266
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
267
|
+
function (pError, pRows)
|
|
268
|
+
{
|
|
269
|
+
pDBConnection.release();
|
|
270
|
+
tmpResult.executed = true;
|
|
271
|
+
tmpResult.error = pError;
|
|
272
|
+
tmpResult.value = false;
|
|
273
|
+
try
|
|
274
|
+
{
|
|
275
|
+
tmpResult.value = pRows[0].RowCount;
|
|
276
|
+
}
|
|
277
|
+
catch (pErrorGettingRowcount)
|
|
278
|
+
{
|
|
279
|
+
_Fable.log.warn('Error getting rowcount during count query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
280
|
+
}
|
|
281
|
+
return fCallback();
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
var tmpNewProvider = (
|
|
288
|
+
{
|
|
289
|
+
marshalRecordFromSourceToObject: marshalRecordFromSourceToObject,
|
|
290
|
+
|
|
291
|
+
Create: Create,
|
|
292
|
+
Read: Read,
|
|
293
|
+
Update: Update,
|
|
294
|
+
Delete: Delete,
|
|
295
|
+
Undelete: Undelete,
|
|
296
|
+
Count: Count,
|
|
297
|
+
|
|
298
|
+
new: createNew
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
return tmpNewProvider;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return createNew();
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
module.exports = new MeadowProvider();
|
|
@@ -3,37 +3,37 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
|
-
var MeadowProvider = function()
|
|
6
|
+
var MeadowProvider = function ()
|
|
7
7
|
{
|
|
8
8
|
function createNew(pFable)
|
|
9
9
|
{
|
|
10
10
|
// If a valid Fable object isn't passed in, return a constructor
|
|
11
|
-
if (typeof(pFable) !== 'object')
|
|
11
|
+
if (typeof (pFable) !== 'object')
|
|
12
12
|
{
|
|
13
|
-
return {new: createNew};
|
|
13
|
+
return { new: createNew };
|
|
14
14
|
}
|
|
15
15
|
var _Fable = pFable;
|
|
16
16
|
var _GlobalLogLevel = 0;
|
|
17
17
|
if (_Fable.settings.MySQL)
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
_GlobalLogLevel = _Fable.settings.MySQL.GlobalLogLevel || 0;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
/**
|
|
23
23
|
* Build a connection pool, shared within this provider.
|
|
24
24
|
* This may be more performant as a shared object.
|
|
25
25
|
*/
|
|
26
|
-
var getSQLPool = function()
|
|
26
|
+
var getSQLPool = function ()
|
|
27
27
|
{
|
|
28
28
|
let tmpSqlPool = false;
|
|
29
|
-
if (typeof(_Fable.MeadowMySQLConnectionPool) == 'object')
|
|
29
|
+
if (typeof (_Fable.MeadowMySQLConnectionPool) == 'object')
|
|
30
30
|
{
|
|
31
31
|
// This is where the old-style SQL Connection pool is. Refactor doesn't even look for it anymore
|
|
32
32
|
return _Fable.MeadowMySQLConnectionPool;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// New-style default connection pool provider
|
|
36
|
-
if (typeof(_Fable.MeadowMySQLProvider) == 'object' && _Fable.MeadowMySQLProvider.connected)
|
|
36
|
+
if (typeof (_Fable.MeadowMySQLProvider) == 'object' && _Fable.MeadowMySQLProvider.connected)
|
|
37
37
|
{
|
|
38
38
|
return _Fable.MeadowMySQLProvider.pool;
|
|
39
39
|
}
|
|
@@ -42,17 +42,17 @@ var MeadowProvider = function()
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
// The Meadow marshaller also passes in the Schema as the third parameter, but this is a blunt function ATM.
|
|
45
|
-
var marshalRecordFromSourceToObject = function(pObject, pRecord)
|
|
45
|
+
var marshalRecordFromSourceToObject = function (pObject, pRecord)
|
|
46
46
|
{
|
|
47
47
|
// For now, crudely assign everything in pRecord to pObject
|
|
48
48
|
// This is safe in this context, and we don't want to slow down marshalling with millions of hasOwnProperty checks
|
|
49
|
-
for(var tmpColumn in pRecord)
|
|
49
|
+
for (var tmpColumn in pRecord)
|
|
50
50
|
{
|
|
51
51
|
pObject[tmpColumn] = pRecord[tmpColumn];
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
var Create = function(pQuery, fCallback)
|
|
55
|
+
var Create = function (pQuery, fCallback)
|
|
56
56
|
{
|
|
57
57
|
var tmpResult = pQuery.parameters.result;
|
|
58
58
|
|
|
@@ -65,13 +65,13 @@ var MeadowProvider = function()
|
|
|
65
65
|
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
getSQLPool().getConnection(function(pError, pDBConnection)
|
|
68
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
69
69
|
{
|
|
70
70
|
pDBConnection.query(
|
|
71
71
|
pQuery.query.body,
|
|
72
72
|
pQuery.query.parameters,
|
|
73
73
|
// The MySQL library also returns the Fields as the third parameter
|
|
74
|
-
function(pError, pRows)
|
|
74
|
+
function (pError, pRows)
|
|
75
75
|
{
|
|
76
76
|
pDBConnection.release();
|
|
77
77
|
tmpResult.error = pError;
|
|
@@ -80,9 +80,9 @@ var MeadowProvider = function()
|
|
|
80
80
|
{
|
|
81
81
|
tmpResult.value = pRows.insertId;
|
|
82
82
|
}
|
|
83
|
-
catch(pErrorGettingRowcount)
|
|
83
|
+
catch (pErrorGettingRowcount)
|
|
84
84
|
{
|
|
85
|
-
_Fable.log.warn('Error getting insert ID during create query',{Body:pQuery.query.body, Parameters:pQuery.query.parameters});
|
|
85
|
+
_Fable.log.warn('Error getting insert ID during create query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
tmpResult.executed = true;
|
|
@@ -94,7 +94,7 @@ var MeadowProvider = function()
|
|
|
94
94
|
|
|
95
95
|
// This is a synchronous read, good for a few records.
|
|
96
96
|
// TODO: Add a pipe-able read for huge sets
|
|
97
|
-
var Read = function(pQuery, fCallback)
|
|
97
|
+
var Read = function (pQuery, fCallback)
|
|
98
98
|
{
|
|
99
99
|
var tmpResult = pQuery.parameters.result;
|
|
100
100
|
|
|
@@ -106,13 +106,13 @@ var MeadowProvider = function()
|
|
|
106
106
|
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
getSQLPool().getConnection(function(pError, pDBConnection)
|
|
109
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
110
110
|
{
|
|
111
111
|
pDBConnection.query(
|
|
112
112
|
pQuery.query.body,
|
|
113
113
|
pQuery.query.parameters,
|
|
114
114
|
// The MySQL library also returns the Fields as the third parameter
|
|
115
|
-
function(pError, pRows)
|
|
115
|
+
function (pError, pRows)
|
|
116
116
|
{
|
|
117
117
|
pDBConnection.release();
|
|
118
118
|
tmpResult.error = pError;
|
|
@@ -124,7 +124,7 @@ var MeadowProvider = function()
|
|
|
124
124
|
});
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
var Update = function(pQuery, fCallback)
|
|
127
|
+
var Update = function (pQuery, fCallback)
|
|
128
128
|
{
|
|
129
129
|
var tmpResult = pQuery.parameters.result;
|
|
130
130
|
|
|
@@ -136,13 +136,13 @@ var MeadowProvider = function()
|
|
|
136
136
|
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
getSQLPool().getConnection(function(pError, pDBConnection)
|
|
139
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
140
140
|
{
|
|
141
141
|
pDBConnection.query(
|
|
142
142
|
pQuery.query.body,
|
|
143
143
|
pQuery.query.parameters,
|
|
144
144
|
// The MySQL library also returns the Fields as the third parameter
|
|
145
|
-
function(pError, pRows)
|
|
145
|
+
function (pError, pRows)
|
|
146
146
|
{
|
|
147
147
|
pDBConnection.release();
|
|
148
148
|
tmpResult.error = pError;
|
|
@@ -154,7 +154,7 @@ var MeadowProvider = function()
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
var Delete = function(pQuery, fCallback)
|
|
157
|
+
var Delete = function (pQuery, fCallback)
|
|
158
158
|
{
|
|
159
159
|
var tmpResult = pQuery.parameters.result;
|
|
160
160
|
|
|
@@ -166,34 +166,34 @@ var MeadowProvider = function()
|
|
|
166
166
|
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
getSQLPool().getConnection(function(pError, pDBConnection)
|
|
169
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
170
170
|
{
|
|
171
171
|
pDBConnection.query
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
{
|
|
178
|
-
pDBConnection.release();
|
|
179
|
-
tmpResult.error = pError;
|
|
180
|
-
tmpResult.value = false;
|
|
181
|
-
try
|
|
182
|
-
{
|
|
183
|
-
tmpResult.value = pRows.affectedRows;
|
|
184
|
-
}
|
|
185
|
-
catch(pErrorGettingRowcount)
|
|
172
|
+
(
|
|
173
|
+
pQuery.query.body,
|
|
174
|
+
pQuery.query.parameters,
|
|
175
|
+
// The MySQL library also returns the Fields as the third parameter
|
|
176
|
+
function (pError, pRows)
|
|
186
177
|
{
|
|
187
|
-
|
|
178
|
+
pDBConnection.release();
|
|
179
|
+
tmpResult.error = pError;
|
|
180
|
+
tmpResult.value = false;
|
|
181
|
+
try
|
|
182
|
+
{
|
|
183
|
+
tmpResult.value = pRows.affectedRows;
|
|
184
|
+
}
|
|
185
|
+
catch (pErrorGettingRowcount)
|
|
186
|
+
{
|
|
187
|
+
_Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
188
|
+
}
|
|
189
|
+
tmpResult.executed = true;
|
|
190
|
+
return fCallback();
|
|
188
191
|
}
|
|
189
|
-
|
|
190
|
-
return fCallback();
|
|
191
|
-
}
|
|
192
|
-
);
|
|
192
|
+
);
|
|
193
193
|
});
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
var Undelete = function(pQuery, fCallback)
|
|
196
|
+
var Undelete = function (pQuery, fCallback)
|
|
197
197
|
{
|
|
198
198
|
var tmpResult = pQuery.parameters.result;
|
|
199
199
|
|
|
@@ -205,34 +205,34 @@ var MeadowProvider = function()
|
|
|
205
205
|
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
getSQLPool().getConnection(function(pError, pDBConnection)
|
|
208
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
209
209
|
{
|
|
210
210
|
pDBConnection.query
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
{
|
|
217
|
-
pDBConnection.release();
|
|
218
|
-
tmpResult.error = pError;
|
|
219
|
-
tmpResult.value = false;
|
|
220
|
-
try
|
|
221
|
-
{
|
|
222
|
-
tmpResult.value = pRows.affectedRows;
|
|
223
|
-
}
|
|
224
|
-
catch(pErrorGettingRowcount)
|
|
211
|
+
(
|
|
212
|
+
pQuery.query.body,
|
|
213
|
+
pQuery.query.parameters,
|
|
214
|
+
// The MySQL library also returns the Fields as the third parameter
|
|
215
|
+
function (pError, pRows)
|
|
225
216
|
{
|
|
226
|
-
|
|
217
|
+
pDBConnection.release();
|
|
218
|
+
tmpResult.error = pError;
|
|
219
|
+
tmpResult.value = false;
|
|
220
|
+
try
|
|
221
|
+
{
|
|
222
|
+
tmpResult.value = pRows.affectedRows;
|
|
223
|
+
}
|
|
224
|
+
catch (pErrorGettingRowcount)
|
|
225
|
+
{
|
|
226
|
+
_Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
227
|
+
}
|
|
228
|
+
tmpResult.executed = true;
|
|
229
|
+
return fCallback();
|
|
227
230
|
}
|
|
228
|
-
|
|
229
|
-
return fCallback();
|
|
230
|
-
}
|
|
231
|
-
);
|
|
231
|
+
);
|
|
232
232
|
});
|
|
233
233
|
};
|
|
234
234
|
|
|
235
|
-
var Count = function(pQuery, fCallback)
|
|
235
|
+
var Count = function (pQuery, fCallback)
|
|
236
236
|
{
|
|
237
237
|
var tmpResult = pQuery.parameters.result;
|
|
238
238
|
|
|
@@ -244,13 +244,13 @@ var MeadowProvider = function()
|
|
|
244
244
|
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
getSQLPool().getConnection(function(pError, pDBConnection)
|
|
247
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
248
248
|
{
|
|
249
249
|
pDBConnection.query(
|
|
250
250
|
pQuery.query.body,
|
|
251
251
|
pQuery.query.parameters,
|
|
252
252
|
// The MySQL library also returns the Fields as the third parameter
|
|
253
|
-
function(pError, pRows)
|
|
253
|
+
function (pError, pRows)
|
|
254
254
|
{
|
|
255
255
|
pDBConnection.release();
|
|
256
256
|
tmpResult.executed = true;
|
|
@@ -260,9 +260,9 @@ var MeadowProvider = function()
|
|
|
260
260
|
{
|
|
261
261
|
tmpResult.value = pRows[0].RowCount;
|
|
262
262
|
}
|
|
263
|
-
catch(pErrorGettingRowcount)
|
|
263
|
+
catch (pErrorGettingRowcount)
|
|
264
264
|
{
|
|
265
|
-
_Fable.log.warn('Error getting rowcount during count query',{Body:pQuery.query.body, Parameters:pQuery.query.parameters});
|
|
265
|
+
_Fable.log.warn('Error getting rowcount during count query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
266
266
|
}
|
|
267
267
|
return fCallback();
|
|
268
268
|
}
|
|
@@ -271,18 +271,18 @@ var MeadowProvider = function()
|
|
|
271
271
|
};
|
|
272
272
|
|
|
273
273
|
var tmpNewProvider = (
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
{
|
|
275
|
+
marshalRecordFromSourceToObject: marshalRecordFromSourceToObject,
|
|
276
276
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
277
|
+
Create: Create,
|
|
278
|
+
Read: Read,
|
|
279
|
+
Update: Update,
|
|
280
|
+
Delete: Delete,
|
|
281
|
+
Undelete: Undelete,
|
|
282
|
+
Count: Count,
|
|
283
283
|
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
new: createNew
|
|
285
|
+
});
|
|
286
286
|
|
|
287
287
|
|
|
288
288
|
return tmpNewProvider;
|