meadow 1.1.2 → 2.0.2
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/luxury-extras/MySQL/Dockerfile +1 -0
- package/.config/luxury-extras/MySQL/MySQL-Laden-Entry.sh +0 -0
- package/.config/luxury-extras/model/documentation/Dictionary.md +18 -0
- package/.config/luxury-extras/model/documentation/Model-Author.md +20 -0
- package/.config/luxury-extras/model/documentation/Model-Book.md +26 -0
- package/.config/luxury-extras/model/documentation/Model-BookAuthorJoin.md +14 -0
- package/.config/luxury-extras/model/documentation/Model-BookPrice.md +25 -0
- package/.config/luxury-extras/model/documentation/Model-Review.md +22 -0
- package/.config/luxury-extras/model/documentation/ModelChangeTracking.md +17 -0
- package/.config/luxury-extras/model/documentation/README.md +1 -0
- package/.config/luxury-extras/model/documentation/diagram/README.md +1 -0
- package/.config/luxury-extras/model/documentation/diagram/Stricture_Output.dot +13 -0
- package/.config/luxury-extras/model/documentation/diagram/Stricture_Output.png +0 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-Author.json +220 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-Book.json +268 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-BookAuthorJoin.json +172 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-BookPrice.json +260 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-Review.json +236 -0
- package/.config/luxury-extras/model/json_schema_entities/README.md +1 -0
- package/.config/luxury-extras/model/json_schema_model/BookStore-Extended.json +915 -0
- package/.config/luxury-extras/model/json_schema_model/BookStore-PICT.json +1 -0
- package/.config/luxury-extras/model/json_schema_model/BookStore.json +280 -0
- package/.config/luxury-extras/model/json_schema_model/README.md +1 -0
- package/.config/luxury-extras/model/mysql_create/BookStore-CreateDatabase.mysql.sql +116 -0
- package/.config/luxury-extras/model/mysql_create/README.md +1 -0
- package/{Dockerfile → Dockerfile_LUXURYCode} +16 -1
- package/README.md +19 -5
- package/debug/Harness.js +69 -84
- package/gulpfile.js +83 -0
- package/package.json +24 -17
- package/source/Meadow-Browser-Shim.js +14 -0
- package/source/Meadow-Package.json +1 -1
- package/source/Meadow.js +17 -8
- package/source/behaviors/Meadow-Count.js +2 -2
- package/source/behaviors/Meadow-Create.js +3 -4
- package/source/behaviors/Meadow-Delete.js +2 -2
- package/source/behaviors/Meadow-Read.js +4 -4
- package/source/behaviors/Meadow-Reads.js +4 -3
- package/source/behaviors/Meadow-Undelete.js +42 -0
- package/source/behaviors/Meadow-Update.js +2 -2
- package/source/providers/Meadow-Provider-ALASQL.js +33 -0
- package/source/providers/Meadow-Provider-MeadowEndpoints.js +3 -4
- package/source/providers/Meadow-Provider-MySQL.js +40 -0
- package/source/providers/Meadow-Provider-None.js +8 -0
- package/test/Meadow-Provider-ALASQL.js +38 -14
- package/test/Meadow-Provider-MeadowEndpoints_tests.js +2 -819
- package/test/Meadow-Provider-MySQL_tests.js +49 -13
- package/test/Meadow-Provider-None_tests.js +19 -16
- package/test/Meadow_tests.js +2 -2
|
@@ -12,19 +12,10 @@ var Chai = require("chai");
|
|
|
12
12
|
var Expect = Chai.expect;
|
|
13
13
|
var Assert = Chai.assert;
|
|
14
14
|
|
|
15
|
-
var libAsync = require('async');
|
|
16
|
-
|
|
17
15
|
var tmpFableSettings = (
|
|
18
16
|
{
|
|
19
17
|
MeadowEndpoints:
|
|
20
18
|
{
|
|
21
|
-
// This is queued up for Travis defaults.
|
|
22
|
-
Server: "localhost",
|
|
23
|
-
Port: 3306,
|
|
24
|
-
User: "root",
|
|
25
|
-
Password: "123456789",
|
|
26
|
-
Database: "FableTest",
|
|
27
|
-
ConnectionPoolLimit: 20
|
|
28
19
|
},
|
|
29
20
|
LogStreams:
|
|
30
21
|
[
|
|
@@ -39,7 +30,7 @@ var tmpFableSettings = (
|
|
|
39
30
|
]
|
|
40
31
|
});
|
|
41
32
|
|
|
42
|
-
var libFable = require('fable')
|
|
33
|
+
var libFable = new (require('fable'))(tmpFableSettings)
|
|
43
34
|
|
|
44
35
|
var _AnimalJsonSchema = (
|
|
45
36
|
{
|
|
@@ -118,72 +109,7 @@ suite
|
|
|
118
109
|
(
|
|
119
110
|
function(fDone)
|
|
120
111
|
{
|
|
121
|
-
|
|
122
|
-
if (!_SpooledUp)
|
|
123
|
-
{
|
|
124
|
-
var _SQLConnectionPool = libMeadowEndpoints.createPool
|
|
125
|
-
(
|
|
126
|
-
{
|
|
127
|
-
connectionLimit: tmpFableSettings.MeadowEndpoints.ConnectionPoolLimit,
|
|
128
|
-
host: tmpFableSettings.MeadowEndpoints.Server,
|
|
129
|
-
port: tmpFableSettings.MeadowEndpoints.Port,
|
|
130
|
-
user: tmpFableSettings.MeadowEndpoints.User,
|
|
131
|
-
password: tmpFableSettings.MeadowEndpoints.Password,
|
|
132
|
-
database: tmpFableSettings.MeadowEndpoints.Database
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
// Tear down previous test data
|
|
137
|
-
libAsync.waterfall(
|
|
138
|
-
[
|
|
139
|
-
function(fCallBack)
|
|
140
|
-
{
|
|
141
|
-
_SQLConnectionPool.query('DROP TABLE IF EXISTS FableTest',
|
|
142
|
-
function(pErrorUpdate, pResponse) { fCallBack(null); });
|
|
143
|
-
},
|
|
144
|
-
function(fCallBack)
|
|
145
|
-
{
|
|
146
|
-
_SQLConnectionPool.query("CREATE TABLE IF NOT EXISTS FableTest (IDAnimal INT UNSIGNED NOT NULL AUTO_INCREMENT, GUIDAnimal CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', CreateDate DATETIME, CreatingIDUser INT NOT NULL DEFAULT '0', UpdateDate DATETIME, UpdatingIDUser INT NOT NULL DEFAULT '0', Deleted TINYINT NOT NULL DEFAULT '0', DeleteDate DATETIME, DeletingIDUser INT NOT NULL DEFAULT '0', Name CHAR(128) NOT NULL DEFAULT '', Type CHAR(128) NOT NULL DEFAULT '', PRIMARY KEY (IDAnimal) );",
|
|
147
|
-
function(pErrorUpdate, pResponse) { fCallBack(null); });
|
|
148
|
-
},
|
|
149
|
-
function(fCallBack)
|
|
150
|
-
{
|
|
151
|
-
_SQLConnectionPool.query(getAnimalInsert('Foo Foo', 'Bunny'),
|
|
152
|
-
function(pErrorUpdate, pResponse) { fCallBack(null); });
|
|
153
|
-
},
|
|
154
|
-
function(fCallBack)
|
|
155
|
-
{
|
|
156
|
-
_SQLConnectionPool.query(getAnimalInsert('Red Riding Hood', 'Girl'),
|
|
157
|
-
function(pErrorUpdate, pResponse) { fCallBack(null); });
|
|
158
|
-
},
|
|
159
|
-
function(fCallBack)
|
|
160
|
-
{
|
|
161
|
-
_SQLConnectionPool.query(getAnimalInsert('Red', 'Dog'),
|
|
162
|
-
function(pErrorUpdate, pResponse) { fCallBack(null); });
|
|
163
|
-
},
|
|
164
|
-
function(fCallBack)
|
|
165
|
-
{
|
|
166
|
-
_SQLConnectionPool.query(getAnimalInsert('Spot', 'Dog'),
|
|
167
|
-
function(pErrorUpdate, pResponse) { fCallBack(null); });
|
|
168
|
-
},
|
|
169
|
-
function(fCallBack)
|
|
170
|
-
{
|
|
171
|
-
_SQLConnectionPool.query(getAnimalInsert('Gertrude', 'Frog'),
|
|
172
|
-
function(pErrorUpdate, pResponse) { fCallBack(null); });
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
function(pError, pResult)
|
|
176
|
-
{
|
|
177
|
-
// Now continue the tests.
|
|
178
|
-
_SpooledUp = true;
|
|
179
|
-
fDone();
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
else
|
|
184
|
-
{
|
|
185
|
-
fDone();
|
|
186
|
-
}
|
|
112
|
+
fDone();
|
|
187
113
|
}
|
|
188
114
|
);
|
|
189
115
|
|
|
@@ -203,748 +129,5 @@ suite
|
|
|
203
129
|
);
|
|
204
130
|
}
|
|
205
131
|
);
|
|
206
|
-
suite
|
|
207
|
-
(
|
|
208
|
-
'Query Processing',
|
|
209
|
-
function()
|
|
210
|
-
{
|
|
211
|
-
test
|
|
212
|
-
(
|
|
213
|
-
'Create a record in the database',
|
|
214
|
-
function(fDone)
|
|
215
|
-
{
|
|
216
|
-
var testMeadow = newMeadow().setIDUser(90210);
|
|
217
|
-
|
|
218
|
-
// Ensure this query is "slow"...
|
|
219
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1;
|
|
220
|
-
|
|
221
|
-
var tmpQuery = testMeadow.query.clone().setLogLevel(5)
|
|
222
|
-
.addRecord({Name:'Blastoise', Type:'Pokemon'});
|
|
223
|
-
|
|
224
|
-
testMeadow.doCreate(tmpQuery,
|
|
225
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
226
|
-
{
|
|
227
|
-
// We should have a record ....
|
|
228
|
-
Expect(pRecord.Name)
|
|
229
|
-
.to.equal('Blastoise');
|
|
230
|
-
Expect(pRecord.CreatingIDUser)
|
|
231
|
-
.to.equal(90210);
|
|
232
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1000;
|
|
233
|
-
fDone();
|
|
234
|
-
}
|
|
235
|
-
)
|
|
236
|
-
}
|
|
237
|
-
);
|
|
238
|
-
test
|
|
239
|
-
(
|
|
240
|
-
'Create a record in the database with Deleted bit already set',
|
|
241
|
-
function(fDone)
|
|
242
|
-
{
|
|
243
|
-
var testMeadow = newMeadow().setIDUser(90210);
|
|
244
|
-
|
|
245
|
-
var tmpQuery = testMeadow.query.clone().setLogLevel(5)
|
|
246
|
-
.setDisableDeleteTracking(true)
|
|
247
|
-
.addRecord({Name:'Blastoise', Type:'Pokemon', Deleted: true});
|
|
248
|
-
|
|
249
|
-
testMeadow.doCreate(tmpQuery,
|
|
250
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
251
|
-
{
|
|
252
|
-
// We should have a record ....
|
|
253
|
-
Expect(pRecord.Name)
|
|
254
|
-
.to.equal('Blastoise');
|
|
255
|
-
Expect(pRecord.CreatingIDUser)
|
|
256
|
-
.to.equal(90210);
|
|
257
|
-
fDone();
|
|
258
|
-
}
|
|
259
|
-
)
|
|
260
|
-
}
|
|
261
|
-
);
|
|
262
|
-
test
|
|
263
|
-
(
|
|
264
|
-
'Read a record from the database',
|
|
265
|
-
function(fDone)
|
|
266
|
-
{
|
|
267
|
-
var testMeadow = newMeadow();
|
|
268
|
-
|
|
269
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1;
|
|
270
|
-
|
|
271
|
-
var tmpQuery = testMeadow.query
|
|
272
|
-
.addFilter('IDAnimal', 1);
|
|
273
|
-
|
|
274
|
-
testMeadow.doRead(tmpQuery,
|
|
275
|
-
function(pError, pQuery, pRecord)
|
|
276
|
-
{
|
|
277
|
-
// We should have a record ....
|
|
278
|
-
Expect(pRecord.IDAnimal)
|
|
279
|
-
.to.equal(1);
|
|
280
|
-
Expect(pRecord.Name)
|
|
281
|
-
.to.equal('Foo Foo');
|
|
282
|
-
|
|
283
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1000;
|
|
284
|
-
|
|
285
|
-
fDone();
|
|
286
|
-
}
|
|
287
|
-
)
|
|
288
|
-
}
|
|
289
|
-
);
|
|
290
|
-
test
|
|
291
|
-
(
|
|
292
|
-
'Read all records from the database',
|
|
293
|
-
function(fDone)
|
|
294
|
-
{
|
|
295
|
-
var testMeadow = newMeadow();
|
|
296
|
-
|
|
297
|
-
testMeadow.doReads(testMeadow.query,
|
|
298
|
-
function(pError, pQuery, pRecords)
|
|
299
|
-
{
|
|
300
|
-
// We should have a record ....
|
|
301
|
-
Expect(pRecords[0].IDAnimal)
|
|
302
|
-
.to.equal(1);
|
|
303
|
-
Expect(pRecords[0].Name)
|
|
304
|
-
.to.equal('Foo Foo');
|
|
305
|
-
Expect(pRecords[1].IDAnimal)
|
|
306
|
-
.to.equal(2);
|
|
307
|
-
Expect(pRecords[1].Name)
|
|
308
|
-
.to.equal('Red Riding Hood');
|
|
309
|
-
Expect(pRecords[1].Type)
|
|
310
|
-
.to.equal('Girl');
|
|
311
|
-
fDone();
|
|
312
|
-
}
|
|
313
|
-
)
|
|
314
|
-
}
|
|
315
|
-
);
|
|
316
|
-
test
|
|
317
|
-
(
|
|
318
|
-
'Update a record in the database',
|
|
319
|
-
function(fDone)
|
|
320
|
-
{
|
|
321
|
-
var testMeadow = newMeadow();
|
|
322
|
-
|
|
323
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1;
|
|
324
|
-
|
|
325
|
-
var tmpQuery = testMeadow.query
|
|
326
|
-
.addRecord({IDAnimal:2, Type:'Human'});
|
|
327
|
-
|
|
328
|
-
testMeadow.doUpdate(tmpQuery,
|
|
329
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
330
|
-
{
|
|
331
|
-
// We should have a record ....
|
|
332
|
-
Expect(pRecord.Type)
|
|
333
|
-
.to.equal('Human');
|
|
334
|
-
|
|
335
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1000;
|
|
336
|
-
|
|
337
|
-
fDone();
|
|
338
|
-
}
|
|
339
|
-
)
|
|
340
|
-
}
|
|
341
|
-
);
|
|
342
|
-
test
|
|
343
|
-
(
|
|
344
|
-
'Delete a record in the database',
|
|
345
|
-
function(fDone)
|
|
346
|
-
{
|
|
347
|
-
var testMeadow = newMeadow();
|
|
348
|
-
|
|
349
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1;
|
|
350
|
-
var tmpQuery = testMeadow.query.addFilter('IDAnimal',3);
|
|
351
|
-
|
|
352
|
-
testMeadow.doDelete(tmpQuery,
|
|
353
|
-
function(pError, pQuery, pRecord)
|
|
354
|
-
{
|
|
355
|
-
// It returns the number of rows deleted
|
|
356
|
-
Expect(pRecord)
|
|
357
|
-
.to.equal(1);
|
|
358
|
-
|
|
359
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1000;
|
|
360
|
-
|
|
361
|
-
fDone();
|
|
362
|
-
}
|
|
363
|
-
)
|
|
364
|
-
}
|
|
365
|
-
);
|
|
366
|
-
test
|
|
367
|
-
(
|
|
368
|
-
'Count all records from the database',
|
|
369
|
-
function(fDone)
|
|
370
|
-
{
|
|
371
|
-
var testMeadow = newMeadow();
|
|
372
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1;
|
|
373
|
-
|
|
374
|
-
Expect(testMeadow.query.parameters.result.executed)
|
|
375
|
-
.to.equal(false);
|
|
376
|
-
testMeadow.doCount(testMeadow.query,
|
|
377
|
-
function(pError, pQuery, pRecord)
|
|
378
|
-
{
|
|
379
|
-
// There should be 5 records
|
|
380
|
-
Expect(pRecord)
|
|
381
|
-
.to.equal(5);
|
|
382
|
-
Expect(pQuery.parameters.result.executed)
|
|
383
|
-
.to.equal(true);
|
|
384
|
-
testMeadow.fable.settings.QueryThresholdWarnTime = 1000;
|
|
385
|
-
fDone();
|
|
386
|
-
}
|
|
387
|
-
)
|
|
388
|
-
}
|
|
389
|
-
);
|
|
390
|
-
test
|
|
391
|
-
(
|
|
392
|
-
'Perform operations with a schema-based instantiation',
|
|
393
|
-
function(fDone)
|
|
394
|
-
{
|
|
395
|
-
var testMeadow = require('../source/Meadow.js').new(libFable)
|
|
396
|
-
.loadFromPackage(__dirname+'/Animal.json').setProvider('MeadowEndpoints');
|
|
397
|
-
|
|
398
|
-
// Make sure the authentication stuff got loaded
|
|
399
|
-
Expect(testMeadow.schemaFull.authorizer.User)
|
|
400
|
-
.to.be.an('object');
|
|
401
|
-
Expect(testMeadow.schemaFull.authorizer.User.Create)
|
|
402
|
-
.to.equal('Allow');
|
|
403
|
-
|
|
404
|
-
var tmpQuery = testMeadow.query
|
|
405
|
-
.addRecord({Name:'Grommet', Type:'Dog'});
|
|
406
|
-
|
|
407
|
-
testMeadow.doCreate(tmpQuery,
|
|
408
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
409
|
-
{
|
|
410
|
-
// We should have a record ....
|
|
411
|
-
Expect(pRecord.Name)
|
|
412
|
-
.to.equal('Grommet');
|
|
413
|
-
fDone();
|
|
414
|
-
}
|
|
415
|
-
)
|
|
416
|
-
}
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
);
|
|
420
|
-
suite
|
|
421
|
-
(
|
|
422
|
-
'Logged Query Processing',
|
|
423
|
-
function()
|
|
424
|
-
{
|
|
425
|
-
test
|
|
426
|
-
(
|
|
427
|
-
'Create a record in the database',
|
|
428
|
-
function(fDone)
|
|
429
|
-
{
|
|
430
|
-
var testMeadow = newMeadow();
|
|
431
|
-
|
|
432
|
-
var tmpQuery = testMeadow.query
|
|
433
|
-
.setLogLevel(5)
|
|
434
|
-
.addRecord({Name:'MewTwo', Type:'Pokemon'});
|
|
435
|
-
|
|
436
|
-
testMeadow.doCreate(tmpQuery,
|
|
437
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
438
|
-
{
|
|
439
|
-
// We should have a record ....
|
|
440
|
-
Expect(pRecord.Name)
|
|
441
|
-
.to.equal('MewTwo');
|
|
442
|
-
fDone();
|
|
443
|
-
}
|
|
444
|
-
)
|
|
445
|
-
}
|
|
446
|
-
);
|
|
447
|
-
test
|
|
448
|
-
(
|
|
449
|
-
'Create a record in the database with a predefined GUID',
|
|
450
|
-
function(fDone)
|
|
451
|
-
{
|
|
452
|
-
var testMeadow = newMeadow();
|
|
453
|
-
|
|
454
|
-
var tmpQuery = testMeadow.query
|
|
455
|
-
.setLogLevel(5)
|
|
456
|
-
.addRecord({Name:'MewThree', GUIDAnimal:'0x12345', Type:'Pokemon'});
|
|
457
|
-
|
|
458
|
-
testMeadow.doCreate(tmpQuery,
|
|
459
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
460
|
-
{
|
|
461
|
-
// We should have a record ....
|
|
462
|
-
Expect(pRecord.Name)
|
|
463
|
-
.to.equal('MewThree');
|
|
464
|
-
fDone();
|
|
465
|
-
}
|
|
466
|
-
)
|
|
467
|
-
}
|
|
468
|
-
);
|
|
469
|
-
test
|
|
470
|
-
(
|
|
471
|
-
'Create a record in the database with a previously predefined GUID -- expect failure',
|
|
472
|
-
function(fDone)
|
|
473
|
-
{
|
|
474
|
-
var testMeadow = newMeadow();
|
|
475
|
-
|
|
476
|
-
var tmpQuery = testMeadow.query
|
|
477
|
-
.setLogLevel(5)
|
|
478
|
-
.addRecord({Name:'MewThree', GUIDAnimal:'0x12345', Type:'Pokemon'});
|
|
479
|
-
|
|
480
|
-
testMeadow.doCreate(tmpQuery,
|
|
481
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
482
|
-
{
|
|
483
|
-
Expect(pError)
|
|
484
|
-
.to.equal("Record with GUID 0x12345 already exists!");
|
|
485
|
-
fDone();
|
|
486
|
-
}
|
|
487
|
-
)
|
|
488
|
-
}
|
|
489
|
-
);
|
|
490
|
-
test
|
|
491
|
-
(
|
|
492
|
-
'Read a record from the database',
|
|
493
|
-
function(fDone)
|
|
494
|
-
{
|
|
495
|
-
var testMeadow = newMeadow();
|
|
496
|
-
|
|
497
|
-
var tmpQuery = testMeadow.query
|
|
498
|
-
.setLogLevel(5)
|
|
499
|
-
.addFilter('IDAnimal', 1);
|
|
500
|
-
|
|
501
|
-
testMeadow.doRead(tmpQuery,
|
|
502
|
-
function(pError, pQuery, pRecord)
|
|
503
|
-
{
|
|
504
|
-
// We should have a record ....
|
|
505
|
-
Expect(pRecord.IDAnimal)
|
|
506
|
-
.to.equal(1);
|
|
507
|
-
Expect(pRecord.Name)
|
|
508
|
-
.to.equal('Foo Foo');
|
|
509
|
-
fDone();
|
|
510
|
-
}
|
|
511
|
-
)
|
|
512
|
-
}
|
|
513
|
-
);
|
|
514
|
-
test
|
|
515
|
-
(
|
|
516
|
-
'Read all records from the database',
|
|
517
|
-
function(fDone)
|
|
518
|
-
{
|
|
519
|
-
var testMeadow = newMeadow();
|
|
520
|
-
|
|
521
|
-
testMeadow.doReads(testMeadow.query.setLogLevel(5),
|
|
522
|
-
function(pError, pQuery, pRecords)
|
|
523
|
-
{
|
|
524
|
-
// We should have a record ....
|
|
525
|
-
Expect(pRecords[0].IDAnimal)
|
|
526
|
-
.to.equal(1);
|
|
527
|
-
Expect(pRecords[0].Name)
|
|
528
|
-
.to.equal('Foo Foo');
|
|
529
|
-
Expect(pRecords[1].IDAnimal)
|
|
530
|
-
.to.equal(2);
|
|
531
|
-
Expect(pRecords[1].Name)
|
|
532
|
-
.to.equal('Red Riding Hood');
|
|
533
|
-
Expect(pRecords[1].Type)
|
|
534
|
-
.to.equal('Human');
|
|
535
|
-
fDone();
|
|
536
|
-
}
|
|
537
|
-
)
|
|
538
|
-
}
|
|
539
|
-
);
|
|
540
|
-
test
|
|
541
|
-
(
|
|
542
|
-
'Update a record in the database',
|
|
543
|
-
function(fDone)
|
|
544
|
-
{
|
|
545
|
-
var testMeadow = newMeadow();
|
|
546
|
-
|
|
547
|
-
var tmpQuery = testMeadow.query
|
|
548
|
-
.setLogLevel(5)
|
|
549
|
-
.addRecord({IDAnimal:2, Type:'HumanGirl'});
|
|
550
|
-
|
|
551
|
-
testMeadow.doUpdate(tmpQuery,
|
|
552
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
553
|
-
{
|
|
554
|
-
// We should have a record ....
|
|
555
|
-
Expect(pRecord.Type)
|
|
556
|
-
.to.equal('HumanGirl');
|
|
557
|
-
fDone();
|
|
558
|
-
}
|
|
559
|
-
)
|
|
560
|
-
}
|
|
561
|
-
);
|
|
562
|
-
test
|
|
563
|
-
(
|
|
564
|
-
'Delete a record in the database',
|
|
565
|
-
function(fDone)
|
|
566
|
-
{
|
|
567
|
-
var testMeadow = newMeadow();
|
|
568
|
-
|
|
569
|
-
var tmpQuery = testMeadow.query
|
|
570
|
-
.setLogLevel(5)
|
|
571
|
-
.addFilter('IDAnimal',4);
|
|
572
|
-
|
|
573
|
-
testMeadow.doDelete(tmpQuery,
|
|
574
|
-
function(pError, pQuery, pRecord)
|
|
575
|
-
{
|
|
576
|
-
// It returns the number of rows deleted
|
|
577
|
-
Expect(pRecord)
|
|
578
|
-
.to.equal(1);
|
|
579
|
-
fDone();
|
|
580
|
-
}
|
|
581
|
-
)
|
|
582
|
-
}
|
|
583
|
-
);
|
|
584
|
-
test
|
|
585
|
-
(
|
|
586
|
-
'Count all records from the database',
|
|
587
|
-
function(fDone)
|
|
588
|
-
{
|
|
589
|
-
var testMeadow = newMeadow();
|
|
590
|
-
|
|
591
|
-
testMeadow.doCount(testMeadow.query.setLogLevel(5),
|
|
592
|
-
function(pError, pQuery, pRecord)
|
|
593
|
-
{
|
|
594
|
-
// There should be 7 records
|
|
595
|
-
Expect(pRecord)
|
|
596
|
-
.to.equal(7);
|
|
597
|
-
fDone();
|
|
598
|
-
}
|
|
599
|
-
)
|
|
600
|
-
}
|
|
601
|
-
);
|
|
602
|
-
test
|
|
603
|
-
(
|
|
604
|
-
'Read a record from the database that had a defined GUID',
|
|
605
|
-
function(fDone)
|
|
606
|
-
{
|
|
607
|
-
var testMeadow = newMeadow();
|
|
608
|
-
|
|
609
|
-
var tmpQuery = testMeadow.query
|
|
610
|
-
.addFilter('GUIDAnimal', '0x12345');
|
|
611
|
-
|
|
612
|
-
testMeadow.doRead(tmpQuery,
|
|
613
|
-
function(pError, pQuery, pRecord)
|
|
614
|
-
{
|
|
615
|
-
// We should have a record ....
|
|
616
|
-
Expect(pRecord.IDAnimal)
|
|
617
|
-
.to.equal(10);
|
|
618
|
-
Expect(pRecord.Name)
|
|
619
|
-
.to.equal('MewThree');
|
|
620
|
-
fDone();
|
|
621
|
-
}
|
|
622
|
-
)
|
|
623
|
-
}
|
|
624
|
-
);
|
|
625
|
-
test
|
|
626
|
-
(
|
|
627
|
-
'Create a record in the database with a defined creating user',
|
|
628
|
-
function(fDone)
|
|
629
|
-
{
|
|
630
|
-
var testMeadow = newMeadow();
|
|
631
|
-
var tmpQuery = testMeadow.query
|
|
632
|
-
.setIDUser(800)
|
|
633
|
-
.addRecord({Name:'MewSix', GUIDAnimal:'0x123456', Type:'Pokemon'});
|
|
634
|
-
|
|
635
|
-
testMeadow.doCreate(tmpQuery,
|
|
636
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
637
|
-
{
|
|
638
|
-
// We should have a record ....
|
|
639
|
-
Expect(pRecord.Name)
|
|
640
|
-
.to.equal('MewSix');
|
|
641
|
-
Expect(pRecord.CreatingIDUser)
|
|
642
|
-
.to.equal(800);
|
|
643
|
-
fDone();
|
|
644
|
-
}
|
|
645
|
-
)
|
|
646
|
-
}
|
|
647
|
-
);
|
|
648
|
-
}
|
|
649
|
-
);
|
|
650
|
-
suite
|
|
651
|
-
(
|
|
652
|
-
'The Bad Kind of Query Processing',
|
|
653
|
-
function()
|
|
654
|
-
{
|
|
655
|
-
test
|
|
656
|
-
(
|
|
657
|
-
'Count all records from the database from a nonexistent table',
|
|
658
|
-
function(fDone)
|
|
659
|
-
{
|
|
660
|
-
var testMeadow = newMeadow();
|
|
661
|
-
|
|
662
|
-
testMeadow.doCount(testMeadow.query.setScope('BadTable'),
|
|
663
|
-
function(pError, pQuery, pRecord)
|
|
664
|
-
{
|
|
665
|
-
Expect(pError.code)
|
|
666
|
-
.to.equal("ER_NO_SUCH_TABLE");
|
|
667
|
-
fDone();
|
|
668
|
-
}
|
|
669
|
-
)
|
|
670
|
-
}
|
|
671
|
-
);
|
|
672
|
-
test
|
|
673
|
-
(
|
|
674
|
-
'Create a record in the database with an invalid default identifier',
|
|
675
|
-
function(fDone)
|
|
676
|
-
{
|
|
677
|
-
var testMeadow = newMeadow().setDefaultIdentifier('BadIdentifier');
|
|
678
|
-
|
|
679
|
-
var tmpQuery = testMeadow.query
|
|
680
|
-
.addRecord({Name:'Scaley', Type:'Chameleon'});
|
|
681
|
-
|
|
682
|
-
testMeadow.doCreate(tmpQuery,
|
|
683
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
684
|
-
{
|
|
685
|
-
// We should have no record because the default id is IDFableTest and our tables identity is IDAnimal
|
|
686
|
-
Expect(pError.code)
|
|
687
|
-
.to.equal('ER_BAD_FIELD_ERROR');
|
|
688
|
-
fDone();
|
|
689
|
-
}
|
|
690
|
-
)
|
|
691
|
-
}
|
|
692
|
-
);
|
|
693
|
-
test
|
|
694
|
-
(
|
|
695
|
-
'Create a record in the database with the wrong default identifier',
|
|
696
|
-
function(fDone)
|
|
697
|
-
{
|
|
698
|
-
var testMeadow = newMeadow().setDefaultIdentifier('Type');
|
|
699
|
-
|
|
700
|
-
var tmpQuery = testMeadow.query
|
|
701
|
-
.addRecord({Name:'Tina', Type:'Chameleon'});
|
|
702
|
-
|
|
703
|
-
testMeadow.doCreate(tmpQuery,
|
|
704
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
705
|
-
{
|
|
706
|
-
// We should have no record because the default id is IDFableTest and our tables identity is IDAnimal
|
|
707
|
-
Expect(pError)
|
|
708
|
-
.to.equal('No record found after create.');
|
|
709
|
-
fDone();
|
|
710
|
-
}
|
|
711
|
-
)
|
|
712
|
-
}
|
|
713
|
-
);
|
|
714
|
-
test
|
|
715
|
-
(
|
|
716
|
-
'Create a record in the database with no record',
|
|
717
|
-
function(fDone)
|
|
718
|
-
{
|
|
719
|
-
var testMeadow = newMeadow().setDefaultIdentifier('Type');
|
|
720
|
-
|
|
721
|
-
testMeadow.doCreate(testMeadow.query,
|
|
722
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
723
|
-
{
|
|
724
|
-
// We should have no record because the default id is IDFableTest and our tables identity is IDAnimal
|
|
725
|
-
Expect(pError)
|
|
726
|
-
.to.equal('No record submitted');
|
|
727
|
-
fDone();
|
|
728
|
-
}
|
|
729
|
-
)
|
|
730
|
-
}
|
|
731
|
-
);
|
|
732
|
-
test
|
|
733
|
-
(
|
|
734
|
-
'Read a record from the database with no data returned',
|
|
735
|
-
function(fDone)
|
|
736
|
-
{
|
|
737
|
-
var testMeadow = newMeadow();
|
|
738
|
-
|
|
739
|
-
var tmpQuery = testMeadow.query
|
|
740
|
-
.addFilter('IDAnimal', 5000);
|
|
741
|
-
testMeadow.doRead(tmpQuery,
|
|
742
|
-
function(pError, pQuery, pRecord)
|
|
743
|
-
{
|
|
744
|
-
Expect(pRecord)
|
|
745
|
-
.to.equal(false);
|
|
746
|
-
fDone();
|
|
747
|
-
}
|
|
748
|
-
)
|
|
749
|
-
}
|
|
750
|
-
);
|
|
751
|
-
test
|
|
752
|
-
(
|
|
753
|
-
'Read records from the database with no data returned',
|
|
754
|
-
function(fDone)
|
|
755
|
-
{
|
|
756
|
-
var testMeadow = newMeadow();
|
|
757
|
-
|
|
758
|
-
var tmpQuery = testMeadow.query
|
|
759
|
-
.addFilter('IDAnimal', 5000);
|
|
760
|
-
|
|
761
|
-
testMeadow.doReads(tmpQuery,
|
|
762
|
-
function(pError, pQuery, pRecord)
|
|
763
|
-
{
|
|
764
|
-
Expect(pRecord.length)
|
|
765
|
-
.to.equal(0);
|
|
766
|
-
fDone();
|
|
767
|
-
}
|
|
768
|
-
)
|
|
769
|
-
}
|
|
770
|
-
);
|
|
771
|
-
test
|
|
772
|
-
(
|
|
773
|
-
'Read records from the database with an invalid query',
|
|
774
|
-
function(fDone)
|
|
775
|
-
{
|
|
776
|
-
var testMeadow = newMeadow();
|
|
777
|
-
|
|
778
|
-
var tmpQuery = testMeadow.query
|
|
779
|
-
.addFilter('IDAnimalFarmGeorge', 5000);
|
|
780
|
-
|
|
781
|
-
testMeadow.doReads(tmpQuery,
|
|
782
|
-
function(pError, pQuery, pRecord)
|
|
783
|
-
{
|
|
784
|
-
Expect(pError.code)
|
|
785
|
-
.to.equal('ER_BAD_FIELD_ERROR');
|
|
786
|
-
fDone();
|
|
787
|
-
}
|
|
788
|
-
)
|
|
789
|
-
}
|
|
790
|
-
);
|
|
791
|
-
test
|
|
792
|
-
(
|
|
793
|
-
'Read a single record from the database with an invalid query',
|
|
794
|
-
function(fDone)
|
|
795
|
-
{
|
|
796
|
-
var testMeadow = newMeadow();
|
|
797
|
-
|
|
798
|
-
var tmpQuery = testMeadow.query
|
|
799
|
-
.addFilter('IDAnimalFarmGeorge', 5000);
|
|
800
|
-
|
|
801
|
-
testMeadow.doRead(tmpQuery,
|
|
802
|
-
function(pError, pQuery, pRecord)
|
|
803
|
-
{
|
|
804
|
-
Expect(pError.code)
|
|
805
|
-
.to.equal('ER_BAD_FIELD_ERROR');
|
|
806
|
-
fDone();
|
|
807
|
-
}
|
|
808
|
-
)
|
|
809
|
-
}
|
|
810
|
-
);
|
|
811
|
-
test
|
|
812
|
-
(
|
|
813
|
-
'Delete with a bad query',
|
|
814
|
-
function(fDone)
|
|
815
|
-
{
|
|
816
|
-
var testMeadow = newMeadow();
|
|
817
|
-
|
|
818
|
-
var tmpQuery = testMeadow.query
|
|
819
|
-
.addFilter('IDAnimalHouse',4);
|
|
820
|
-
|
|
821
|
-
testMeadow.doDelete(tmpQuery,
|
|
822
|
-
function(pError, pQuery, pRecord)
|
|
823
|
-
{
|
|
824
|
-
Expect(pError.code)
|
|
825
|
-
.to.equal('ER_BAD_FIELD_ERROR');
|
|
826
|
-
fDone();
|
|
827
|
-
}
|
|
828
|
-
)
|
|
829
|
-
}
|
|
830
|
-
);
|
|
831
|
-
test
|
|
832
|
-
(
|
|
833
|
-
'Update a record in the database with a bad filter',
|
|
834
|
-
function(fDone)
|
|
835
|
-
{
|
|
836
|
-
var testMeadow = newMeadow();
|
|
837
|
-
|
|
838
|
-
var tmpQuery = testMeadow.query
|
|
839
|
-
.setLogLevel(5)
|
|
840
|
-
.addRecord({IDAnimal:undefined, Type:'HumanGirl'});
|
|
841
|
-
|
|
842
|
-
testMeadow.doUpdate(tmpQuery,
|
|
843
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
844
|
-
{
|
|
845
|
-
// We should have a record ....
|
|
846
|
-
Expect(pError)
|
|
847
|
-
.to.equal('Automated update missing filters... aborting!');
|
|
848
|
-
fDone();
|
|
849
|
-
}
|
|
850
|
-
)
|
|
851
|
-
}
|
|
852
|
-
);
|
|
853
|
-
test
|
|
854
|
-
(
|
|
855
|
-
'Update a record in the database without passing a record in',
|
|
856
|
-
function(fDone)
|
|
857
|
-
{
|
|
858
|
-
var testMeadow = newMeadow();
|
|
859
|
-
|
|
860
|
-
testMeadow.doUpdate(testMeadow.query,
|
|
861
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
862
|
-
{
|
|
863
|
-
Expect(pError)
|
|
864
|
-
.to.equal('No record submitted');
|
|
865
|
-
fDone();
|
|
866
|
-
}
|
|
867
|
-
)
|
|
868
|
-
}
|
|
869
|
-
);
|
|
870
|
-
test
|
|
871
|
-
(
|
|
872
|
-
'Update a record in the database without passing a record in',
|
|
873
|
-
function(fDone)
|
|
874
|
-
{
|
|
875
|
-
var testMeadow = newMeadow();
|
|
876
|
-
|
|
877
|
-
testMeadow.doUpdate(testMeadow.query,
|
|
878
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
879
|
-
{
|
|
880
|
-
Expect(pError)
|
|
881
|
-
.to.equal('No record submitted');
|
|
882
|
-
fDone();
|
|
883
|
-
}
|
|
884
|
-
)
|
|
885
|
-
}
|
|
886
|
-
);
|
|
887
|
-
test
|
|
888
|
-
(
|
|
889
|
-
'Update a record in the database with a bad record passed in (no default identifier)',
|
|
890
|
-
function(fDone)
|
|
891
|
-
{
|
|
892
|
-
var testMeadow = newMeadow();
|
|
893
|
-
|
|
894
|
-
var tmpQuery = testMeadow.query
|
|
895
|
-
.addRecord({Name:'Bill'});
|
|
896
|
-
|
|
897
|
-
testMeadow.doUpdate(tmpQuery,
|
|
898
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
899
|
-
{
|
|
900
|
-
Expect(pError)
|
|
901
|
-
.to.equal('Automated update missing default identifier');
|
|
902
|
-
fDone();
|
|
903
|
-
}
|
|
904
|
-
)
|
|
905
|
-
}
|
|
906
|
-
);
|
|
907
|
-
test
|
|
908
|
-
(
|
|
909
|
-
'Update a record in the database that does not exist',
|
|
910
|
-
function(fDone)
|
|
911
|
-
{
|
|
912
|
-
var testMeadow = newMeadow();
|
|
913
|
-
|
|
914
|
-
var tmpQuery = testMeadow.query
|
|
915
|
-
.addRecord({IDAnimal:983924});
|
|
916
|
-
|
|
917
|
-
testMeadow.doUpdate(tmpQuery,
|
|
918
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
919
|
-
{
|
|
920
|
-
Expect(pError)
|
|
921
|
-
.to.equal('No record found to update!');
|
|
922
|
-
fDone();
|
|
923
|
-
}
|
|
924
|
-
)
|
|
925
|
-
}
|
|
926
|
-
);
|
|
927
|
-
test
|
|
928
|
-
(
|
|
929
|
-
'Create a record in the database with bad fields',
|
|
930
|
-
function(fDone)
|
|
931
|
-
{
|
|
932
|
-
var testMeadow = newMeadow();
|
|
933
|
-
// NOTE: Bad fields passed in are polluting the schema forever.
|
|
934
|
-
var tmpQuery = testMeadow.query
|
|
935
|
-
.addRecord({Name:'Tina', TypeWriter:'Chameleon'});
|
|
936
|
-
|
|
937
|
-
testMeadow.doCreate(tmpQuery,
|
|
938
|
-
function(pError, pQuery, pQueryRead, pRecord)
|
|
939
|
-
{
|
|
940
|
-
Expect(pError.code)
|
|
941
|
-
.to.equal('ER_BAD_FIELD_ERROR');
|
|
942
|
-
fDone();
|
|
943
|
-
}
|
|
944
|
-
)
|
|
945
|
-
}
|
|
946
|
-
);
|
|
947
|
-
}
|
|
948
|
-
);
|
|
949
132
|
}
|
|
950
133
|
);
|