foxhound 2.0.5 → 2.0.7

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.5",
3
+ "version": "2.0.7",
4
4
  "description": "A Database Query generation library.",
5
5
  "main": "source/FoxHound.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  var FoxHoundDialectMSSQL = function(pFable)
20
20
  {
21
21
  //Request time from SQL server with microseconds resolution
22
- const SQL_NOW = "NOW(3)";
22
+ const SQL_NOW = "GETUTCDATE()";
23
23
 
24
24
  _Fable = pFable;
25
25
 
@@ -704,7 +704,7 @@ var FoxHoundDialectMSSQL = function(pFable)
704
704
  }
705
705
  }
706
706
 
707
- if (tmpCurrentColumn > 0)
707
+ if ((tmpCurrentColumn > 0) && (tmpCreateSet != ''))
708
708
  {
709
709
  tmpCreateSet += ',';
710
710
  }
@@ -730,7 +730,8 @@ var FoxHoundDialectMSSQL = function(pFable)
730
730
  else
731
731
  {
732
732
  // This is an autoidentity, so we don't parameterize it and just pass in NULL
733
- tmpCreateSet += ' NULL';
733
+ //tmpCreateSet += ' NULL';
734
+ // For MSSQL we have to skip this. NULL and DEFAULT both error for autoidentities.
734
735
  }
735
736
  break;
736
737
  case 'AutoGUID':
@@ -846,6 +847,17 @@ var FoxHoundDialectMSSQL = function(pFable)
846
847
  }
847
848
  switch (tmpSchemaEntry.Type)
848
849
  {
850
+ // We skip these for MSSQL on INSERT or they cause an error for some versions (different errors for different versions)
851
+ case 'AutoIdentity':
852
+ if (pParameters.query.disableAutoIdentity)
853
+ {
854
+ if (tmpCreateSet != '')
855
+ {
856
+ tmpCreateSet += ',';
857
+ }
858
+ tmpCreateSet += ' '+tmpColumn;
859
+ }
860
+ continue;
849
861
  default:
850
862
  if (tmpCreateSet != '')
851
863
  {
@@ -493,7 +493,7 @@ suite
493
493
  // This is the query generated by the MSSQL dialect
494
494
  _Fable.log.trace('Create Query', tmpQuery.query);
495
495
  Expect(tmpQuery.query.body)
496
- .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);");
496
+ .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);");
497
497
  }
498
498
  );
499
499
  test
@@ -525,7 +525,7 @@ suite
525
525
  // This is the query generated by the MSSQL dialect
526
526
  _Fable.log.trace('Create Query', tmpQuery.query);
527
527
  Expect(tmpQuery.query.body)
528
- .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);");
528
+ .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);");
529
529
  }
530
530
  );
531
531
  test
@@ -676,7 +676,7 @@ suite
676
676
  // This is the query generated by the MSSQL dialect
677
677
  _Fable.log.trace('Delete Query', tmpQuery.query);
678
678
  Expect(tmpQuery.query.body)
679
- .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;');
679
+ .to.equal('UPDATE Animal SET UpdateDate = GETUTCDATE(), Deleted = 1, DeletingIDUser = @DeletingIDUser_2, DeleteDate = GETUTCDATE() WHERE IDAnimal = @IDAnimal_w0 AND Animal.Deleted = @Deleted_w1;');
680
680
  }
681
681
  );
682
682
  test
@@ -704,7 +704,7 @@ suite
704
704
  // This is the query generated by the MSSQL dialect
705
705
  _Fable.log.trace('Update Query', tmpQuery.query);
706
706
  Expect(tmpQuery.query.body)
707
- .to.equal('UPDATE Animal SET GUIDAnimal = @GUIDAnimal_0, UpdateDate = NOW(3), UpdatingIDUser = @UpdatingIDUser_2, Name = @Name_3, Age = @Age_4 WHERE IDAnimal = @IDAnimal_w0;');
707
+ .to.equal('UPDATE Animal SET GUIDAnimal = @GUIDAnimal_0, UpdateDate = GETUTCDATE(), UpdatingIDUser = @UpdatingIDUser_2, Name = @Name_3, Age = @Age_4 WHERE IDAnimal = @IDAnimal_w0;');
708
708
  }
709
709
  );
710
710
  test
@@ -788,7 +788,7 @@ suite
788
788
  // This is the query generated by the MSSQL dialect
789
789
  _Fable.log.trace('Update Query', tmpQuery.query);
790
790
  Expect(tmpQuery.query.body)
791
- .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;');
791
+ .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;');
792
792
  }
793
793
  );
794
794
  test
@@ -810,7 +810,7 @@ suite
810
810
  // This is the query generated by the MSSQL dialect
811
811
  _Fable.log.trace('Delete Query', tmpQuery.query);
812
812
  Expect(tmpQuery.query.body)
813
- .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;');
813
+ .to.equal('UPDATE Animal SET UpdateDate = GETUTCDATE(), Deleted = 1, DeletingIDUser = @DeletingIDUser_2, DeleteDate = GETUTCDATE() WHERE IDAnimal = @IDAnimal_w0 AND Animal.Deleted = @Deleted_w1;');
814
814
  }
815
815
  );
816
816
  test
@@ -853,7 +853,7 @@ suite
853
853
  // This is the query generated by the MSSQL dialect
854
854
  _Fable.log.trace('Undelete Query', tmpQuery.query);
855
855
  Expect(tmpQuery.query.body)
856
- .to.equal('UPDATE Animal SET UpdateDate = NOW(3), UpdatingIDUser = @UpdatingIDUser_1, Deleted = 0 WHERE IDAnimal = @IDAnimal_w0;');
856
+ .to.equal('UPDATE Animal SET UpdateDate = GETUTCDATE(), UpdatingIDUser = @UpdatingIDUser_1, Deleted = 0 WHERE IDAnimal = @IDAnimal_w0;');
857
857
  }
858
858
  );
859
859
  test