foxhound 2.0.9 → 2.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxhound",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "A Database Query generation library.",
5
5
  "main": "source/FoxHound.js",
6
6
  "scripts": {
@@ -38,7 +38,7 @@ var FoxHoundDialectMSSQL = function(pFable)
38
38
  {
39
39
  pParameters.query.parameterTypes = {};
40
40
  }
41
- return ' '+pParameters.scope;
41
+ return ' ['+pParameters.scope+']';
42
42
  };
43
43
 
44
44
  var generateMSSQLParameterTypeEntry = function(pParameters, pColumnParameterName, pColumn)
@@ -152,7 +152,7 @@ var FoxHoundDialectMSSQL = function(pFable)
152
152
  // this means there is no autoincrementing unique ID column; treat as above
153
153
  return '';
154
154
  }
155
- const qualifiedIDColumn = `${tmpTableName}.${idColumn.Column}`;
155
+ const qualifiedIDColumn = `${idColumn.Column}`;
156
156
  return ` ${generateSafeFieldName(qualifiedIDColumn)}`;
157
157
  }
158
158
 
@@ -184,7 +184,15 @@ var FoxHoundDialectMSSQL = function(pFable)
184
184
  */
185
185
  var generateSafeFieldName = function(pFieldName)
186
186
  {
187
- return pFieldName;
187
+ // This isn't great but best we can do for MS SQL needing brackets around field names for reserved keywords
188
+ if ((pFieldName != '*') && (pFieldName.indexOf('[') < 0) && pFieldName.indexOf('.') < 0)
189
+ {
190
+ return '['+pFieldName+']';
191
+ }
192
+ else
193
+ {
194
+ return pFieldName;
195
+ }
188
196
  }
189
197
 
190
198
  /**
@@ -238,7 +246,7 @@ var FoxHoundDialectMSSQL = function(pFable)
238
246
  //if not, we need to add it
239
247
  tmpFilter.push(
240
248
  {
241
- Column: tmpTableName + '.' + tmpSchemaEntry.Column,
249
+ Column: tmpSchemaEntry.Column,
242
250
  Operator: '=',
243
251
  Value: 0,
244
252
  Connector: 'AND',
@@ -287,7 +295,7 @@ var FoxHoundDialectMSSQL = function(pFable)
287
295
  {
288
296
  tmpColumnParameter = tmpFilter[i].Parameter+'_w'+i;
289
297
  // Add the column name, operator and parameter name to the list of where value parenthetical
290
- tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator+' ( @'+tmpColumnParameter+' )';
298
+ tmpWhere += ' ['+tmpFilter[i].Column+'] '+tmpFilter[i].Operator+' ( @'+tmpColumnParameter+' )';
291
299
  pParameters.query.parameters[tmpColumnParameter] = tmpFilter[i].Value;
292
300
  // Find the column in the schema
293
301
  generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpFilter[i].Parameter)
@@ -295,18 +303,18 @@ var FoxHoundDialectMSSQL = function(pFable)
295
303
  else if (tmpFilter[i].Operator === 'IS NULL')
296
304
  {
297
305
  // IS NULL is a special operator which doesn't require a value, or parameter
298
- tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator;
306
+ tmpWhere += ' ['+tmpFilter[i].Column+'] '+tmpFilter[i].Operator;
299
307
  }
300
308
  else if (tmpFilter[i].Operator === 'IS NOT NULL')
301
309
  {
302
310
  // IS NOT NULL is a special operator which doesn't require a value, or parameter
303
- tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator;
311
+ tmpWhere += ' ['+tmpFilter[i].Column+'] '+tmpFilter[i].Operator;
304
312
  }
305
313
  else
306
314
  {
307
315
  tmpColumnParameter = tmpFilter[i].Parameter+'_w'+i;
308
316
  // Add the column name, operator and parameter name to the list of where value parenthetical
309
- tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator+' @'+tmpColumnParameter;
317
+ tmpWhere += ' ['+tmpFilter[i].Column+'] '+tmpFilter[i].Operator+' @'+tmpColumnParameter;
310
318
  pParameters.query.parameters[tmpColumnParameter] = tmpFilter[i].Value;
311
319
  generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpFilter[i].Parameter)
312
320
  }
@@ -340,7 +348,7 @@ var FoxHoundDialectMSSQL = function(pFable)
340
348
  {
341
349
  tmpOrderClause += ',';
342
350
  }
343
- tmpOrderClause += ' '+tmpOrderBy[i].Column;
351
+ tmpOrderClause += ' ['+tmpOrderBy[i].Column+']';
344
352
 
345
353
  if (tmpOrderBy[i].Direction == 'Descending')
346
354
  {
@@ -419,7 +427,7 @@ var FoxHoundDialectMSSQL = function(pFable)
419
427
  //verify that all required fields are valid
420
428
  if (join.Type && join.Table && join.From && join.To)
421
429
  {
422
- tmpJoinClause += ` ${join.Type} ${join.Table} ON ${join.From} = ${join.To}`;
430
+ tmpJoinClause += ` ${join.Type} [${join.Table}] ON ${join.From} = ${join.To}`;
423
431
  }
424
432
  }
425
433
 
@@ -494,20 +502,20 @@ var FoxHoundDialectMSSQL = function(pFable)
494
502
  {
495
503
  case 'UpdateDate':
496
504
  // This is an autoidentity, so we don't parameterize it and just pass in NULL
497
- tmpUpdate += ' '+tmpColumn+' = ' + SQL_NOW;
505
+ tmpUpdate += ' ['+tmpColumn+'] = ' + SQL_NOW;
498
506
  break;
499
507
  case 'UpdateIDUser':
500
508
  // This is the user ID, which we hope is in the query.
501
509
  // This is how to deal with a normal column
502
510
  var tmpColumnParameter = tmpColumn+'_'+tmpCurrentColumn;
503
- tmpUpdate += ' '+tmpColumn+' = @'+tmpColumnParameter;
511
+ tmpUpdate += ' ['+tmpColumn+'] = @'+tmpColumnParameter;
504
512
  // Set the query parameter
505
513
  pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser;
506
514
  generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpColumn)
507
515
  break;
508
516
  default:
509
517
  var tmpColumnDefaultParameter = tmpColumn+'_'+tmpCurrentColumn;
510
- tmpUpdate += ' '+tmpColumn+' = @'+tmpColumnDefaultParameter;
518
+ tmpUpdate += ' ['+tmpColumn+'] = @'+tmpColumnDefaultParameter;
511
519
 
512
520
  // Set the query parameter
513
521
  pParameters.query.parameters[tmpColumnDefaultParameter] = tmpRecords[0][tmpColumn];
@@ -561,21 +569,21 @@ var FoxHoundDialectMSSQL = function(pFable)
561
569
  switch (tmpSchemaEntry.Type)
562
570
  {
563
571
  case 'Deleted':
564
- tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = 1';
572
+ tmpUpdateSql = ' ['+tmpSchemaEntry.Column+'] = 1';
565
573
  tmpHasDeletedField = true; //this field is required in order for query to be built
566
574
  break;
567
575
  case 'DeleteDate':
568
- tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = ' + SQL_NOW;
576
+ tmpUpdateSql = ' ['+tmpSchemaEntry.Column+'] = ' + SQL_NOW;
569
577
  break;
570
578
  case 'UpdateDate':
571
579
  // Delete operation is an Update, so we should stamp the update time
572
- tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = ' + SQL_NOW;
580
+ tmpUpdateSql = ' ['+tmpSchemaEntry.Column+'] = ' + SQL_NOW;
573
581
  break;
574
582
  case 'DeleteIDUser':
575
583
  // This is the user ID, which we hope is in the query.
576
584
  // This is how to deal with a normal column
577
585
  var tmpColumnParameter = tmpSchemaEntry.Column+'_'+tmpCurrentColumn;
578
- tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = @'+tmpColumnParameter;
586
+ tmpUpdateSql = ' ['+tmpSchemaEntry.Column+'] = @'+tmpColumnParameter;
579
587
  // Set the query parameter
580
588
  pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser;
581
589
  generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpSchemaEntry)
@@ -634,16 +642,16 @@ var FoxHoundDialectMSSQL = function(pFable)
634
642
  switch (tmpSchemaEntry.Type)
635
643
  {
636
644
  case 'Deleted':
637
- tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = 0';
645
+ tmpUpdateSql = ' ['+tmpSchemaEntry.Column+'] = 0';
638
646
  tmpHasDeletedField = true; //this field is required in order for query to be built
639
647
  break;
640
648
  case 'UpdateDate':
641
649
  // The undelete operation is an Update, so we should stamp the update time
642
- tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = ' + SQL_NOW;
650
+ tmpUpdateSql = ' ['+tmpSchemaEntry.Column+'] = ' + SQL_NOW;
643
651
  break;
644
652
  case 'UpdateIDUser':
645
653
  var tmpColumnParameter = tmpSchemaEntry.Column+'_'+tmpCurrentColumn;
646
- tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = @'+tmpColumnParameter;
654
+ tmpUpdateSql = ' ['+tmpSchemaEntry.Column+'] = @'+tmpColumnParameter;
647
655
  pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser;
648
656
  generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpSchemaEntry)
649
657
  break;
@@ -872,7 +880,7 @@ var FoxHoundDialectMSSQL = function(pFable)
872
880
  {
873
881
  tmpCreateSet += ',';
874
882
  }
875
- tmpCreateSet += ' '+tmpColumn;
883
+ tmpCreateSet += ' ['+tmpColumn+']';
876
884
  }
877
885
  continue;
878
886
  default:
@@ -880,7 +888,7 @@ var FoxHoundDialectMSSQL = function(pFable)
880
888
  {
881
889
  tmpCreateSet += ',';
882
890
  }
883
- tmpCreateSet += ' '+tmpColumn;
891
+ tmpCreateSet += ' ['+tmpColumn+']';
884
892
  break;
885
893
  }
886
894
  }
@@ -91,7 +91,7 @@ suite
91
91
  // This is the query generated by the MSSQL dialect
92
92
  _Fable.log.trace('Create Query', tmpQuery.query);
93
93
  Expect(tmpQuery.query.body)
94
- .to.equal("INSERT INTO Animal ( IDAnimal, Name, Age) VALUES ( @IDAnimal_0, @Name_1, @Age_2);");
94
+ .to.equal("INSERT INTO [Animal] ( [IDAnimal], [Name], [Age]) VALUES ( @IDAnimal_0, @Name_1, @Age_2);");
95
95
  }
96
96
  );
97
97
  test
@@ -122,7 +122,7 @@ suite
122
122
  // This is the query generated by the MSSQL dialect
123
123
  _Fable.log.trace('Simple Select Query', tmpQuery.query);
124
124
  Expect(tmpQuery.query.body)
125
- .to.equal('SELECT Animal.* FROM Animal ORDER BY Cost DESC;');
125
+ .to.equal('SELECT [Animal].* FROM [Animal] ORDER BY [Cost] DESC;');
126
126
  }
127
127
  );
128
128
  test
@@ -138,7 +138,7 @@ suite
138
138
  // This is the query generated by the MSSQL dialect
139
139
  _Fable.log.trace('Simple Select Query', tmpQuery.query);
140
140
  Expect(tmpQuery.query.body)
141
- .to.equal('SELECT Animal.* FROM Animal WITH(INDEX(AnimalIndex_1)) ORDER BY Cost DESC;');
141
+ .to.equal('SELECT [Animal].* FROM [Animal] WITH(INDEX(AnimalIndex_1)) ORDER BY [Cost] DESC;');
142
142
  }
143
143
  );
144
144
  test
@@ -154,7 +154,7 @@ suite
154
154
  // This is the query generated by the MSSQL dialect
155
155
  _Fable.log.trace('Simple Select Query', tmpQuery.query);
156
156
  Expect(tmpQuery.query.body)
157
- .to.equal('SELECT DISTINCT Animal.* FROM Animal ORDER BY Cost DESC;');
157
+ .to.equal('SELECT DISTINCT [Animal].* FROM [Animal] ORDER BY [Cost] DESC;');
158
158
  }
159
159
  );
160
160
  test
@@ -176,7 +176,7 @@ suite
176
176
  // This is the query generated by the MSSQL dialect
177
177
  _Fable.log.trace('Select Query', tmpQuery.query);
178
178
  Expect(tmpQuery.query.body)
179
- .to.equal('SELECT Name, Age, Cost FROM Animal WHERE Age = @Age_w0 ORDER BY Age, Cost OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
179
+ .to.equal('SELECT [Name], [Age], [Cost] FROM [Animal] WHERE [Age] = @Age_w0 ORDER BY [Age], [Cost] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
180
180
  );
181
181
  test
182
182
  (
@@ -188,7 +188,7 @@ suite
188
188
  .setScope('Animal')
189
189
  .setCap(10)
190
190
  .setBegin(0)
191
- .setDataElements(['*', 'Name', 'Age', 'Cost', 'Animal.*'])
191
+ .setDataElements(['*', 'Name', 'Age', 'Cost', '[Animal].*'])
192
192
  .setSort([{Column:'Age',Direction:'Ascending'}])
193
193
  .setFilter({Column:'Age',Operator:'=',Value:'15',Connector:'AND',Parameter:'Age'});
194
194
  tmpQuery.addSort('Cost');
@@ -197,7 +197,7 @@ suite
197
197
  // This is the query generated by the MSSQL dialect
198
198
  _Fable.log.trace('Select Query', tmpQuery.query);
199
199
  Expect(tmpQuery.query.body)
200
- .to.equal('SELECT *, Name, Age, Cost, Animal.* FROM Animal WHERE Age = @Age_w0 ORDER BY Age, Cost OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
200
+ .to.equal('SELECT *, [Name], [Age], [Cost], [Animal].* FROM [Animal] WHERE [Age] = @Age_w0 ORDER BY [Age], [Cost] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
201
201
  );
202
202
  test
203
203
  (
@@ -222,7 +222,7 @@ suite
222
222
  // This is the query generated by the MSSQL dialect
223
223
  _Fable.log.trace('Select Query', tmpQuery.query);
224
224
  Expect(tmpQuery.query.body)
225
- .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 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
225
+ .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] OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
226
226
  }
227
227
  );
228
228
  test
@@ -244,7 +244,7 @@ suite
244
244
  // This is the query generated by the MSSQL dialect
245
245
  _Fable.log.trace('Custom Select Query', tmpQuery.query);
246
246
  Expect(tmpQuery.query.body)
247
- .to.equal('SELECT Name, Age * 5, Cost FROM Animal WHERE Age = @Age_w0 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
247
+ .to.equal('SELECT Name, Age * 5, Cost FROM [Animal] WHERE [Age] = @Age_w0 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
248
248
  );
249
249
  test
250
250
  (
@@ -266,7 +266,7 @@ suite
266
266
  // This is the query generated by the MSSQL dialect
267
267
  _Fable.log.trace('Custom Select Query', tmpQuery.query);
268
268
  Expect(tmpQuery.query.body)
269
- .to.equal('SELECT Name, Age * 5, Cost FROM Animal WHERE Age = @Age_w0 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
269
+ .to.equal('SELECT Name, Age * 5, Cost FROM [Animal] WHERE [Age] = @Age_w0 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
270
270
  );
271
271
  test
272
272
  (
@@ -323,7 +323,7 @@ suite
323
323
  // This is the query generated by the MSSQL dialect
324
324
  _Fable.log.trace('Custom Count Query', tmpQuery.query);
325
325
  Expect(tmpQuery.query.body)
326
- .to.equal('SELECT COUNT(*) AS RowCount FROM Animal WHERE Age = @Age_w0;');
326
+ .to.equal('SELECT COUNT(*) AS RowCount FROM [Animal] WHERE [Age] = @Age_w0;');
327
327
  }
328
328
  );
329
329
  test
@@ -342,7 +342,7 @@ suite
342
342
  // This is the query generated by the MSSQL dialect
343
343
  _Fable.log.trace('Custom Count Query', tmpQuery.query);
344
344
  Expect(tmpQuery.query.body)
345
- .to.equal('SELECT COUNT(*) AS RowCount FROM Animal WITH(INDEX(AnimalIndex_1)) WHERE Age = @Age_w0;');
345
+ .to.equal('SELECT COUNT(*) AS RowCount FROM [Animal] WITH(INDEX(AnimalIndex_1)) WHERE [Age] = @Age_w0;');
346
346
  }
347
347
  );
348
348
  test
@@ -361,7 +361,7 @@ suite
361
361
  // This is the query generated by the MSSQL dialect
362
362
  _Fable.log.trace('Custom Count Query', tmpQuery.query);
363
363
  Expect(tmpQuery.query.body)
364
- .to.equal('SELECT COUNT(*) AS RowCount FROM Animal WHERE Age = @Age_w0;');
364
+ .to.equal('SELECT COUNT(*) AS RowCount FROM [Animal] WHERE [Age] = @Age_w0;');
365
365
  }
366
366
  );
367
367
  test
@@ -380,7 +380,7 @@ suite
380
380
  // This is the query generated by the MSSQL dialect
381
381
  _Fable.log.trace('Update Query', tmpQuery.query);
382
382
  Expect(tmpQuery.query.body)
383
- .to.equal('UPDATE Animal SET Age = @Age_0, Color = @Color_1 WHERE IDAnimal = @IDAnimal_w0;');
383
+ .to.equal('UPDATE [Animal] SET [Age] = @Age_0, [Color] = @Color_1 WHERE [IDAnimal] = @IDAnimal_w0;');
384
384
  }
385
385
  );
386
386
  test
@@ -414,7 +414,7 @@ suite
414
414
  // This is the query generated by the MSSQL dialect
415
415
  _Fable.log.trace('Delete Query', tmpQuery.query);
416
416
  Expect(tmpQuery.query.body)
417
- .to.equal('DELETE FROM Animal WHERE IDAnimal = @IDAnimal_w0;');
417
+ .to.equal('DELETE FROM [Animal] WHERE [IDAnimal] = @IDAnimal_w0;');
418
418
  }
419
419
  );
420
420
  test
@@ -432,7 +432,7 @@ suite
432
432
  // This is the query generated by the MSSQL dialect
433
433
  _Fable.log.trace('Count Query', tmpQuery.query);
434
434
  Expect(tmpQuery.query.body)
435
- .to.equal('SELECT COUNT(*) AS Row_Count FROM Animal WITH(INDEX(AnimalIndex_1));');
435
+ .to.equal('SELECT COUNT(*) AS Row_Count FROM [Animal] WITH(INDEX(AnimalIndex_1));');
436
436
  }
437
437
  );
438
438
  test
@@ -452,7 +452,7 @@ suite
452
452
  _Fable.log.trace('Count Distinct Query', tmpQuery.query);
453
453
  Expect(tmpQuery.query.body)
454
454
  // RowCount is a reserved word for MSSQL so we need to change it to Row_Count
455
- .to.equal('SELECT COUNT(DISTINCT Animal.IDAnimal) AS Row_Count FROM Animal WHERE Animal.Deleted = @Deleted_w0;');
455
+ .to.equal('SELECT COUNT(DISTINCT [IDAnimal]) AS Row_Count FROM [Animal] WHERE [Deleted] = @Deleted_w0;');
456
456
  }
457
457
  );
458
458
  test
@@ -470,7 +470,7 @@ suite
470
470
  // This is the query generated by the MSSQL dialect
471
471
  _Fable.log.trace('Count Distinct Query', tmpQuery.query);
472
472
  Expect(tmpQuery.query.body)
473
- .to.equal('SELECT COUNT(*) AS Row_Count FROM Animal;');
473
+ .to.equal('SELECT COUNT(*) AS Row_Count FROM [Animal];');
474
474
  }
475
475
  );
476
476
  test
@@ -489,7 +489,7 @@ suite
489
489
  // This is the query generated by the MSSQL dialect
490
490
  _Fable.log.trace('Count Distinct Query', tmpQuery.query);
491
491
  Expect(tmpQuery.query.body)
492
- .to.equal('SELECT COUNT(DISTINCT Name) AS Row_Count FROM Animal;');
492
+ .to.equal('SELECT COUNT(DISTINCT [Name]) AS Row_Count FROM [Animal];');
493
493
  }
494
494
  );
495
495
  }
@@ -529,7 +529,7 @@ suite
529
529
  // This is the query generated by the MSSQL dialect
530
530
  _Fable.log.trace('Create Query', tmpQuery.query);
531
531
  Expect(tmpQuery.query.body)
532
- .to.equal("INSERT INTO Animal ( GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, Name, Age) VALUES ( @GUIDAnimal_1, GETUTCDATE(), @CreatingIDUser_3, GETUTCDATE(), @UpdatingIDUser_5, @Deleted_6, @Name_7, @Age_8);");
532
+ .to.equal("INSERT INTO [Animal] ( [GUIDAnimal], [CreateDate], [CreatingIDUser], [UpdateDate], [UpdatingIDUser], [Deleted], [Name], [Age]) VALUES ( @GUIDAnimal_1, GETUTCDATE(), @CreatingIDUser_3, GETUTCDATE(), @UpdatingIDUser_5, @Deleted_6, @Name_7, @Age_8);");
533
533
  }
534
534
  );
535
535
  test
@@ -561,7 +561,7 @@ suite
561
561
  // This is the query generated by the MSSQL dialect
562
562
  _Fable.log.trace('Create Query', tmpQuery.query);
563
563
  Expect(tmpQuery.query.body)
564
- .to.equal("INSERT INTO Animal ( GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, Name, Age) VALUES ( @GUIDAnimal_1, GETUTCDATE(), @CreatingIDUser_3, GETUTCDATE(), @UpdatingIDUser_5, @Deleted_6, @Name_7, @Age_8);");
564
+ .to.equal("INSERT INTO [Animal] ( [GUIDAnimal], [CreateDate], [CreatingIDUser], [UpdateDate], [UpdatingIDUser], [Deleted], [Name], [Age]) VALUES ( @GUIDAnimal_1, GETUTCDATE(), @CreatingIDUser_3, GETUTCDATE(), @UpdatingIDUser_5, @Deleted_6, @Name_7, @Age_8);");
565
565
  }
566
566
  );
567
567
  test
@@ -597,7 +597,7 @@ suite
597
597
  // This is the query generated by the MSSQL dialect
598
598
  _Fable.log.trace('Create Query (AutoIdentity disabled)', tmpQuery.query);
599
599
  Expect(tmpQuery.query.body)
600
- .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);");
600
+ .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);");
601
601
  }
602
602
  );
603
603
  test
@@ -618,7 +618,7 @@ suite
618
618
  // This is the query generated by the MSSQL dialect
619
619
  _Fable.log.trace('Select Query', tmpQuery.query);
620
620
  Expect(tmpQuery.query.body)
621
- .to.equal('SELECT Name, Age, Cost FROM Animal WHERE Animal.Deleted = @Deleted_w0 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
621
+ .to.equal('SELECT [Name], [Age], [Cost] FROM [Animal] WHERE [Deleted] = @Deleted_w0 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
622
622
  }
623
623
  );
624
624
  test
@@ -640,7 +640,7 @@ suite
640
640
  // This is the query generated by the MSSQL dialect
641
641
  _Fable.log.trace('Select Query', tmpQuery.query);
642
642
  Expect(tmpQuery.query.body)
643
- .to.equal('SELECT DISTINCT Name, Age, Cost FROM Animal WHERE Animal.Deleted = @Deleted_w0 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
643
+ .to.equal('SELECT DISTINCT [Name], [Age], [Cost] FROM [Animal] WHERE [Deleted] = @Deleted_w0 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
644
644
  }
645
645
  );
646
646
  test
@@ -669,7 +669,7 @@ suite
669
669
  // This is the query generated by the MSSQL dialect
670
670
  _Fable.log.trace('Select Query', tmpQuery.query);
671
671
  Expect(tmpQuery.query.body)
672
- .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 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
672
+ .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 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
673
673
  }
674
674
  );
675
675
  test
@@ -691,7 +691,7 @@ suite
691
691
  // This is the query generated by the MSSQL dialect
692
692
  _Fable.log.trace('Select Query', tmpQuery.query);
693
693
  Expect(tmpQuery.query.body)
694
- .to.equal('SELECT Name, Age, Cost FROM Animal OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
694
+ .to.equal('SELECT [Name], [Age], [Cost] FROM [Animal] OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;');
695
695
  }
696
696
  );
697
697
  test
@@ -712,7 +712,7 @@ suite
712
712
  // This is the query generated by the MSSQL dialect
713
713
  _Fable.log.trace('Delete Query', tmpQuery.query);
714
714
  Expect(tmpQuery.query.body)
715
- .to.equal('UPDATE Animal SET UpdateDate = GETUTCDATE(), Deleted = 1, DeletingIDUser = @DeletingIDUser_2, DeleteDate = GETUTCDATE() WHERE IDAnimal = @IDAnimal_w0 AND Animal.Deleted = @Deleted_w1;');
715
+ .to.equal('UPDATE [Animal] SET [UpdateDate] = GETUTCDATE(), [Deleted] = 1, [DeletingIDUser] = @DeletingIDUser_2, [DeleteDate] = GETUTCDATE() WHERE [IDAnimal] = @IDAnimal_w0 AND [Deleted] = @Deleted_w1;');
716
716
  }
717
717
  );
718
718
  test
@@ -740,7 +740,7 @@ suite
740
740
  // This is the query generated by the MSSQL dialect
741
741
  _Fable.log.trace('Update Query', tmpQuery.query);
742
742
  Expect(tmpQuery.query.body)
743
- .to.equal('UPDATE Animal SET GUIDAnimal = @GUIDAnimal_0, UpdateDate = GETUTCDATE(), UpdatingIDUser = @UpdatingIDUser_2, Name = @Name_3, Age = @Age_4 WHERE IDAnimal = @IDAnimal_w0;');
743
+ .to.equal('UPDATE [Animal] SET [GUIDAnimal] = @GUIDAnimal_0, [UpdateDate] = GETUTCDATE(), [UpdatingIDUser] = @UpdatingIDUser_2, [Name] = @Name_3, [Age] = @Age_4 WHERE [IDAnimal] = @IDAnimal_w0;');
744
744
  }
745
745
  );
746
746
  test
@@ -770,7 +770,7 @@ suite
770
770
  // This is the query generated by the MSSQL dialect
771
771
  _Fable.log.trace('Update Query', tmpQuery.query);
772
772
  Expect(tmpQuery.query.body)
773
- .to.equal('UPDATE Animal SET GUIDAnimal = @GUIDAnimal_0, Name = @Name_1, Age = @Age_2 WHERE IDAnimal = @IDAnimal_w0;');
773
+ .to.equal('UPDATE [Animal] SET [GUIDAnimal] = @GUIDAnimal_0, [Name] = @Name_1, [Age] = @Age_2 WHERE [IDAnimal] = @IDAnimal_w0;');
774
774
  }
775
775
  );
776
776
  test
@@ -792,7 +792,7 @@ suite
792
792
  // This is the query generated by the MSSQL dialect
793
793
  _Fable.log.trace('Delete Query', tmpQuery.query);
794
794
  Expect(tmpQuery.query.body)
795
- .to.equal('DELETE FROM Animal WHERE IDAnimal = @IDAnimal_w0;');
795
+ .to.equal('DELETE FROM [Animal] WHERE [IDAnimal] = @IDAnimal_w0;');
796
796
  }
797
797
  );
798
798
  test
@@ -824,7 +824,7 @@ suite
824
824
  // This is the query generated by the MSSQL dialect
825
825
  _Fable.log.trace('Update Query', tmpQuery.query);
826
826
  Expect(tmpQuery.query.body)
827
- .to.equal('UPDATE Animal SET GUIDAnimal = @GUIDAnimal_0, UpdateDate = GETUTCDATE(), UpdatingIDUser = @UpdatingIDUser_2, Deleted = @Deleted_3, Name = @Name_4, Age = @Age_5 WHERE IDAnimal = @IDAnimal_w0 AND Deleted = @Deleted_w1;');
827
+ .to.equal('UPDATE [Animal] SET [GUIDAnimal] = @GUIDAnimal_0, [UpdateDate] = GETUTCDATE(), [UpdatingIDUser] = @UpdatingIDUser_2, [Deleted] = @Deleted_3, [Name] = @Name_4, [Age] = @Age_5 WHERE [IDAnimal] = @IDAnimal_w0 AND [Deleted] = @Deleted_w1;');
828
828
  }
829
829
  );
830
830
  test
@@ -846,7 +846,7 @@ suite
846
846
  // This is the query generated by the MSSQL dialect
847
847
  _Fable.log.trace('Delete Query', tmpQuery.query);
848
848
  Expect(tmpQuery.query.body)
849
- .to.equal('UPDATE Animal SET UpdateDate = GETUTCDATE(), Deleted = 1, DeletingIDUser = @DeletingIDUser_2, DeleteDate = GETUTCDATE() WHERE IDAnimal = @IDAnimal_w0 AND Animal.Deleted = @Deleted_w1;');
849
+ .to.equal('UPDATE [Animal] SET [UpdateDate] = GETUTCDATE(), [Deleted] = 1, [DeletingIDUser] = @DeletingIDUser_2, [DeleteDate] = GETUTCDATE() WHERE [IDAnimal] = @IDAnimal_w0 AND [Deleted] = @Deleted_w1;');
850
850
  }
851
851
  );
852
852
  test
@@ -869,7 +869,7 @@ suite
869
869
  // This is the query generated by the MSSQL dialect
870
870
  _Fable.log.trace('Delete Query', tmpQuery.query);
871
871
  Expect(tmpQuery.query.body)
872
- .to.equal('DELETE FROM Animal WHERE IDAnimal = @IDAnimal_w0;');
872
+ .to.equal('DELETE FROM [Animal] WHERE [IDAnimal] = @IDAnimal_w0;');
873
873
  }
874
874
  );
875
875
  test
@@ -889,7 +889,7 @@ suite
889
889
  // This is the query generated by the MSSQL dialect
890
890
  _Fable.log.trace('Undelete Query', tmpQuery.query);
891
891
  Expect(tmpQuery.query.body)
892
- .to.equal('UPDATE Animal SET UpdateDate = GETUTCDATE(), UpdatingIDUser = @UpdatingIDUser_1, Deleted = 0 WHERE IDAnimal = @IDAnimal_w0;');
892
+ .to.equal('UPDATE [Animal] SET [UpdateDate] = GETUTCDATE(), [UpdatingIDUser] = @UpdatingIDUser_1, [Deleted] = 0 WHERE [IDAnimal] = @IDAnimal_w0;');
893
893
  }
894
894
  );
895
895
  test
@@ -937,7 +937,7 @@ suite
937
937
  // This is the query generated by the MSSQL dialect
938
938
  _Fable.log.trace('Select Query', tmpQuery.query);
939
939
  Expect(tmpQuery.query.body)
940
- .to.equal('SELECT Name, Age, Cost FROM Animal INNER JOIN Test ON Test.IDAnimal = Animal.IDAnimal WHERE Age = @Age_w0 ORDER BY Age OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
940
+ .to.equal('SELECT [Name], [Age], [Cost] FROM [Animal] INNER JOIN [Test] ON Test.IDAnimal = Animal.IDAnimal WHERE [Age] = @Age_w0 ORDER BY [Age] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
941
941
  );
942
942
  test
943
943
  (
@@ -960,7 +960,7 @@ suite
960
960
  // This is the query generated by the MSSQL dialect
961
961
  _Fable.log.trace('Select Query', tmpQuery.query);
962
962
  Expect(tmpQuery.query.body)
963
- .to.equal('SELECT DISTINCT Name, Age, Cost FROM Animal INNER JOIN Test ON Test.IDAnimal = Animal.IDAnimal WHERE Age = @Age_w0 ORDER BY Age OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
963
+ .to.equal('SELECT DISTINCT [Name], [Age], [Cost] FROM [Animal] INNER JOIN [Test] ON Test.IDAnimal = Animal.IDAnimal WHERE [Age] = @Age_w0 ORDER BY [Age] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); }
964
964
  );
965
965
  test
966
966
  (
@@ -977,7 +977,7 @@ suite
977
977
  // This is the query generated by the MSSQL dialect
978
978
  _Fable.log.trace('Select Query', tmpQuery.query);
979
979
  Expect(tmpQuery.query.body)
980
- .to.equal('SELECT Animal.* FROM Animal;'); //bad join is ignored, warn log is generated
980
+ .to.equal('SELECT [Animal].* FROM [Animal];'); //bad join is ignored, warn log is generated
981
981
  }
982
982
  );
983
983
  }