meadow 2.0.41 → 2.0.43
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/README.md +19 -17
- package/docs/_cover.md +1 -1
- package/docs/_topbar.md +1 -1
- package/docs/_version.json +2 -2
- package/docs/providers/README.md +9 -9
- package/docs/providers/alasql.md +3 -3
- package/docs/providers/meadow-endpoints.md +6 -6
- package/docs/providers/mongodb.md +5 -5
- package/docs/providers/mssql.md +3 -3
- package/docs/providers/mysql.md +3 -3
- package/docs/providers/postgresql.md +5 -5
- package/docs/providers/rocksdb.md +4 -4
- package/docs/providers/sqlite.md +4 -4
- package/docs/query/README.md +1 -1
- package/docs/query-dsl.md +1 -1
- package/docs/quick-start.md +1 -1
- package/docs/retold-catalog.json +302 -213
- package/docs/retold-keyword-index.json +18147 -13014
- package/package.json +17 -10
- package/scripts/bookstore-seed.js +136 -1
- package/scripts/meadow-test-cleanup.sh +1 -0
- package/scripts/oracle-test-db.sh +128 -0
- package/source/Meadow.js +1 -0
- package/source/providers/Meadow-Provider-ALASQL.js +1 -1
- package/source/providers/Meadow-Provider-Oracle.js +463 -0
- package/test/Meadow-Provider-Oracle_tests.js +877 -0
|
@@ -0,0 +1,463 @@
|
|
|
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.Oracle)
|
|
18
|
+
{
|
|
19
|
+
_GlobalLogLevel = _Fable.settings.Oracle.GlobalLogLevel || 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the connection provider (set up by meadow-connection-oracle
|
|
24
|
+
* and registered on Fable as MeadowOracleProvider).
|
|
25
|
+
*/
|
|
26
|
+
var getProvider = function ()
|
|
27
|
+
{
|
|
28
|
+
if (typeof (_Fable.MeadowOracleProvider) == 'object' && _Fable.MeadowOracleProvider.connected)
|
|
29
|
+
{
|
|
30
|
+
return _Fable.MeadowOracleProvider;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Propagate Oracle dialect flags (legacyPagination, quoteIdentifiers)
|
|
37
|
+
* from configuration onto the FoxHound query parameters so the dialect
|
|
38
|
+
* emits the right SQL. Honors both fable.settings.Oracle and the live
|
|
39
|
+
* connection provider's resolved options.
|
|
40
|
+
*/
|
|
41
|
+
var applyOracleParameters = function (pQuery)
|
|
42
|
+
{
|
|
43
|
+
if (_Fable.settings.Oracle)
|
|
44
|
+
{
|
|
45
|
+
if (_Fable.settings.Oracle.LegacyPagination) pQuery.parameters.legacyPagination = true;
|
|
46
|
+
if (_Fable.settings.Oracle.QuoteIdentifiers) pQuery.parameters.quoteIdentifiers = true;
|
|
47
|
+
}
|
|
48
|
+
var tmpProvider = (typeof (_Fable.MeadowOracleProvider) == 'object') ? _Fable.MeadowOracleProvider : false;
|
|
49
|
+
if (tmpProvider && tmpProvider.options && tmpProvider.options.Oracle)
|
|
50
|
+
{
|
|
51
|
+
if (tmpProvider.options.Oracle.LegacyPagination) pQuery.parameters.legacyPagination = true;
|
|
52
|
+
if (tmpProvider.options.Oracle.QuoteIdentifiers) pQuery.parameters.quoteIdentifiers = true;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Find the AutoIdentity column on the query's schema, if any. Used to
|
|
58
|
+
* register the RETURNING out-bind and read back the generated key.
|
|
59
|
+
*/
|
|
60
|
+
var findAutoIdentityColumn = function (pQuery)
|
|
61
|
+
{
|
|
62
|
+
var tmpSchema = Array.isArray(pQuery.query.schema) ? pQuery.query.schema : [];
|
|
63
|
+
for (var i = 0; i < tmpSchema.length; i++)
|
|
64
|
+
{
|
|
65
|
+
if (tmpSchema[i].Type === 'AutoIdentity')
|
|
66
|
+
{
|
|
67
|
+
return tmpSchema[i].Column;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Translate the dialect's string parameterTypes into an oracledb bind
|
|
75
|
+
* object. oracledb infers scalar types from JS values, so we only need
|
|
76
|
+
* to be explicit for CLOB (large Text/JSON, which would otherwise error
|
|
77
|
+
* or truncate) and for the RETURNING out-bind.
|
|
78
|
+
*/
|
|
79
|
+
var buildBinds = function (pQuery, pOracleDB, pIncludeReturning)
|
|
80
|
+
{
|
|
81
|
+
var tmpBinds = {};
|
|
82
|
+
var tmpParameters = pQuery.query.parameters || {};
|
|
83
|
+
var tmpParameterTypes = pQuery.query.parameterTypes || {};
|
|
84
|
+
for (var tmpName in tmpParameters)
|
|
85
|
+
{
|
|
86
|
+
if (tmpParameterTypes[tmpName] === 'CLOB')
|
|
87
|
+
{
|
|
88
|
+
tmpBinds[tmpName] = { val: tmpParameters[tmpName], type: pOracleDB.CLOB };
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
{
|
|
92
|
+
tmpBinds[tmpName] = tmpParameters[tmpName];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (pIncludeReturning)
|
|
96
|
+
{
|
|
97
|
+
tmpBinds.RETURNING_ID = { dir: pOracleDB.BIND_OUT, type: pOracleDB.NUMBER };
|
|
98
|
+
}
|
|
99
|
+
return tmpBinds;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Acquire a pooled connection, run a statement with autoCommit, and
|
|
104
|
+
* always release the connection.
|
|
105
|
+
*/
|
|
106
|
+
var executeStatement = function (pSQL, pBinds, fCallback)
|
|
107
|
+
{
|
|
108
|
+
var tmpProvider = getProvider();
|
|
109
|
+
if (!tmpProvider)
|
|
110
|
+
{
|
|
111
|
+
return fCallback(new Error('Meadow Oracle provider is not connected.'));
|
|
112
|
+
}
|
|
113
|
+
var libOracleDB = tmpProvider.oracledb;
|
|
114
|
+
tmpProvider.getConnection(function (pConnectionError, pConnection)
|
|
115
|
+
{
|
|
116
|
+
if (pConnectionError)
|
|
117
|
+
{
|
|
118
|
+
return fCallback(pConnectionError);
|
|
119
|
+
}
|
|
120
|
+
pConnection.execute(pSQL, pBinds, { autoCommit: true, outFormat: libOracleDB.OUT_FORMAT_OBJECT })
|
|
121
|
+
.then(function (pResult)
|
|
122
|
+
{
|
|
123
|
+
pConnection.close()
|
|
124
|
+
.then(function () { return fCallback(null, pResult); })
|
|
125
|
+
.catch(function () { return fCallback(null, pResult); });
|
|
126
|
+
})
|
|
127
|
+
.catch(function (pError)
|
|
128
|
+
{
|
|
129
|
+
pConnection.close()
|
|
130
|
+
.then(function () { return fCallback(pError); })
|
|
131
|
+
.catch(function () { return fCallback(pError); });
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// The Meadow marshaller passes in the Schema as the third parameter for
|
|
137
|
+
// JSON/JSONProxy deserialization and (for Oracle) for remapping the
|
|
138
|
+
// data-dictionary's UPPERCASE column keys back to the schema's casing.
|
|
139
|
+
var marshalRecordFromSourceToObject = function (pObject, pRecord, pSchema)
|
|
140
|
+
{
|
|
141
|
+
var tmpJsonColumns = {};
|
|
142
|
+
var tmpProxyColumns = {};
|
|
143
|
+
// Map UPPER(columnName) -> canonical column name so unquoted-mode
|
|
144
|
+
// rows (which come back uppercased) resolve to the schema casing.
|
|
145
|
+
// In quoteIdentifiers mode names already match — the lookup is a no-op.
|
|
146
|
+
var tmpColumnNameByUpper = {};
|
|
147
|
+
if (Array.isArray(pSchema))
|
|
148
|
+
{
|
|
149
|
+
for (var s = 0; s < pSchema.length; s++)
|
|
150
|
+
{
|
|
151
|
+
if (pSchema[s].Column)
|
|
152
|
+
{
|
|
153
|
+
tmpColumnNameByUpper[pSchema[s].Column.toUpperCase()] = pSchema[s].Column;
|
|
154
|
+
}
|
|
155
|
+
if (pSchema[s].Type === 'JSON')
|
|
156
|
+
{
|
|
157
|
+
tmpJsonColumns[pSchema[s].Column] = true;
|
|
158
|
+
}
|
|
159
|
+
else if (pSchema[s].Type === 'JSONProxy' && pSchema[s].StorageColumn)
|
|
160
|
+
{
|
|
161
|
+
tmpProxyColumns[pSchema[s].StorageColumn] = pSchema[s].Column;
|
|
162
|
+
tmpColumnNameByUpper[pSchema[s].StorageColumn.toUpperCase()] = pSchema[s].StorageColumn;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
for (var tmpRawColumn in pRecord)
|
|
168
|
+
{
|
|
169
|
+
var tmpColumn = tmpColumnNameByUpper[tmpRawColumn.toUpperCase()] || tmpRawColumn;
|
|
170
|
+
|
|
171
|
+
if (tmpJsonColumns[tmpColumn])
|
|
172
|
+
{
|
|
173
|
+
try
|
|
174
|
+
{
|
|
175
|
+
pObject[tmpColumn] = (typeof pRecord[tmpRawColumn] === 'string')
|
|
176
|
+
? JSON.parse(pRecord[tmpRawColumn])
|
|
177
|
+
: (pRecord[tmpRawColumn] || {});
|
|
178
|
+
}
|
|
179
|
+
catch (pParseError)
|
|
180
|
+
{
|
|
181
|
+
pObject[tmpColumn] = {};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else if (tmpProxyColumns.hasOwnProperty(tmpColumn))
|
|
185
|
+
{
|
|
186
|
+
var tmpVirtualColumn = tmpProxyColumns[tmpColumn];
|
|
187
|
+
try
|
|
188
|
+
{
|
|
189
|
+
pObject[tmpVirtualColumn] = (typeof pRecord[tmpRawColumn] === 'string')
|
|
190
|
+
? JSON.parse(pRecord[tmpRawColumn])
|
|
191
|
+
: (pRecord[tmpRawColumn] || {});
|
|
192
|
+
}
|
|
193
|
+
catch (pParseError)
|
|
194
|
+
{
|
|
195
|
+
pObject[tmpVirtualColumn] = {};
|
|
196
|
+
}
|
|
197
|
+
// Do NOT copy the storage column to the output object
|
|
198
|
+
}
|
|
199
|
+
else
|
|
200
|
+
{
|
|
201
|
+
pObject[tmpColumn] = pRecord[tmpRawColumn];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
var Create = function (pQuery, fCallback)
|
|
207
|
+
{
|
|
208
|
+
var tmpResult = pQuery.parameters.result;
|
|
209
|
+
|
|
210
|
+
applyOracleParameters(pQuery);
|
|
211
|
+
pQuery.setDialect('Oracle').buildCreateQuery();
|
|
212
|
+
|
|
213
|
+
if (pQuery.logLevel > 0 || _GlobalLogLevel > 0)
|
|
214
|
+
{
|
|
215
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
var tmpProvider = getProvider();
|
|
219
|
+
if (!tmpProvider)
|
|
220
|
+
{
|
|
221
|
+
tmpResult.error = new Error('Meadow Oracle provider is not connected.');
|
|
222
|
+
tmpResult.executed = true;
|
|
223
|
+
return fCallback();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// The dialect appends RETURNING <ID> INTO :RETURNING_ID when there
|
|
227
|
+
// is an AutoIdentity column and auto-identity is not disabled.
|
|
228
|
+
var tmpHasReturning = !pQuery.query.disableAutoIdentity && (findAutoIdentityColumn(pQuery) !== false);
|
|
229
|
+
var tmpBinds = buildBinds(pQuery, tmpProvider.oracledb, tmpHasReturning);
|
|
230
|
+
|
|
231
|
+
executeStatement(pQuery.query.body, tmpBinds, function (pError, pDBResult)
|
|
232
|
+
{
|
|
233
|
+
tmpResult.error = pError;
|
|
234
|
+
tmpResult.value = false;
|
|
235
|
+
try
|
|
236
|
+
{
|
|
237
|
+
if (!pError && pDBResult && pDBResult.outBinds && Array.isArray(pDBResult.outBinds.RETURNING_ID) && pDBResult.outBinds.RETURNING_ID.length > 0)
|
|
238
|
+
{
|
|
239
|
+
tmpResult.value = pDBResult.outBinds.RETURNING_ID[0];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (pErrorGettingID)
|
|
243
|
+
{
|
|
244
|
+
_Fable.log.warn('Error getting insert ID during create query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
245
|
+
}
|
|
246
|
+
tmpResult.executed = true;
|
|
247
|
+
return fCallback();
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
var Read = function (pQuery, fCallback)
|
|
252
|
+
{
|
|
253
|
+
var tmpResult = pQuery.parameters.result;
|
|
254
|
+
|
|
255
|
+
applyOracleParameters(pQuery);
|
|
256
|
+
pQuery.setDialect('Oracle').buildReadQuery();
|
|
257
|
+
|
|
258
|
+
if (pQuery.logLevel > 0 || _GlobalLogLevel > 0)
|
|
259
|
+
{
|
|
260
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
var tmpProvider = getProvider();
|
|
264
|
+
if (!tmpProvider)
|
|
265
|
+
{
|
|
266
|
+
tmpResult.error = new Error('Meadow Oracle provider is not connected.');
|
|
267
|
+
tmpResult.value = [];
|
|
268
|
+
tmpResult.executed = true;
|
|
269
|
+
return fCallback();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
var tmpBinds = buildBinds(pQuery, tmpProvider.oracledb, false);
|
|
273
|
+
|
|
274
|
+
executeStatement(pQuery.query.body, tmpBinds, function (pError, pDBResult)
|
|
275
|
+
{
|
|
276
|
+
tmpResult.error = pError;
|
|
277
|
+
tmpResult.value = (pDBResult && pDBResult.rows) ? pDBResult.rows : [];
|
|
278
|
+
tmpResult.executed = true;
|
|
279
|
+
return fCallback();
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
var Update = function (pQuery, fCallback)
|
|
284
|
+
{
|
|
285
|
+
var tmpResult = pQuery.parameters.result;
|
|
286
|
+
|
|
287
|
+
applyOracleParameters(pQuery);
|
|
288
|
+
pQuery.setDialect('Oracle').buildUpdateQuery();
|
|
289
|
+
|
|
290
|
+
if (pQuery.logLevel > 0 || _GlobalLogLevel > 0)
|
|
291
|
+
{
|
|
292
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
var tmpProvider = getProvider();
|
|
296
|
+
if (!tmpProvider)
|
|
297
|
+
{
|
|
298
|
+
tmpResult.error = new Error('Meadow Oracle provider is not connected.');
|
|
299
|
+
tmpResult.executed = true;
|
|
300
|
+
return fCallback();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
var tmpBinds = buildBinds(pQuery, tmpProvider.oracledb, false);
|
|
304
|
+
|
|
305
|
+
executeStatement(pQuery.query.body, tmpBinds, function (pError, pDBResult)
|
|
306
|
+
{
|
|
307
|
+
tmpResult.error = pError;
|
|
308
|
+
// The Meadow Update behavior requires result.value to be an
|
|
309
|
+
// object; oracledb's UPDATE result has no rows array (no
|
|
310
|
+
// RETURNING), so mirror the PostgreSQL provider and expose an
|
|
311
|
+
// (empty) array. The post-update Read supplies the record.
|
|
312
|
+
tmpResult.value = (pDBResult && pDBResult.rows) ? pDBResult.rows : [];
|
|
313
|
+
tmpResult.executed = true;
|
|
314
|
+
return fCallback();
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
var Delete = function (pQuery, fCallback)
|
|
319
|
+
{
|
|
320
|
+
var tmpResult = pQuery.parameters.result;
|
|
321
|
+
|
|
322
|
+
applyOracleParameters(pQuery);
|
|
323
|
+
pQuery.setDialect('Oracle').buildDeleteQuery();
|
|
324
|
+
|
|
325
|
+
if (pQuery.logLevel > 0 || _GlobalLogLevel > 0)
|
|
326
|
+
{
|
|
327
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
var tmpProvider = getProvider();
|
|
331
|
+
if (!tmpProvider)
|
|
332
|
+
{
|
|
333
|
+
tmpResult.error = new Error('Meadow Oracle provider is not connected.');
|
|
334
|
+
tmpResult.executed = true;
|
|
335
|
+
return fCallback();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
var tmpBinds = buildBinds(pQuery, tmpProvider.oracledb, false);
|
|
339
|
+
|
|
340
|
+
executeStatement(pQuery.query.body, tmpBinds, function (pError, pDBResult)
|
|
341
|
+
{
|
|
342
|
+
tmpResult.error = pError;
|
|
343
|
+
tmpResult.value = false;
|
|
344
|
+
try
|
|
345
|
+
{
|
|
346
|
+
tmpResult.value = pDBResult ? pDBResult.rowsAffected : 0;
|
|
347
|
+
}
|
|
348
|
+
catch (pErrorGettingRowcount)
|
|
349
|
+
{
|
|
350
|
+
_Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
351
|
+
}
|
|
352
|
+
tmpResult.executed = true;
|
|
353
|
+
return fCallback();
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
var Undelete = function (pQuery, fCallback)
|
|
358
|
+
{
|
|
359
|
+
var tmpResult = pQuery.parameters.result;
|
|
360
|
+
|
|
361
|
+
applyOracleParameters(pQuery);
|
|
362
|
+
pQuery.setDialect('Oracle').buildUndeleteQuery();
|
|
363
|
+
|
|
364
|
+
if (pQuery.logLevel > 0 || _GlobalLogLevel > 0)
|
|
365
|
+
{
|
|
366
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
var tmpProvider = getProvider();
|
|
370
|
+
if (!tmpProvider)
|
|
371
|
+
{
|
|
372
|
+
tmpResult.error = new Error('Meadow Oracle provider is not connected.');
|
|
373
|
+
tmpResult.executed = true;
|
|
374
|
+
return fCallback();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
var tmpBinds = buildBinds(pQuery, tmpProvider.oracledb, false);
|
|
378
|
+
|
|
379
|
+
executeStatement(pQuery.query.body, tmpBinds, function (pError, pDBResult)
|
|
380
|
+
{
|
|
381
|
+
tmpResult.error = pError;
|
|
382
|
+
tmpResult.value = false;
|
|
383
|
+
try
|
|
384
|
+
{
|
|
385
|
+
tmpResult.value = pDBResult ? pDBResult.rowsAffected : 0;
|
|
386
|
+
}
|
|
387
|
+
catch (pErrorGettingRowcount)
|
|
388
|
+
{
|
|
389
|
+
_Fable.log.warn('Error getting affected rowcount during undelete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
390
|
+
}
|
|
391
|
+
tmpResult.executed = true;
|
|
392
|
+
return fCallback();
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
var Count = function (pQuery, fCallback)
|
|
397
|
+
{
|
|
398
|
+
var tmpResult = pQuery.parameters.result;
|
|
399
|
+
|
|
400
|
+
applyOracleParameters(pQuery);
|
|
401
|
+
pQuery.setDialect('Oracle').buildCountQuery();
|
|
402
|
+
|
|
403
|
+
if (pQuery.logLevel > 0 || _GlobalLogLevel > 0)
|
|
404
|
+
{
|
|
405
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
var tmpProvider = getProvider();
|
|
409
|
+
if (!tmpProvider)
|
|
410
|
+
{
|
|
411
|
+
tmpResult.error = new Error('Meadow Oracle provider is not connected.');
|
|
412
|
+
tmpResult.executed = true;
|
|
413
|
+
return fCallback();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
var tmpBinds = buildBinds(pQuery, tmpProvider.oracledb, false);
|
|
417
|
+
|
|
418
|
+
executeStatement(pQuery.query.body, tmpBinds, function (pError, pDBResult)
|
|
419
|
+
{
|
|
420
|
+
tmpResult.executed = true;
|
|
421
|
+
tmpResult.error = pError;
|
|
422
|
+
tmpResult.value = false;
|
|
423
|
+
try
|
|
424
|
+
{
|
|
425
|
+
// The COUNT column alias casing depends on quoting mode, so
|
|
426
|
+
// read the first (only) column of the first row by position.
|
|
427
|
+
var tmpRow = pDBResult.rows[0];
|
|
428
|
+
var tmpKey = Object.keys(tmpRow)[0];
|
|
429
|
+
tmpResult.value = parseInt(tmpRow[tmpKey], 10);
|
|
430
|
+
}
|
|
431
|
+
catch (pErrorGettingRowcount)
|
|
432
|
+
{
|
|
433
|
+
_Fable.log.warn('Error getting rowcount during count query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
434
|
+
}
|
|
435
|
+
return fCallback();
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
var tmpNewProvider = (
|
|
440
|
+
{
|
|
441
|
+
marshalRecordFromSourceToObject: marshalRecordFromSourceToObject,
|
|
442
|
+
|
|
443
|
+
Create: Create,
|
|
444
|
+
Read: Read,
|
|
445
|
+
Update: Update,
|
|
446
|
+
Delete: Delete,
|
|
447
|
+
Undelete: Undelete,
|
|
448
|
+
Count: Count,
|
|
449
|
+
|
|
450
|
+
getProvider: getProvider,
|
|
451
|
+
providerCreatesSupported: true,
|
|
452
|
+
|
|
453
|
+
new: createNew
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
return tmpNewProvider;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return createNew();
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
module.exports = new MeadowProvider();
|