foxhound 2.0.0 → 2.0.1
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/dist/foxhound.js +2713 -2723
- package/dist/foxhound.min.js +3 -6
- package/dist/foxhound.min.js.map +1 -1
- package/package.json +2 -3
- package/source/FoxHound.js +12 -24
- package/source/Foxhound-Dialects.js +15 -0
- package/source/dialects/ALASQL/FoxHound-Dialect-ALASQL.js +9 -5
- package/source/dialects/English/FoxHound-Dialect-English.js +1 -1
- package/source/dialects/MeadowEndpoints/FoxHound-Dialect-MeadowEndpoints.js +1 -2
- package/source/dialects/MySQL/FoxHound-Dialect-MySQL.js +6 -5
- package/test/FoxHound-Dialect-ALASQL_tests.js +77 -76
- package/test/FoxHound-Dialect-English_tests.js +15 -14
- package/test/FoxHound-Dialect-MeadowEndpoints_tests.js +51 -50
- package/test/FoxHound-Dialect-MySQL_tests.js +81 -80
- package/test/FoxHound_tests.js +24 -23
|
@@ -10,7 +10,8 @@ var Chai = require('chai');
|
|
|
10
10
|
var Expect = Chai.expect;
|
|
11
11
|
var Assert = Chai.assert;
|
|
12
12
|
|
|
13
|
-
var libFable =
|
|
13
|
+
var libFable = require('fable');
|
|
14
|
+
const _Fable = new libFable({Product:'FoxhoundTestsMySQL'});
|
|
14
15
|
var libFoxHound = require('../source/FoxHound.js');
|
|
15
16
|
|
|
16
17
|
var _AnimalSchema = (
|
|
@@ -58,7 +59,7 @@ suite
|
|
|
58
59
|
'initialize should build a happy little object',
|
|
59
60
|
function()
|
|
60
61
|
{
|
|
61
|
-
var testFoxHound = libFoxHound.new(
|
|
62
|
+
var testFoxHound = libFoxHound.new(_Fable).setDialect('MySQL');
|
|
62
63
|
Expect(testFoxHound.dialect.name)
|
|
63
64
|
.to.equal('MySQL');
|
|
64
65
|
Expect(testFoxHound)
|
|
@@ -78,7 +79,7 @@ suite
|
|
|
78
79
|
'Create Query',
|
|
79
80
|
function()
|
|
80
81
|
{
|
|
81
|
-
var tmpQuery = libFoxHound.new(
|
|
82
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
82
83
|
.setLogLevel(5)
|
|
83
84
|
.setDialect('MySQL')
|
|
84
85
|
.setScope('Animal')
|
|
@@ -86,7 +87,7 @@ suite
|
|
|
86
87
|
// Build the query
|
|
87
88
|
tmpQuery.buildCreateQuery();
|
|
88
89
|
// This is the query generated by the MySQL dialect
|
|
89
|
-
|
|
90
|
+
_Fable.log.trace('Create Query', tmpQuery.query);
|
|
90
91
|
Expect(tmpQuery.query.body)
|
|
91
92
|
.to.equal("INSERT INTO `Animal` ( IDAnimal, Name, Age) VALUES ( :IDAnimal_0, :Name_1, :Age_2);");
|
|
92
93
|
}
|
|
@@ -96,13 +97,13 @@ suite
|
|
|
96
97
|
'Bad Create Query',
|
|
97
98
|
function()
|
|
98
99
|
{
|
|
99
|
-
var tmpQuery = libFoxHound.new(
|
|
100
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL');
|
|
100
101
|
// Build the query
|
|
101
102
|
tmpQuery.buildCreateQuery();
|
|
102
103
|
tmpQuery.addRecord({});
|
|
103
104
|
tmpQuery.buildCreateQuery();
|
|
104
105
|
// This is the query generated by the MySQL dialect
|
|
105
|
-
|
|
106
|
+
_Fable.log.trace('Create Query', tmpQuery.query);
|
|
106
107
|
Expect(tmpQuery.query.body)
|
|
107
108
|
.to.equal(false);
|
|
108
109
|
}
|
|
@@ -112,12 +113,12 @@ suite
|
|
|
112
113
|
'Read Query',
|
|
113
114
|
function()
|
|
114
115
|
{
|
|
115
|
-
var tmpQuery = libFoxHound.new(
|
|
116
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL').setScope('Animal');
|
|
116
117
|
tmpQuery.addSort({Column:'Cost',Direction:'Descending'});
|
|
117
118
|
// Build the query
|
|
118
119
|
tmpQuery.buildReadQuery();
|
|
119
120
|
// This is the query generated by the MySQL dialect
|
|
120
|
-
|
|
121
|
+
_Fable.log.trace('Simple Select Query', tmpQuery.query);
|
|
121
122
|
Expect(tmpQuery.query.body)
|
|
122
123
|
.to.equal('SELECT `Animal`.* FROM `Animal` ORDER BY Cost DESC;');
|
|
123
124
|
}
|
|
@@ -127,13 +128,13 @@ suite
|
|
|
127
128
|
'Read Query with Distinct',
|
|
128
129
|
function()
|
|
129
130
|
{
|
|
130
|
-
var tmpQuery = libFoxHound.new(
|
|
131
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL').setScope('Animal');
|
|
131
132
|
tmpQuery.addSort({Column:'Cost',Direction:'Descending'})
|
|
132
133
|
.setDistinct(true);
|
|
133
134
|
// Build the query
|
|
134
135
|
tmpQuery.buildReadQuery();
|
|
135
136
|
// This is the query generated by the MySQL dialect
|
|
136
|
-
|
|
137
|
+
_Fable.log.trace('Simple Select Query', tmpQuery.query);
|
|
137
138
|
Expect(tmpQuery.query.body)
|
|
138
139
|
.to.equal('SELECT DISTINCT `Animal`.* FROM `Animal` ORDER BY Cost DESC;');
|
|
139
140
|
}
|
|
@@ -143,7 +144,7 @@ suite
|
|
|
143
144
|
'Complex Read Query',
|
|
144
145
|
function()
|
|
145
146
|
{
|
|
146
|
-
var tmpQuery = libFoxHound.new(
|
|
147
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
147
148
|
.setDialect('MySQL')
|
|
148
149
|
.setScope('Animal')
|
|
149
150
|
.setCap(10)
|
|
@@ -155,7 +156,7 @@ suite
|
|
|
155
156
|
// Build the query
|
|
156
157
|
tmpQuery.buildReadQuery();
|
|
157
158
|
// This is the query generated by the MySQL dialect
|
|
158
|
-
|
|
159
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
159
160
|
Expect(tmpQuery.query.body)
|
|
160
161
|
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` WHERE Age = :Age_w0 ORDER BY Age, Cost LIMIT 0, 10;');
|
|
161
162
|
}
|
|
@@ -165,7 +166,7 @@ suite
|
|
|
165
166
|
'Complex Read Query with qualified and unqualified "SELECT *" cases',
|
|
166
167
|
function()
|
|
167
168
|
{
|
|
168
|
-
var tmpQuery = libFoxHound.new(
|
|
169
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
169
170
|
.setDialect('MySQL')
|
|
170
171
|
.setScope('Animal')
|
|
171
172
|
.setCap(10)
|
|
@@ -177,7 +178,7 @@ suite
|
|
|
177
178
|
// Build the query
|
|
178
179
|
tmpQuery.buildReadQuery();
|
|
179
180
|
// This is the query generated by the MySQL dialect
|
|
180
|
-
|
|
181
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
181
182
|
Expect(tmpQuery.query.body)
|
|
182
183
|
.to.equal('SELECT *, `Name`, `Age`, `Cost`, `Animal`.* FROM `Animal` WHERE Age = :Age_w0 ORDER BY Age, Cost LIMIT 0, 10;');
|
|
183
184
|
}
|
|
@@ -187,7 +188,7 @@ suite
|
|
|
187
188
|
'Complex Read Query 2',
|
|
188
189
|
function()
|
|
189
190
|
{
|
|
190
|
-
var tmpQuery = libFoxHound.new(
|
|
191
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
191
192
|
.setDialect('MySQL')
|
|
192
193
|
.setScope('Animal')
|
|
193
194
|
.setDataElements(['Name', 'Age', 'Cost'])
|
|
@@ -203,7 +204,7 @@ suite
|
|
|
203
204
|
// Build the query
|
|
204
205
|
tmpQuery.buildReadQuery();
|
|
205
206
|
// This is the query generated by the MySQL dialect
|
|
206
|
-
|
|
207
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
207
208
|
Expect(tmpQuery.query.body)
|
|
208
209
|
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` WHERE Age = :Age_w0 AND ( Color = :Color_w2 OR Color = :Color_w3 ) AND Description IS NOT NULL AND IDOffice IN ( :IDOffice_w6 ) ORDER BY Age LIMIT 100;');
|
|
209
210
|
}
|
|
@@ -213,7 +214,7 @@ suite
|
|
|
213
214
|
'Custom Read Query',
|
|
214
215
|
function()
|
|
215
216
|
{
|
|
216
|
-
var tmpQuery = libFoxHound.new(
|
|
217
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
217
218
|
.setDialect('MySQL')
|
|
218
219
|
.setScope('Animal')
|
|
219
220
|
.setCap(10)
|
|
@@ -225,7 +226,7 @@ suite
|
|
|
225
226
|
// Build the query
|
|
226
227
|
tmpQuery.buildReadQuery();
|
|
227
228
|
// This is the query generated by the MySQL dialect
|
|
228
|
-
|
|
229
|
+
_Fable.log.trace('Custom Select Query', tmpQuery.query);
|
|
229
230
|
Expect(tmpQuery.query.body)
|
|
230
231
|
.to.equal('SELECT Name, Age * 5, Cost FROM `Animal` WHERE Age = :Age_w0 LIMIT 0, 10;');
|
|
231
232
|
}
|
|
@@ -235,7 +236,7 @@ suite
|
|
|
235
236
|
'Custom Read Query with Custom Parameters',
|
|
236
237
|
function()
|
|
237
238
|
{
|
|
238
|
-
var tmpQuery = libFoxHound.new(
|
|
239
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
239
240
|
.setDialect('MySQL')
|
|
240
241
|
.setScope('Animal')
|
|
241
242
|
.setCap(10)
|
|
@@ -248,7 +249,7 @@ suite
|
|
|
248
249
|
// Build the query
|
|
249
250
|
tmpQuery.buildReadQuery();
|
|
250
251
|
// This is the query generated by the MySQL dialect
|
|
251
|
-
|
|
252
|
+
_Fable.log.trace('Custom Select Query', tmpQuery.query);
|
|
252
253
|
Expect(tmpQuery.query.body)
|
|
253
254
|
.to.equal('SELECT Name, Age * 5, Cost FROM `Animal` WHERE Age = :Age_w0 LIMIT 0, 10;');
|
|
254
255
|
}
|
|
@@ -258,7 +259,7 @@ suite
|
|
|
258
259
|
'Bad Custom Read Query',
|
|
259
260
|
function()
|
|
260
261
|
{
|
|
261
|
-
var tmpQuery = libFoxHound.new(
|
|
262
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
262
263
|
.setDialect('MySQL')
|
|
263
264
|
.setScope('Animal')
|
|
264
265
|
.setCap(10)
|
|
@@ -270,7 +271,7 @@ suite
|
|
|
270
271
|
// Build the query
|
|
271
272
|
tmpQuery.buildReadQuery();
|
|
272
273
|
// This is the query generated by the MySQL dialect
|
|
273
|
-
|
|
274
|
+
_Fable.log.trace('Custom Select Query', tmpQuery.query);
|
|
274
275
|
Expect(tmpQuery.query.body)
|
|
275
276
|
.to.equal(false);
|
|
276
277
|
}
|
|
@@ -280,7 +281,7 @@ suite
|
|
|
280
281
|
'Bad Custom Count Query',
|
|
281
282
|
function()
|
|
282
283
|
{
|
|
283
|
-
var tmpQuery = libFoxHound.new(
|
|
284
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
284
285
|
.setDialect('MySQL')
|
|
285
286
|
.setScope('Animal')
|
|
286
287
|
.setFilter({Column:'Age',Operator:'=',Value:'15',Connector:'AND',Parameter:'Age'});
|
|
@@ -288,7 +289,7 @@ suite
|
|
|
288
289
|
// Build the query
|
|
289
290
|
tmpQuery.buildCountQuery();
|
|
290
291
|
// This is the query generated by the MySQL dialect
|
|
291
|
-
|
|
292
|
+
_Fable.log.trace('Custom Count Query', tmpQuery.query);
|
|
292
293
|
Expect(tmpQuery.query.body)
|
|
293
294
|
.to.equal(false);
|
|
294
295
|
}
|
|
@@ -298,7 +299,7 @@ suite
|
|
|
298
299
|
'Custom Count Query',
|
|
299
300
|
function()
|
|
300
301
|
{
|
|
301
|
-
var tmpQuery = libFoxHound.new(
|
|
302
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
302
303
|
.setDialect('MySQL')
|
|
303
304
|
.setScope('Animal')
|
|
304
305
|
.setFilter({Column:'Age',Operator:'=',Value:'15',Connector:'AND',Parameter:'Age'});
|
|
@@ -306,7 +307,7 @@ suite
|
|
|
306
307
|
// Build the query
|
|
307
308
|
tmpQuery.buildCountQuery();
|
|
308
309
|
// This is the query generated by the MySQL dialect
|
|
309
|
-
|
|
310
|
+
_Fable.log.trace('Custom Count Query', tmpQuery.query);
|
|
310
311
|
Expect(tmpQuery.query.body)
|
|
311
312
|
.to.equal('SELECT COUNT(*) AS RowCount FROM `Animal` WHERE Age = :Age_w0;');
|
|
312
313
|
}
|
|
@@ -316,7 +317,7 @@ suite
|
|
|
316
317
|
'Custom Count Query with Custom Parameters',
|
|
317
318
|
function()
|
|
318
319
|
{
|
|
319
|
-
var tmpQuery = libFoxHound.new(
|
|
320
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
320
321
|
.setDialect('MySQL')
|
|
321
322
|
.setScope('Animal')
|
|
322
323
|
.setFilter({Column:'Age',Operator:'=',Value:'15',Connector:'AND',Parameter:'Age'});
|
|
@@ -325,7 +326,7 @@ suite
|
|
|
325
326
|
// Build the query
|
|
326
327
|
tmpQuery.buildCountQuery();
|
|
327
328
|
// This is the query generated by the MySQL dialect
|
|
328
|
-
|
|
329
|
+
_Fable.log.trace('Custom Count Query', tmpQuery.query);
|
|
329
330
|
Expect(tmpQuery.query.body)
|
|
330
331
|
.to.equal('SELECT COUNT(*) AS RowCount FROM `Animal` WHERE Age = :Age_w0;');
|
|
331
332
|
}
|
|
@@ -335,7 +336,7 @@ suite
|
|
|
335
336
|
'Update Query',
|
|
336
337
|
function()
|
|
337
338
|
{
|
|
338
|
-
var tmpQuery = libFoxHound.new(
|
|
339
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
339
340
|
.setLogLevel(5)
|
|
340
341
|
.setScope('Animal')
|
|
341
342
|
.addFilter('IDAnimal', 9)
|
|
@@ -344,7 +345,7 @@ suite
|
|
|
344
345
|
// Build the query
|
|
345
346
|
tmpQuery.buildUpdateQuery();
|
|
346
347
|
// This is the query generated by the MySQL dialect
|
|
347
|
-
|
|
348
|
+
_Fable.log.trace('Update Query', tmpQuery.query);
|
|
348
349
|
Expect(tmpQuery.query.body)
|
|
349
350
|
.to.equal('UPDATE `Animal` SET Age = :Age_0, Color = :Color_1 WHERE IDAnimal = :IDAnimal_w0;');
|
|
350
351
|
}
|
|
@@ -354,14 +355,14 @@ suite
|
|
|
354
355
|
'Bad Update Query',
|
|
355
356
|
function()
|
|
356
357
|
{
|
|
357
|
-
var tmpQuery = libFoxHound.new(
|
|
358
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL');
|
|
358
359
|
|
|
359
360
|
// Build the query
|
|
360
361
|
tmpQuery.buildUpdateQuery();
|
|
361
362
|
tmpQuery.addRecord({});
|
|
362
363
|
tmpQuery.buildUpdateQuery();
|
|
363
364
|
// This is the query generated by the MySQL dialect
|
|
364
|
-
|
|
365
|
+
_Fable.log.trace('Update Query', tmpQuery.query);
|
|
365
366
|
Expect(tmpQuery.query.body)
|
|
366
367
|
.to.equal(false);
|
|
367
368
|
}
|
|
@@ -371,14 +372,14 @@ suite
|
|
|
371
372
|
'Delete Query',
|
|
372
373
|
function()
|
|
373
374
|
{
|
|
374
|
-
var tmpQuery = libFoxHound.new(
|
|
375
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
375
376
|
.setScope('Animal')
|
|
376
377
|
.addFilter('IDAnimal', 10);
|
|
377
378
|
|
|
378
379
|
// Build the query
|
|
379
380
|
tmpQuery.buildDeleteQuery();
|
|
380
381
|
// This is the query generated by the MySQL dialect
|
|
381
|
-
|
|
382
|
+
_Fable.log.trace('Delete Query', tmpQuery.query);
|
|
382
383
|
Expect(tmpQuery.query.body)
|
|
383
384
|
.to.equal('DELETE FROM `Animal` WHERE IDAnimal = :IDAnimal_w0;');
|
|
384
385
|
}
|
|
@@ -388,14 +389,14 @@ suite
|
|
|
388
389
|
'Count Query',
|
|
389
390
|
function()
|
|
390
391
|
{
|
|
391
|
-
var tmpQuery = libFoxHound.new(
|
|
392
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
392
393
|
.setDialect('MySQL')
|
|
393
394
|
.setScope('Animal');
|
|
394
395
|
|
|
395
396
|
// Build the query
|
|
396
397
|
tmpQuery.buildCountQuery();
|
|
397
398
|
// This is the query generated by the MySQL dialect
|
|
398
|
-
|
|
399
|
+
_Fable.log.trace('Count Query', tmpQuery.query);
|
|
399
400
|
Expect(tmpQuery.query.body)
|
|
400
401
|
.to.equal('SELECT COUNT(*) AS RowCount FROM `Animal`;');
|
|
401
402
|
}
|
|
@@ -405,7 +406,7 @@ suite
|
|
|
405
406
|
'Count Distinct Query',
|
|
406
407
|
function()
|
|
407
408
|
{
|
|
408
|
-
var tmpQuery = libFoxHound.new(
|
|
409
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
409
410
|
.setDialect('MySQL')
|
|
410
411
|
.setScope('Animal');
|
|
411
412
|
tmpQuery.setDistinct(true);
|
|
@@ -414,7 +415,7 @@ suite
|
|
|
414
415
|
// Build the query
|
|
415
416
|
tmpQuery.buildCountQuery();
|
|
416
417
|
// This is the query generated by the MySQL dialect
|
|
417
|
-
|
|
418
|
+
_Fable.log.trace('Count Distinct Query', tmpQuery.query);
|
|
418
419
|
Expect(tmpQuery.query.body)
|
|
419
420
|
.to.equal('SELECT COUNT(DISTINCT `Animal`.`IDAnimal`) AS RowCount FROM `Animal` WHERE `Animal`.Deleted = :Deleted_w0;');
|
|
420
421
|
}
|
|
@@ -424,7 +425,7 @@ suite
|
|
|
424
425
|
'Count Distinct Query without Schema',
|
|
425
426
|
function()
|
|
426
427
|
{
|
|
427
|
-
var tmpQuery = libFoxHound.new(
|
|
428
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
428
429
|
.setDialect('MySQL')
|
|
429
430
|
.setScope('Animal');
|
|
430
431
|
tmpQuery.setDistinct(true);
|
|
@@ -432,7 +433,7 @@ suite
|
|
|
432
433
|
// Build the query
|
|
433
434
|
tmpQuery.buildCountQuery();
|
|
434
435
|
// This is the query generated by the MySQL dialect
|
|
435
|
-
|
|
436
|
+
_Fable.log.trace('Count Distinct Query', tmpQuery.query);
|
|
436
437
|
Expect(tmpQuery.query.body)
|
|
437
438
|
.to.equal('SELECT COUNT(*) AS RowCount FROM `Animal`;');
|
|
438
439
|
}
|
|
@@ -442,7 +443,7 @@ suite
|
|
|
442
443
|
'Count Distinct Query with Custom Fields',
|
|
443
444
|
function()
|
|
444
445
|
{
|
|
445
|
-
var tmpQuery = libFoxHound.new(
|
|
446
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
446
447
|
.setDialect('MySQL')
|
|
447
448
|
.setScope('Animal')
|
|
448
449
|
.setDataElements(['Name', 'Age', 'Cost']);
|
|
@@ -451,7 +452,7 @@ suite
|
|
|
451
452
|
// Build the query
|
|
452
453
|
tmpQuery.buildCountQuery();
|
|
453
454
|
// This is the query generated by the MySQL dialect
|
|
454
|
-
|
|
455
|
+
_Fable.log.trace('Count Distinct Query', tmpQuery.query);
|
|
455
456
|
Expect(tmpQuery.query.body)
|
|
456
457
|
.to.equal('SELECT COUNT(DISTINCT `Name`, `Age`, `Cost`) AS RowCount FROM `Animal`;');
|
|
457
458
|
}
|
|
@@ -469,7 +470,7 @@ suite
|
|
|
469
470
|
'Create Query',
|
|
470
471
|
function()
|
|
471
472
|
{
|
|
472
|
-
var tmpQuery = libFoxHound.new(
|
|
473
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
473
474
|
.setLogLevel(5)
|
|
474
475
|
.setDialect('MySQL')
|
|
475
476
|
.setScope('Animal')
|
|
@@ -491,7 +492,7 @@ suite
|
|
|
491
492
|
// Build the query
|
|
492
493
|
tmpQuery.buildCreateQuery();
|
|
493
494
|
// This is the query generated by the MySQL dialect
|
|
494
|
-
|
|
495
|
+
_Fable.log.trace('Create Query', tmpQuery.query);
|
|
495
496
|
Expect(tmpQuery.query.body)
|
|
496
497
|
.to.equal("INSERT INTO `Animal` ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, Name, Age) VALUES ( NULL, :GUIDAnimal_1, NOW(3), :CreatingIDUser_3, NOW(3), :UpdatingIDUser_5, :Deleted_6, :Name_7, :Age_8);");
|
|
497
498
|
}
|
|
@@ -501,7 +502,7 @@ suite
|
|
|
501
502
|
'Create Query -- with GUID specified',
|
|
502
503
|
function()
|
|
503
504
|
{
|
|
504
|
-
var tmpQuery = libFoxHound.new(
|
|
505
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
505
506
|
.setLogLevel(5)
|
|
506
507
|
.setDialect('MySQL')
|
|
507
508
|
.setScope('Animal')
|
|
@@ -523,7 +524,7 @@ suite
|
|
|
523
524
|
// Build the query
|
|
524
525
|
tmpQuery.buildCreateQuery();
|
|
525
526
|
// This is the query generated by the MySQL dialect
|
|
526
|
-
|
|
527
|
+
_Fable.log.trace('Create Query', tmpQuery.query);
|
|
527
528
|
Expect(tmpQuery.query.body)
|
|
528
529
|
.to.equal("INSERT INTO `Animal` ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, Name, Age) VALUES ( NULL, :GUIDAnimal_1, NOW(3), :CreatingIDUser_3, NOW(3), :UpdatingIDUser_5, :Deleted_6, :Name_7, :Age_8);");
|
|
529
530
|
}
|
|
@@ -533,7 +534,7 @@ suite
|
|
|
533
534
|
'Create Query - with AutoIdentity disabled',
|
|
534
535
|
function()
|
|
535
536
|
{
|
|
536
|
-
var tmpQuery = libFoxHound.new(
|
|
537
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
537
538
|
.setLogLevel(5)
|
|
538
539
|
.setDialect('MySQL')
|
|
539
540
|
.setScope('Animal')
|
|
@@ -559,7 +560,7 @@ suite
|
|
|
559
560
|
// Build the query
|
|
560
561
|
tmpQuery.buildCreateQuery();
|
|
561
562
|
// This is the query generated by the MySQL dialect
|
|
562
|
-
|
|
563
|
+
_Fable.log.trace('Create Query (AutoIdentity disabled)', tmpQuery.query);
|
|
563
564
|
Expect(tmpQuery.query.body)
|
|
564
565
|
.to.equal("INSERT INTO `Animal` ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, DeletingIDUser, DeleteDate, Name, Age) VALUES ( :IDAnimal_0, :GUIDAnimal_1, :CreateDate_2, :CreatingIDUser_3, :UpdateDate_4, :UpdatingIDUser_5, :Deleted_6, :DeletingIDUser_7, :DeleteDate_8, :Name_9, :Age_10);");
|
|
565
566
|
}
|
|
@@ -569,7 +570,7 @@ suite
|
|
|
569
570
|
'Complex Read Query 2, verify checking Deleted bit with no filters',
|
|
570
571
|
function()
|
|
571
572
|
{
|
|
572
|
-
var tmpQuery = libFoxHound.new(
|
|
573
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
573
574
|
.setDialect('MySQL')
|
|
574
575
|
.setScope('Animal')
|
|
575
576
|
.setDataElements(['Name', 'Age', 'Cost'])
|
|
@@ -580,7 +581,7 @@ suite
|
|
|
580
581
|
// Build the query
|
|
581
582
|
tmpQuery.buildReadQuery();
|
|
582
583
|
// This is the query generated by the MySQL dialect
|
|
583
|
-
|
|
584
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
584
585
|
Expect(tmpQuery.query.body)
|
|
585
586
|
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` WHERE `Animal`.Deleted = :Deleted_w0 LIMIT 100;');
|
|
586
587
|
}
|
|
@@ -590,7 +591,7 @@ suite
|
|
|
590
591
|
'Complex Read Query 2, verify checking Deleted bit with no filters, with Distinct',
|
|
591
592
|
function()
|
|
592
593
|
{
|
|
593
|
-
var tmpQuery = libFoxHound.new(
|
|
594
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
594
595
|
.setDialect('MySQL')
|
|
595
596
|
.setScope('Animal')
|
|
596
597
|
.setDataElements(['Name', 'Age', 'Cost'])
|
|
@@ -602,7 +603,7 @@ suite
|
|
|
602
603
|
// Build the query
|
|
603
604
|
tmpQuery.buildReadQuery();
|
|
604
605
|
// This is the query generated by the MySQL dialect
|
|
605
|
-
|
|
606
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
606
607
|
Expect(tmpQuery.query.body)
|
|
607
608
|
.to.equal('SELECT DISTINCT `Name`, `Age`, `Cost` FROM `Animal` WHERE `Animal`.Deleted = :Deleted_w0 LIMIT 100;');
|
|
608
609
|
}
|
|
@@ -612,7 +613,7 @@ suite
|
|
|
612
613
|
'Complex Read Query 2, manually checking Deleted bit with Schema that has one',
|
|
613
614
|
function()
|
|
614
615
|
{
|
|
615
|
-
var tmpQuery = libFoxHound.new(
|
|
616
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
616
617
|
.setDialect('MySQL')
|
|
617
618
|
.setScope('Animal')
|
|
618
619
|
.setDataElements(['Name', 'Age', 'Cost'])
|
|
@@ -631,7 +632,7 @@ suite
|
|
|
631
632
|
// Build the query
|
|
632
633
|
tmpQuery.buildReadQuery();
|
|
633
634
|
// This is the query generated by the MySQL dialect
|
|
634
|
-
|
|
635
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
635
636
|
Expect(tmpQuery.query.body)
|
|
636
637
|
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` WHERE Age = :Age_w0 AND ( Color = :Color_w2 OR Color = :Color_w3 ) AND Description IS NOT NULL AND IDOffice IN ( :IDOffice_w6 ) AND Deleted = :Deleted_w7 LIMIT 100;');
|
|
637
638
|
}
|
|
@@ -641,7 +642,7 @@ suite
|
|
|
641
642
|
'Complex Read Query 2, delete tracking disabled',
|
|
642
643
|
function()
|
|
643
644
|
{
|
|
644
|
-
var tmpQuery = libFoxHound.new(
|
|
645
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
645
646
|
.setDialect('MySQL')
|
|
646
647
|
.setScope('Animal')
|
|
647
648
|
.setDisableDeleteTracking(true)
|
|
@@ -653,7 +654,7 @@ suite
|
|
|
653
654
|
// Build the query
|
|
654
655
|
tmpQuery.buildReadQuery();
|
|
655
656
|
// This is the query generated by the MySQL dialect
|
|
656
|
-
|
|
657
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
657
658
|
Expect(tmpQuery.query.body)
|
|
658
659
|
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` LIMIT 100;');
|
|
659
660
|
}
|
|
@@ -663,7 +664,7 @@ suite
|
|
|
663
664
|
'Delete Query with Filters',
|
|
664
665
|
function()
|
|
665
666
|
{
|
|
666
|
-
var tmpQuery = libFoxHound.new(
|
|
667
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
667
668
|
.setScope('Animal')
|
|
668
669
|
.addFilter('IDAnimal', 10);
|
|
669
670
|
//Perform delete with no record specified, but has a Deleted bit in the schema
|
|
@@ -674,7 +675,7 @@ suite
|
|
|
674
675
|
// Build the query
|
|
675
676
|
tmpQuery.buildDeleteQuery();
|
|
676
677
|
// This is the query generated by the MySQL dialect
|
|
677
|
-
|
|
678
|
+
_Fable.log.trace('Delete Query', tmpQuery.query);
|
|
678
679
|
Expect(tmpQuery.query.body)
|
|
679
680
|
.to.equal('UPDATE `Animal` SET UpdateDate = NOW(3), Deleted = 1, DeletingIDUser = :DeletingIDUser_2, DeleteDate = NOW(3) WHERE IDAnimal = :IDAnimal_w0 AND `Animal`.Deleted = :Deleted_w1;');
|
|
680
681
|
}
|
|
@@ -684,7 +685,7 @@ suite
|
|
|
684
685
|
'Update Query -- without Deleted',
|
|
685
686
|
function()
|
|
686
687
|
{
|
|
687
|
-
var tmpQuery = libFoxHound.new(
|
|
688
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
688
689
|
.setLogLevel(5)
|
|
689
690
|
.setScope('Animal')
|
|
690
691
|
.addFilter('IDAnimal', 9)
|
|
@@ -702,7 +703,7 @@ suite
|
|
|
702
703
|
// Build the query
|
|
703
704
|
tmpQuery.buildUpdateQuery();
|
|
704
705
|
// This is the query generated by the MySQL dialect
|
|
705
|
-
|
|
706
|
+
_Fable.log.trace('Update Query', tmpQuery.query);
|
|
706
707
|
Expect(tmpQuery.query.body)
|
|
707
708
|
.to.equal('UPDATE `Animal` SET GUIDAnimal = :GUIDAnimal_0, UpdateDate = NOW(3), UpdatingIDUser = :UpdatingIDUser_2, Name = :Name_3, Age = :Age_4 WHERE IDAnimal = :IDAnimal_w0;');
|
|
708
709
|
}
|
|
@@ -712,7 +713,7 @@ suite
|
|
|
712
713
|
'Update Query -- without Deleted, UpdateDate and UpdatingIDUser',
|
|
713
714
|
function()
|
|
714
715
|
{
|
|
715
|
-
var tmpQuery = libFoxHound.new(
|
|
716
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
716
717
|
.setLogLevel(5)
|
|
717
718
|
.setScope('Animal')
|
|
718
719
|
.addFilter('IDAnimal', 9)
|
|
@@ -732,7 +733,7 @@ suite
|
|
|
732
733
|
// Build the query
|
|
733
734
|
tmpQuery.buildUpdateQuery();
|
|
734
735
|
// This is the query generated by the MySQL dialect
|
|
735
|
-
|
|
736
|
+
_Fable.log.trace('Update Query', tmpQuery.query);
|
|
736
737
|
Expect(tmpQuery.query.body)
|
|
737
738
|
.to.equal('UPDATE `Animal` SET GUIDAnimal = :GUIDAnimal_0, Name = :Name_1, Age = :Age_2 WHERE IDAnimal = :IDAnimal_w0;');
|
|
738
739
|
}
|
|
@@ -742,7 +743,7 @@ suite
|
|
|
742
743
|
'Delete Query -- without Deleted',
|
|
743
744
|
function()
|
|
744
745
|
{
|
|
745
|
-
var tmpQuery = libFoxHound.new(
|
|
746
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
746
747
|
.setLogLevel(5)
|
|
747
748
|
.setScope('Animal')
|
|
748
749
|
.addFilter('IDAnimal', 9)
|
|
@@ -754,7 +755,7 @@ suite
|
|
|
754
755
|
// Build the query
|
|
755
756
|
tmpQuery.buildDeleteQuery();
|
|
756
757
|
// This is the query generated by the MySQL dialect
|
|
757
|
-
|
|
758
|
+
_Fable.log.trace('Delete Query', tmpQuery.query);
|
|
758
759
|
Expect(tmpQuery.query.body)
|
|
759
760
|
.to.equal('DELETE FROM `Animal` WHERE IDAnimal = :IDAnimal_w0;');
|
|
760
761
|
}
|
|
@@ -764,7 +765,7 @@ suite
|
|
|
764
765
|
'Update Query',
|
|
765
766
|
function()
|
|
766
767
|
{
|
|
767
|
-
var tmpQuery = libFoxHound.new(
|
|
768
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
768
769
|
.setLogLevel(5)
|
|
769
770
|
.setScope('Animal')
|
|
770
771
|
.addFilter('IDAnimal', 9)
|
|
@@ -786,7 +787,7 @@ suite
|
|
|
786
787
|
// Build the query
|
|
787
788
|
tmpQuery.buildUpdateQuery();
|
|
788
789
|
// This is the query generated by the MySQL dialect
|
|
789
|
-
|
|
790
|
+
_Fable.log.trace('Update Query', tmpQuery.query);
|
|
790
791
|
Expect(tmpQuery.query.body)
|
|
791
792
|
.to.equal('UPDATE `Animal` SET GUIDAnimal = :GUIDAnimal_0, UpdateDate = NOW(3), UpdatingIDUser = :UpdatingIDUser_2, Deleted = :Deleted_3, Name = :Name_4, Age = :Age_5 WHERE IDAnimal = :IDAnimal_w0 AND Deleted = :Deleted_w1;');
|
|
792
793
|
}
|
|
@@ -796,7 +797,7 @@ suite
|
|
|
796
797
|
'Delete Query',
|
|
797
798
|
function()
|
|
798
799
|
{
|
|
799
|
-
var tmpQuery = libFoxHound.new(
|
|
800
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
800
801
|
.setLogLevel(5)
|
|
801
802
|
.setScope('Animal')
|
|
802
803
|
.addFilter('IDAnimal', 9)
|
|
@@ -808,7 +809,7 @@ suite
|
|
|
808
809
|
// Build the query
|
|
809
810
|
tmpQuery.buildDeleteQuery();
|
|
810
811
|
// This is the query generated by the MySQL dialect
|
|
811
|
-
|
|
812
|
+
_Fable.log.trace('Delete Query', tmpQuery.query);
|
|
812
813
|
Expect(tmpQuery.query.body)
|
|
813
814
|
.to.equal('UPDATE `Animal` SET UpdateDate = NOW(3), Deleted = 1, DeletingIDUser = :DeletingIDUser_2, DeleteDate = NOW(3) WHERE IDAnimal = :IDAnimal_w0 AND `Animal`.Deleted = :Deleted_w1;');
|
|
814
815
|
}
|
|
@@ -818,7 +819,7 @@ suite
|
|
|
818
819
|
'Delete Query with Delete Tracking Disabled',
|
|
819
820
|
function()
|
|
820
821
|
{
|
|
821
|
-
var tmpQuery = libFoxHound.new(
|
|
822
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
822
823
|
.setLogLevel(5)
|
|
823
824
|
.setScope('Animal')
|
|
824
825
|
.setDisableDeleteTracking(true)
|
|
@@ -831,7 +832,7 @@ suite
|
|
|
831
832
|
// Build the query
|
|
832
833
|
tmpQuery.buildDeleteQuery();
|
|
833
834
|
// This is the query generated by the MySQL dialect
|
|
834
|
-
|
|
835
|
+
_Fable.log.trace('Delete Query', tmpQuery.query);
|
|
835
836
|
Expect(tmpQuery.query.body)
|
|
836
837
|
.to.equal('DELETE FROM `Animal` WHERE IDAnimal = :IDAnimal_w0;');
|
|
837
838
|
}
|
|
@@ -841,7 +842,7 @@ suite
|
|
|
841
842
|
'Undelete Query with Deleted Bit',
|
|
842
843
|
function()
|
|
843
844
|
{
|
|
844
|
-
var tmpQuery = libFoxHound.new(
|
|
845
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
845
846
|
.setScope('Animal')
|
|
846
847
|
.addFilter('IDAnimal', 10);
|
|
847
848
|
|
|
@@ -851,7 +852,7 @@ suite
|
|
|
851
852
|
// Build the query
|
|
852
853
|
tmpQuery.buildUndeleteQuery();
|
|
853
854
|
// This is the query generated by the MySQL dialect
|
|
854
|
-
|
|
855
|
+
_Fable.log.trace('Undelete Query', tmpQuery.query);
|
|
855
856
|
Expect(tmpQuery.query.body)
|
|
856
857
|
.to.equal('UPDATE `Animal` SET UpdateDate = NOW(3), UpdatingIDUser = :UpdatingIDUser_1, Deleted = 0 WHERE IDAnimal = :IDAnimal_w0;');
|
|
857
858
|
}
|
|
@@ -861,14 +862,14 @@ suite
|
|
|
861
862
|
'Undelete Query without Deleted Bit',
|
|
862
863
|
function()
|
|
863
864
|
{
|
|
864
|
-
var tmpQuery = libFoxHound.new(
|
|
865
|
+
var tmpQuery = libFoxHound.new(_Fable).setDialect('MySQL')
|
|
865
866
|
.setScope('Animal')
|
|
866
867
|
.addFilter('IDAnimal', 10);
|
|
867
868
|
|
|
868
869
|
// Build the query
|
|
869
870
|
tmpQuery.buildUndeleteQuery();
|
|
870
871
|
// This is the query generated by the MySQL dialect
|
|
871
|
-
|
|
872
|
+
_Fable.log.trace('Undelete Query', tmpQuery.query);
|
|
872
873
|
Expect(tmpQuery.query.body)
|
|
873
874
|
.to.equal('SELECT NULL;');
|
|
874
875
|
}
|
|
@@ -886,7 +887,7 @@ suite
|
|
|
886
887
|
'Join Read Query',
|
|
887
888
|
function()
|
|
888
889
|
{
|
|
889
|
-
var tmpQuery = libFoxHound.new(
|
|
890
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
890
891
|
.setDialect('MySQL')
|
|
891
892
|
.setScope('Animal')
|
|
892
893
|
.setCap(10)
|
|
@@ -899,7 +900,7 @@ suite
|
|
|
899
900
|
// Build the query
|
|
900
901
|
tmpQuery.buildReadQuery();
|
|
901
902
|
// This is the query generated by the MySQL dialect
|
|
902
|
-
|
|
903
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
903
904
|
Expect(tmpQuery.query.body)
|
|
904
905
|
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` INNER JOIN Test ON Test.IDAnimal = Animal.IDAnimal WHERE Age = :Age_w0 ORDER BY Age LIMIT 0, 10;');
|
|
905
906
|
}
|
|
@@ -909,7 +910,7 @@ suite
|
|
|
909
910
|
'Join Read Query with Distinct',
|
|
910
911
|
function()
|
|
911
912
|
{
|
|
912
|
-
var tmpQuery = libFoxHound.new(
|
|
913
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
913
914
|
.setDialect('MySQL')
|
|
914
915
|
.setScope('Animal')
|
|
915
916
|
.setCap(10)
|
|
@@ -923,7 +924,7 @@ suite
|
|
|
923
924
|
// Build the query
|
|
924
925
|
tmpQuery.buildReadQuery();
|
|
925
926
|
// This is the query generated by the MySQL dialect
|
|
926
|
-
|
|
927
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
927
928
|
Expect(tmpQuery.query.body)
|
|
928
929
|
.to.equal('SELECT DISTINCT `Name`, `Age`, `Cost` FROM `Animal` INNER JOIN Test ON Test.IDAnimal = Animal.IDAnimal WHERE Age = :Age_w0 ORDER BY Age LIMIT 0, 10;');
|
|
929
930
|
}
|
|
@@ -933,7 +934,7 @@ suite
|
|
|
933
934
|
'Bad Join Read Query',
|
|
934
935
|
function()
|
|
935
936
|
{
|
|
936
|
-
var tmpQuery = libFoxHound.new(
|
|
937
|
+
var tmpQuery = libFoxHound.new(_Fable)
|
|
937
938
|
.setDialect('MySQL')
|
|
938
939
|
.setScope('Animal')
|
|
939
940
|
.setJoin({Table: 'Test', From:'Bad.IDAnimal', To: 'Animal.IDAnimal'});
|
|
@@ -941,7 +942,7 @@ suite
|
|
|
941
942
|
// Build the query
|
|
942
943
|
tmpQuery.buildReadQuery();
|
|
943
944
|
// This is the query generated by the MySQL dialect
|
|
944
|
-
|
|
945
|
+
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
945
946
|
Expect(tmpQuery.query.body)
|
|
946
947
|
.to.equal('SELECT `Animal`.* FROM `Animal`;'); //bad join is ignored, warn log is generated
|
|
947
948
|
}
|