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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxhound",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A Database Query generation library.",
5
5
  "main": "source/FoxHound.js",
6
6
  "scripts": {
@@ -58,7 +58,6 @@
58
58
  "vinyl-source-stream": "^2.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "fable": "^3.0.2",
62
- "underscore": "1.13.6"
61
+ "fable": "^3.0.4"
63
62
  }
64
63
  }
@@ -1,24 +1,12 @@
1
1
  /**
2
2
  * FoxHound Query Generation Library
3
- *
4
3
  * @license MIT
5
- *
6
4
  * @author Steven Velozo <steven@velozo.com>
7
- * @module FoxHound
8
5
  */
9
6
 
10
- // We use Underscore.js for utility
11
- var libUnderscore = require('underscore');
12
-
13
7
  // Load our base parameters skeleton object
14
- var baseParameters = require('./Parameters.js');
8
+ const baseParameters = require('./Parameters.js');
15
9
 
16
- /**
17
- * FoxHound Query Generation Library Main Class
18
- *
19
- * @class FoxHound
20
- * @constructor
21
- */
22
10
  var FoxHound = function()
23
11
  {
24
12
  function createNew(pFable, pFromParameters)
@@ -39,6 +27,8 @@ var FoxHound = function()
39
27
  // piece of internal state that is important to operation.
40
28
  var _Parameters = false;
41
29
 
30
+ var _Dialects = require('./Foxhound-Dialects.js');
31
+
42
32
  // The unique identifier for a query
43
33
  var _UUID = _Fable.getUUID();
44
34
 
@@ -93,7 +83,7 @@ var FoxHound = function()
93
83
  */
94
84
  var resetParameters = function()
95
85
  {
96
- _Parameters = libUnderscore.extend({}, baseParameters, _DefaultParameters);
86
+ _Parameters = _Fable.Utility.extend({}, baseParameters, _DefaultParameters);
97
87
  _Parameters.query = ({
98
88
  disableAutoIdentity: false,
99
89
  disableAutoDateStamp: false,
@@ -127,7 +117,7 @@ var FoxHound = function()
127
117
  */
128
118
  var mergeParameters = function(pFromParameters)
129
119
  {
130
- _Parameters = libUnderscore.extend({}, _Parameters, pFromParameters);
120
+ _Parameters = _Fable.Utility.extend({}, _Parameters, pFromParameters);
131
121
  return this;
132
122
  };
133
123
 
@@ -644,26 +634,24 @@ var FoxHound = function()
644
634
  */
645
635
  var setDialect = function(pDialectName)
646
636
  {
637
+
647
638
  if (typeof(pDialectName) !== 'string')
648
639
  {
649
640
  _Fable.log.warn('Dialect set to English - invalid name', {queryUUID:_UUID, parameters:_Parameters, invalidDialect:pDialectName});
650
641
  return setDialect('English');
651
642
  }
652
643
 
653
- var tmpDialectModuleFile = './dialects/'+pDialectName+'/FoxHound-Dialect-'+pDialectName+'.js';
654
-
655
- try
644
+ if (_Dialects.hasOwnProperty(pDialectName))
656
645
  {
657
- var tmpDialectModule = require(tmpDialectModuleFile);
658
- _Dialect = tmpDialectModule;
646
+ _Dialect = _Dialects[pDialectName](_Fable);
659
647
  if (_LogLevel > 2)
660
648
  {
661
- _Fable.log.info('Dialog set to: '+pDialectName, {queryUUID:_UUID, parameters:_Parameters, dialectModuleFile:tmpDialectModuleFile});
649
+ _Fable.log.info('Dialog set to: '+pDialectName, {queryUUID:_UUID, parameters:_Parameters});
662
650
  }
663
651
  }
664
- catch (pError)
652
+ else
665
653
  {
666
- _Fable.log.error('Dialect not set - require load problem', {queryUUID:_UUID, parameters:_Parameters, dialectModuleFile:tmpDialectModuleFile, invalidDialect:pDialectName, error:pError});
654
+ _Fable.log.error('Dialect not set - unknown dialect "'+pDialectName+"'", {queryUUID:_UUID, parameters:_Parameters, invalidDialect:pDialectName});
667
655
  setDialect('English');
668
656
  }
669
657
 
@@ -931,4 +919,4 @@ var FoxHound = function()
931
919
  return createNew();
932
920
  };
933
921
 
934
- module.exports = new FoxHound();
922
+ module.exports = FoxHound();
@@ -0,0 +1,15 @@
1
+ getDialects = () =>
2
+ {
3
+ let tmpDialects = {};
4
+
5
+ tmpDialects.ALASQL = require('./dialects/ALASQL/FoxHound-Dialect-ALASQL.js');
6
+ tmpDialects.English = require('./dialects/English/FoxHound-Dialect-English.js');
7
+ tmpDialects.MeadowEndpoints = require('./dialects/MeadowEndpoints/FoxHound-Dialect-MeadowEndpoints.js');
8
+ tmpDialects.MySQL = require('./dialects/MySQL/FoxHound-Dialect-MySQL.js');
9
+
10
+ tmpDialects.default = tmpDialects.English;
11
+
12
+ return tmpDialects;
13
+ }
14
+
15
+ module.exports = getDialects();
@@ -15,10 +15,14 @@
15
15
  * @author Steven Velozo <steven@velozo.com>
16
16
  * @class FoxHoundDialectALASQL
17
17
  */
18
- var libUnderscore = require('underscore');
19
18
 
20
- var FoxHoundDialectALASQL = function()
19
+ var FoxHoundDialectALASQL = function(pFable)
21
20
  {
21
+ //Request time from SQL server with microseconds resolution
22
+ const SQL_NOW = "NOW(3)";
23
+
24
+ _Fable = pFable;
25
+
22
26
  /**
23
27
  * Generate a table name from the scope.
24
28
  *
@@ -779,7 +783,7 @@ var FoxHoundDialectALASQL = function()
779
783
  {
780
784
  try
781
785
  {
782
- var tmpQueryTemplate = libUnderscore.template(pParameters.queryOverride);
786
+ var tmpQueryTemplate = _Fable.Utility.template(pParameters.queryOverride);
783
787
  return tmpQueryTemplate({FieldList:tmpFieldList, TableName:tmpTableName, Where:tmpWhere, OrderBy:tmpOrderBy, Limit:tmpLimit, Distinct: tmpOptDistinct, _Params: pParameters});
784
788
  }
785
789
  catch (pError)
@@ -860,7 +864,7 @@ var FoxHoundDialectALASQL = function()
860
864
  {
861
865
  try
862
866
  {
863
- var tmpQueryTemplate = libUnderscore.template(pParameters.queryOverride);
867
+ var tmpQueryTemplate = _Fable.Utility.template(pParameters.queryOverride);
864
868
  return tmpQueryTemplate({FieldList:[], TableName:tmpTableName, Where:tmpWhere, OrderBy:'', Limit:'', Distinct: tmpOptDistinct, _Params: pParameters});
865
869
  }
866
870
  catch (pError)
@@ -898,4 +902,4 @@ var FoxHoundDialectALASQL = function()
898
902
  return tmpDialect;
899
903
  };
900
904
 
901
- module.exports = new FoxHoundDialectALASQL();
905
+ module.exports = FoxHoundDialectALASQL;
@@ -93,4 +93,4 @@ var FoxHoundDialectEnglish = function()
93
93
  return tmpDialect;
94
94
  };
95
95
 
96
- module.exports = new FoxHoundDialectEnglish();
96
+ module.exports = FoxHoundDialectEnglish;
@@ -6,7 +6,6 @@
6
6
  * @author Steven Velozo <steven@velozo.com>
7
7
  * @class FoxHoundDialectMeadowEndpoints
8
8
  */
9
- var libUnderscore = require('underscore');
10
9
 
11
10
  var FoxHoundDialectMeadowEndpoints = function()
12
11
  {
@@ -477,4 +476,4 @@ var FoxHoundDialectMeadowEndpoints = function()
477
476
  return tmpDialect;
478
477
  };
479
478
 
480
- module.exports = new FoxHoundDialectMeadowEndpoints();
479
+ module.exports = FoxHoundDialectMeadowEndpoints;
@@ -15,13 +15,14 @@
15
15
  * @author Steven Velozo <steven@velozo.com>
16
16
  * @class FoxHoundDialectMySQL
17
17
  */
18
- var libUnderscore = require('underscore');
19
18
 
20
- var FoxHoundDialectMySQL = function()
19
+ var FoxHoundDialectMySQL = function(pFable)
21
20
  {
22
21
  //Request time from SQL server with microseconds resolution
23
22
  const SQL_NOW = "NOW(3)";
24
23
 
24
+ _Fable = pFable;
25
+
25
26
  /**
26
27
  * Generate a table name from the scope
27
28
  *
@@ -832,7 +833,7 @@ var FoxHoundDialectMySQL = function()
832
833
  {
833
834
  try
834
835
  {
835
- var tmpQueryTemplate = libUnderscore.template(pParameters.queryOverride);
836
+ var tmpQueryTemplate = _Fable.Utility.template(pParameters.queryOverride);
836
837
  return tmpQueryTemplate({FieldList:tmpFieldList, TableName:tmpTableName, Where:tmpWhere, Join:tmpJoin, OrderBy:tmpOrderBy, Limit:tmpLimit, Distinct: tmpOptDistinct, _Params: pParameters});
837
838
  }
838
839
  catch (pError)
@@ -917,7 +918,7 @@ var FoxHoundDialectMySQL = function()
917
918
  {
918
919
  try
919
920
  {
920
- var tmpQueryTemplate = libUnderscore.template(pParameters.queryOverride);
921
+ var tmpQueryTemplate = _Fable.Utility.template(pParameters.queryOverride);
921
922
  return tmpQueryTemplate({FieldList:[], TableName:tmpTableName, Where:tmpWhere, OrderBy:'', Limit:'', Distinct: tmpOptDistinct, _Params: pParameters});
922
923
  }
923
924
  catch (pError)
@@ -955,4 +956,4 @@ var FoxHoundDialectMySQL = function()
955
956
  return tmpDialect;
956
957
  };
957
958
 
958
- module.exports = new FoxHoundDialectMySQL();
959
+ module.exports = FoxHoundDialectMySQL;