meadow 2.0.27 → 2.0.29

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.
@@ -75,7 +75,9 @@ var _AnimalSchema = (
75
75
  { Column: "UpdatingIDUser", Type:"UpdateIDUser" },
76
76
  { Column: "Deleted", Type:"Deleted" },
77
77
  { Column: "DeletingIDUser", Type:"DeleteIDUser" },
78
- { Column: "DeleteDate", Type:"DeleteDate" }
78
+ { Column: "DeleteDate", Type:"DeleteDate" },
79
+ { Column: "Metadata", Type:"JSON" },
80
+ { Column: "ExtraData", Type:"JSONProxy", StorageColumn:"ExtraDataJSON" }
79
81
  ]);
80
82
  var _AnimalDefault = (
81
83
  {
@@ -91,7 +93,10 @@ var _AnimalDefault = (
91
93
  DeletingIDUser: 0,
92
94
 
93
95
  Name: 'Unknown',
94
- Type: 'Unclassified'
96
+ Type: 'Unclassified',
97
+
98
+ Metadata: {},
99
+ ExtraData: {}
95
100
  });
96
101
 
97
102
  suite
@@ -214,6 +219,35 @@ suite
214
219
  }
215
220
  );
216
221
 
222
+ test
223
+ (
224
+ 'Create a record with JSON data',
225
+ function(fDone)
226
+ {
227
+ var testMeadow = newMeadow().setIDUser(90210);
228
+
229
+ var tmpQuery = testMeadow.query.clone().setLogLevel(5)
230
+ .addRecord({Name:'Moose', Type:'Mammal', Metadata: { habitat: 'forest', weight: 500 }, ExtraData: { endangered: false, population: 'stable' }});
231
+
232
+ testMeadow.doCreate(tmpQuery,
233
+ function(pError, pQuery, pQueryRead, pRecord)
234
+ {
235
+ // We should have a record with JSON data ....
236
+ Expect(pRecord.Name)
237
+ .to.equal('Moose');
238
+ Expect(pRecord.Metadata)
239
+ .to.be.an('object');
240
+ Expect(pRecord.Metadata.habitat)
241
+ .to.equal('forest');
242
+ Expect(pRecord.ExtraData)
243
+ .to.be.an('object');
244
+ Expect(pRecord.ExtraData.endangered)
245
+ .to.equal(false);
246
+ fDone();
247
+ }
248
+ )
249
+ }
250
+ );
217
251
  test
218
252
  (
219
253
  'Create more records for later tests',
@@ -226,7 +260,7 @@ suite
226
260
  testMeadow.doCreate(tmpQuery1,
227
261
  function(pError1, pQuery1, pQueryRead1, pRecord1)
228
262
  {
229
- Expect(pRecord1.IDAnimal).to.equal(2);
263
+ Expect(pRecord1.IDAnimal).to.equal(3);
230
264
  Expect(pRecord1.Name).to.equal('Red Riding Hood');
231
265
 
232
266
  var tmpQuery2 = testMeadow.query.clone()
@@ -234,21 +268,21 @@ suite
234
268
  testMeadow.doCreate(tmpQuery2,
235
269
  function(pError2, pQuery2, pQueryRead2, pRecord2)
236
270
  {
237
- Expect(pRecord2.IDAnimal).to.equal(3);
271
+ Expect(pRecord2.IDAnimal).to.equal(4);
238
272
 
239
273
  var tmpQuery3 = testMeadow.query.clone()
240
274
  .addRecord({Name:'Spot', Type:'Dog'});
241
275
  testMeadow.doCreate(tmpQuery3,
242
276
  function(pError3, pQuery3, pQueryRead3, pRecord3)
243
277
  {
244
- Expect(pRecord3.IDAnimal).to.equal(4);
278
+ Expect(pRecord3.IDAnimal).to.equal(5);
245
279
 
246
280
  var tmpQuery4 = testMeadow.query.clone()
247
281
  .addRecord({Name:'Gertrude', Type:'Frog'});
248
282
  testMeadow.doCreate(tmpQuery4,
249
283
  function(pError4, pQuery4, pQueryRead4, pRecord4)
250
284
  {
251
- Expect(pRecord4.IDAnimal).to.equal(5);
285
+ Expect(pRecord4.IDAnimal).to.equal(6);
252
286
  fDone();
253
287
  }
254
288
  );
@@ -277,7 +311,7 @@ suite
277
311
  {
278
312
  Expect(pRecord.Name).to.equal('Charmander');
279
313
  Expect(pRecord.Deleted).to.equal(1);
280
- Expect(pRecord.IDAnimal).to.equal(6);
314
+ Expect(pRecord.IDAnimal).to.equal(7);
281
315
  fDone();
282
316
  }
283
317
  );
@@ -326,12 +360,13 @@ suite
326
360
  testMeadow.doReads(testMeadow.query,
327
361
  function(pError, pQuery, pRecords)
328
362
  {
329
- // Should return 5 records (excluding Charmander which is Deleted=1)
363
+ // Should return 6 records (excluding Charmander which is Deleted=1)
330
364
  Expect(pRecords.length)
331
- .to.equal(5);
365
+ .to.equal(6);
332
366
  // Records come back in GUID key order, so use set-based assertions
333
367
  var tmpNames = pRecords.map(function(r) { return r.Name; });
334
368
  Expect(tmpNames).to.include('Foo Foo');
369
+ Expect(tmpNames).to.include('Moose');
335
370
  Expect(tmpNames).to.include('Red Riding Hood');
336
371
  Expect(tmpNames).to.include('Red');
337
372
  Expect(tmpNames).to.include('Spot');
@@ -424,17 +459,17 @@ suite
424
459
  var testMeadow = newMeadow();
425
460
 
426
461
  var tmpQuery = testMeadow.query
427
- .addFilter('IDAnimal', 3, '>');
462
+ .addFilter('IDAnimal', 4, '>');
428
463
 
429
464
  testMeadow.doReads(tmpQuery,
430
465
  function(pError, pQuery, pRecords)
431
466
  {
432
467
  Expect(pRecords.length)
433
468
  .to.equal(2);
434
- // IDs 4 and 5 (not 6 since it's Deleted); order depends on GUID keys
469
+ // IDs 5 and 6 (not 7 since it's Deleted); order depends on GUID keys
435
470
  var tmpIDs = pRecords.map(function(r) { return r.IDAnimal; });
436
- Expect(tmpIDs).to.include(4);
437
471
  Expect(tmpIDs).to.include(5);
472
+ Expect(tmpIDs).to.include(6);
438
473
  fDone();
439
474
  }
440
475
  );
@@ -449,7 +484,7 @@ suite
449
484
  var testMeadow = newMeadow();
450
485
 
451
486
  var tmpQuery = testMeadow.query
452
- .addFilter('Type', ['Dog', 'Human', 'Frog'], 'NOT IN');
487
+ .addFilter('Type', ['Dog', 'Human', 'Frog', 'Mammal'], 'NOT IN');
453
488
 
454
489
  testMeadow.doReads(tmpQuery,
455
490
  function(pError, pQuery, pRecords)
@@ -479,7 +514,7 @@ suite
479
514
  function(pError, pQuery, pRecords)
480
515
  {
481
516
  Expect(pRecords.length)
482
- .to.equal(5);
517
+ .to.equal(6);
483
518
  // Alphabetically descending
484
519
  Expect(pRecords[0].Name)
485
520
  .to.equal('Spot');
@@ -534,7 +569,7 @@ suite
534
569
  var testMeadow = newMeadow().setIDUser(42);
535
570
 
536
571
  var tmpQuery = testMeadow.query
537
- .addRecord({IDAnimal:2, Type:'Girl'});
572
+ .addRecord({IDAnimal:3, Type:'Girl'});
538
573
 
539
574
  testMeadow.doUpdate(tmpQuery,
540
575
  function(pError, pQuery, pQueryRead, pRecord)
@@ -559,7 +594,7 @@ suite
559
594
  var testMeadow = newMeadow();
560
595
 
561
596
  var tmpQuery = testMeadow.query
562
- .addFilter('IDAnimal', 2);
597
+ .addFilter('IDAnimal', 3);
563
598
 
564
599
  testMeadow.doRead(tmpQuery,
565
600
  function(pError, pQuery, pRecord)
@@ -590,7 +625,7 @@ suite
590
625
  function(pError, pQuery, pCount)
591
626
  {
592
627
  Expect(pCount)
593
- .to.equal(5);
628
+ .to.equal(6);
594
629
  fDone();
595
630
  }
596
631
  );
@@ -633,7 +668,7 @@ suite
633
668
  var testMeadow = newMeadow().setIDUser(999);
634
669
 
635
670
  var tmpQuery = testMeadow.query
636
- .addFilter('IDAnimal', 5);
671
+ .addFilter('IDAnimal', 6);
637
672
 
638
673
  testMeadow.doDelete(tmpQuery,
639
674
  function(pError, pQuery, pCount)
@@ -656,11 +691,11 @@ suite
656
691
  testMeadow.doReads(testMeadow.query,
657
692
  function(pError, pQuery, pRecords)
658
693
  {
659
- // Should now be 4 (Foo Foo, Red Riding Hood, Red, Spot)
694
+ // Should now be 5 (Foo Foo, Moose, Red Riding Hood, Red, Spot)
660
695
  Expect(pRecords.length)
661
- .to.equal(4);
696
+ .to.equal(5);
662
697
  var tmpIDs = pRecords.map(function(r) { return r.IDAnimal; });
663
- Expect(tmpIDs).to.not.include(5);
698
+ Expect(tmpIDs).to.not.include(6);
664
699
  fDone();
665
700
  }
666
701
  );
@@ -676,13 +711,13 @@ suite
676
711
 
677
712
  var tmpQuery = testMeadow.query
678
713
  .setDisableDeleteTracking(true)
679
- .addFilter('IDAnimal', 5);
714
+ .addFilter('IDAnimal', 6);
680
715
 
681
716
  testMeadow.doRead(tmpQuery,
682
717
  function(pError, pQuery, pRecord)
683
718
  {
684
719
  Expect(pRecord.IDAnimal)
685
- .to.equal(5);
720
+ .to.equal(6);
686
721
  Expect(pRecord.Deleted)
687
722
  .to.equal(1);
688
723
  // Note: Meadow's Delete behavior does not propagate IDUser
@@ -707,7 +742,7 @@ suite
707
742
  function(pError, pQuery, pCount)
708
743
  {
709
744
  Expect(pCount)
710
- .to.equal(4);
745
+ .to.equal(5);
711
746
  fDone();
712
747
  }
713
748
  );
@@ -729,7 +764,7 @@ suite
729
764
  var testMeadow = newMeadow().setIDUser(777);
730
765
 
731
766
  var tmpQuery = testMeadow.query
732
- .addFilter('IDAnimal', 5);
767
+ .addFilter('IDAnimal', 6);
733
768
 
734
769
  testMeadow.doUndelete(tmpQuery,
735
770
  function(pError, pQuery, pCount)
@@ -750,13 +785,13 @@ suite
750
785
  var testMeadow = newMeadow();
751
786
 
752
787
  var tmpQuery = testMeadow.query
753
- .addFilter('IDAnimal', 5);
788
+ .addFilter('IDAnimal', 6);
754
789
 
755
790
  testMeadow.doRead(tmpQuery,
756
791
  function(pError, pQuery, pRecord)
757
792
  {
758
793
  Expect(pRecord.IDAnimal)
759
- .to.equal(5);
794
+ .to.equal(6);
760
795
  Expect(pRecord.Deleted)
761
796
  .to.equal(0);
762
797
  Expect(pRecord.Name)
@@ -778,7 +813,7 @@ suite
778
813
  function(pError, pQuery, pCount)
779
814
  {
780
815
  Expect(pCount)
781
- .to.equal(5);
816
+ .to.equal(6);
782
817
  fDone();
783
818
  }
784
819
  );
@@ -835,12 +870,12 @@ suite
835
870
  Expect(pRecord.Make).to.equal('Toyota');
836
871
  Expect(pRecord.IDVehicle).to.equal(1);
837
872
 
838
- // Now verify FableTest scope still has its 5 records
873
+ // Now verify FableTest scope still has its 6 records
839
874
  var animalMeadow = newMeadow();
840
875
  animalMeadow.doCount(animalMeadow.query,
841
876
  function(pError2, pQuery2, pCount)
842
877
  {
843
- Expect(pCount).to.equal(5);
878
+ Expect(pCount).to.equal(6);
844
879
  fDone();
845
880
  }
846
881
  );
@@ -238,7 +238,9 @@ function generateTestHTML()
238
238
  " DeleteDate TEXT," +
239
239
  " DeletingIDUser INTEGER NOT NULL DEFAULT 0," +
240
240
  " Name TEXT NOT NULL DEFAULT ''," +
241
- " Type TEXT NOT NULL DEFAULT ''" +
241
+ " Type TEXT NOT NULL DEFAULT ''," +
242
+ " Metadata TEXT," +
243
+ " ExtraDataJSON TEXT" +
242
244
  ");"
243
245
  );
244
246
  var ins = db.prepare(
@@ -264,7 +266,9 @@ function generateTestHTML()
264
266
  { Column: 'UpdatingIDUser', Type: 'UpdateIDUser' },
265
267
  { Column: 'Deleted', Type: 'Deleted' },
266
268
  { Column: 'DeletingIDUser', Type: 'DeleteIDUser' },
267
- { Column: 'DeleteDate', Type: 'DeleteDate' }
269
+ { Column: 'DeleteDate', Type: 'DeleteDate' },
270
+ { Column: 'Metadata', Type: 'JSON' },
271
+ { Column: 'ExtraData', Type: 'JSONProxy', StorageColumn: 'ExtraDataJSON' }
268
272
  ];
269
273
  var animalJsonSchema = {
270
274
  title: 'Animal',
@@ -282,7 +286,8 @@ function generateTestHTML()
282
286
  CreateDate: false, CreatingIDUser: 0,
283
287
  UpdateDate: false, UpdatingIDUser: 0,
284
288
  Deleted: 0, DeleteDate: false, DeletingIDUser: 0,
285
- Name: 'Unknown', Type: 'Unclassified'
289
+ Name: 'Unknown', Type: 'Unclassified',
290
+ Metadata: {}, ExtraData: {}
286
291
  };
287
292
 
288
293
  function newMeadow()
@@ -69,7 +69,9 @@ var _AnimalSchema = (
69
69
  { Column: "UpdatingIDUser", Type:"UpdateIDUser" },
70
70
  { Column: "Deleted", Type:"Deleted" },
71
71
  { Column: "DeletingIDUser", Type:"DeleteIDUser" },
72
- { Column: "DeleteDate", Type:"DeleteDate" }
72
+ { Column: "DeleteDate", Type:"DeleteDate" },
73
+ { Column: "Metadata", Type:"JSON" },
74
+ { Column: "ExtraData", Type:"JSONProxy", StorageColumn:"ExtraDataJSON" }
73
75
  ]);
74
76
  var _AnimalDefault = (
75
77
  {
@@ -85,7 +87,10 @@ var _AnimalDefault = (
85
87
  DeletingIDUser: 0,
86
88
 
87
89
  Name: 'Unknown',
88
- Type: 'Unclassified'
90
+ Type: 'Unclassified',
91
+
92
+ Metadata: {},
93
+ ExtraData: {}
89
94
  });
90
95
 
91
96
  suite
@@ -137,7 +142,9 @@ suite
137
142
  " DeleteDate TEXT," +
138
143
  " DeletingIDUser INTEGER NOT NULL DEFAULT 0," +
139
144
  " Name TEXT NOT NULL DEFAULT ''," +
140
- " Type TEXT NOT NULL DEFAULT ''" +
145
+ " Type TEXT NOT NULL DEFAULT ''," +
146
+ " Metadata TEXT," +
147
+ " ExtraDataJSON TEXT" +
141
148
  ");"
142
149
  );
143
150
 
@@ -214,6 +221,37 @@ suite
214
221
  )
215
222
  }
216
223
  );
224
+ test
225
+ (
226
+ 'Create a record with JSON data',
227
+ function(fDone)
228
+ {
229
+ var testMeadow = newMeadow().setIDUser(90210);
230
+
231
+ var tmpQuery = testMeadow.query.clone().setLogLevel(5)
232
+ .addRecord({Name:'Moose', Type:'Mammal', Metadata: { habitat: 'forest', weight: 500 }, ExtraData: { endangered: false, population: 'stable' }});
233
+
234
+ testMeadow.doCreate(tmpQuery,
235
+ function(pError, pQuery, pQueryRead, pRecord)
236
+ {
237
+ // We should have a record with JSON data ....
238
+ Expect(pRecord.Name)
239
+ .to.equal('Moose');
240
+ Expect(pRecord.Metadata)
241
+ .to.be.an('object');
242
+ Expect(pRecord.Metadata.habitat)
243
+ .to.equal('forest');
244
+ Expect(pRecord.ExtraData)
245
+ .to.be.an('object');
246
+ Expect(pRecord.ExtraData.endangered)
247
+ .to.equal(false);
248
+ // The storage column should not be exposed on the marshaled record
249
+ Expect(pRecord).to.not.have.property('ExtraDataJSON');
250
+ fDone();
251
+ }
252
+ )
253
+ }
254
+ );
217
255
  test
218
256
  (
219
257
  'Create a record in the database with Deleted bit already set',
@@ -384,9 +422,9 @@ suite
384
422
  testMeadow.doCount(testMeadow.query,
385
423
  function(pError, pQuery, pRecord)
386
424
  {
387
- // There should be 5 non-deleted records (3 not deleted seeded + Blastoise + Gertrude)
425
+ // There should be 6 non-deleted records (3 not deleted seeded + Blastoise + Moose + Gertrude)
388
426
  Expect(pRecord)
389
- .to.equal(5);
427
+ .to.equal(6);
390
428
  Expect(pQuery.parameters.result.executed)
391
429
  .to.equal(true);
392
430
  testMeadow.fable.settings.QueryThresholdWarnTime = 1000;
@@ -75,7 +75,9 @@ var _AnimalSchema = (
75
75
  { Column: "UpdatingIDUser", Type:"UpdateIDUser" },
76
76
  { Column: "Deleted", Type:"Deleted" },
77
77
  { Column: "DeletingIDUser", Type:"DeleteIDUser" },
78
- { Column: "DeleteDate", Type:"DeleteDate" }
78
+ { Column: "DeleteDate", Type:"DeleteDate" },
79
+ { Column: "Metadata", Type:"JSON" },
80
+ { Column: "ExtraData", Type:"JSONProxy", StorageColumn:"ExtraDataJSON" }
79
81
  ]);
80
82
  var _AnimalDefault = (
81
83
  {
@@ -91,7 +93,10 @@ var _AnimalDefault = (
91
93
  DeletingIDUser: 0,
92
94
 
93
95
  Name: 'Unknown',
94
- Type: 'Unclassified'
96
+ Type: 'Unclassified',
97
+
98
+ Metadata: {},
99
+ ExtraData: {}
95
100
  });
96
101
 
97
102
  suite
@@ -156,7 +161,9 @@ suite
156
161
  " DeleteDate TEXT," +
157
162
  " DeletingIDUser INTEGER NOT NULL DEFAULT 0," +
158
163
  " Name TEXT NOT NULL DEFAULT ''," +
159
- " Type TEXT NOT NULL DEFAULT ''" +
164
+ " Type TEXT NOT NULL DEFAULT ''," +
165
+ " Metadata TEXT," +
166
+ " ExtraDataJSON TEXT" +
160
167
  ");"
161
168
  );
162
169
 
@@ -251,6 +258,37 @@ suite
251
258
  )
252
259
  }
253
260
  );
261
+ test
262
+ (
263
+ 'Create a record with JSON data',
264
+ function(fDone)
265
+ {
266
+ var testMeadow = newMeadow().setIDUser(90210);
267
+
268
+ var tmpQuery = testMeadow.query.clone().setLogLevel(5)
269
+ .addRecord({Name:'Moose', Type:'Mammal', Metadata: { habitat: 'forest', weight: 500 }, ExtraData: { endangered: false, population: 'stable' }});
270
+
271
+ testMeadow.doCreate(tmpQuery,
272
+ function(pError, pQuery, pQueryRead, pRecord)
273
+ {
274
+ // We should have a record with JSON data ....
275
+ Expect(pRecord.Name)
276
+ .to.equal('Moose');
277
+ Expect(pRecord.Metadata)
278
+ .to.be.an('object');
279
+ Expect(pRecord.Metadata.habitat)
280
+ .to.equal('forest');
281
+ Expect(pRecord.ExtraData)
282
+ .to.be.an('object');
283
+ Expect(pRecord.ExtraData.endangered)
284
+ .to.equal(false);
285
+ // The storage column should not be exposed on the marshaled record
286
+ Expect(pRecord).to.not.have.property('ExtraDataJSON');
287
+ fDone();
288
+ }
289
+ )
290
+ }
291
+ );
254
292
  test
255
293
  (
256
294
  'Create a record in the database with Deleted bit already set',
@@ -421,9 +459,9 @@ suite
421
459
  testMeadow.doCount(testMeadow.query,
422
460
  function(pError, pQuery, pRecord)
423
461
  {
424
- // There should be 5 non-deleted records (3 not deleted seeded + Blastoise + Gertrude)
462
+ // There should be 6 non-deleted records (3 not deleted seeded + Blastoise + Moose + Gertrude)
425
463
  Expect(pRecord)
426
- .to.equal(5);
464
+ .to.equal(6);
427
465
  Expect(pQuery.parameters.result.executed)
428
466
  .to.equal(true);
429
467
  testMeadow.fable.settings.QueryThresholdWarnTime = 1000;