foxhound 2.0.9 → 2.0.11
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/Dockerfile_LUXURYCode +6 -10
- package/package.json +53 -61
- package/source/Foxhound-Dialects.js +2 -1
- package/source/dialects/MicrosoftSQL/FoxHound-Dialect-MSSQL.js +30 -22
- package/source/dialects/SQLite/FoxHound-Dialect-SQLite.js +908 -0
- package/test/FoxHound-Dialect-SQLite_tests.js +901 -0
- package/test/Foxhound-Dialect-MSSQL_tests.js +37 -37
- package/gulpfile.js +0 -83
package/Dockerfile_LUXURYCode
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Use the codercom/code-server image
|
|
2
2
|
FROM codercom/code-server:latest
|
|
3
|
-
|
|
3
|
+
LABEL org.opencontainers.image.authors="steven@velozo.com"
|
|
4
4
|
|
|
5
5
|
VOLUME /home/coder/.config
|
|
6
6
|
VOLUME /home/coder/.vscode
|
|
@@ -9,13 +9,7 @@ RUN echo "...installing debian dependencies..."
|
|
|
9
9
|
RUN sudo apt update
|
|
10
10
|
RUN sudo apt install vim curl tmux -y
|
|
11
11
|
|
|
12
|
-
RUN echo "Building
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
RUN echo "...mapping library specific volumes..."
|
|
16
|
-
# Volume mappings for RETOLD:Foxhound library
|
|
17
|
-
VOLUME /home/coder/foxhound
|
|
18
|
-
# VOLUME /home/coder/foxhound/node_modules
|
|
12
|
+
RUN echo "Building development image..."
|
|
19
13
|
|
|
20
14
|
RUN echo "...installing vscode extensions..."
|
|
21
15
|
|
|
@@ -55,8 +49,10 @@ RUN code-server --install-extension eamodio.gitlens
|
|
|
55
49
|
# An easy on the eyes color theme
|
|
56
50
|
# RUN code-server --install-extension daylerees.rainglow
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
RUN echo "...mapping library specific volumes..."
|
|
53
|
+
|
|
54
|
+
# Volume mapping for code
|
|
55
|
+
VOLUME /home/coder/foxhound
|
|
60
56
|
|
|
61
57
|
SHELL ["/bin/bash", "-c"]
|
|
62
58
|
USER coder
|
package/package.json
CHANGED
|
@@ -1,63 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
2
|
+
"name": "foxhound",
|
|
3
|
+
"version": "2.0.11",
|
|
4
|
+
"description": "A Database Query generation library.",
|
|
5
|
+
"main": "source/FoxHound.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node source/FoxHound.js",
|
|
8
|
+
"test": "npx mocha -u tdd -R spec",
|
|
9
|
+
"tests": "npx mocha -u tdd --exit -R spec --grep",
|
|
10
|
+
"coverage": "npx nyc --reporter=lcov --reporter=text-lcov npx mocha -- -u tdd -R spec",
|
|
11
|
+
"build": "npx quack build",
|
|
12
|
+
"docker-dev-build": "docker build ./ -f Dockerfile_LUXURYCode -t foxhound-image:local",
|
|
13
|
+
"docker-dev-run": "docker run -it -d --name foxhound-dev -p 24238:8080 -p 42889:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/foxhound\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" foxhound-image:local",
|
|
14
|
+
"docker-dev-shell": "docker exec -it foxhound-dev /bin/bash"
|
|
15
|
+
},
|
|
16
|
+
"mocha": {
|
|
17
|
+
"diff": true,
|
|
18
|
+
"extension": [
|
|
19
|
+
"js"
|
|
20
|
+
],
|
|
21
|
+
"package": "./package.json",
|
|
22
|
+
"reporter": "spec",
|
|
23
|
+
"slow": "75",
|
|
24
|
+
"timeout": "5000",
|
|
25
|
+
"ui": "tdd",
|
|
26
|
+
"watch-files": [
|
|
27
|
+
"source/**/*.js",
|
|
28
|
+
"test/**/*.js"
|
|
29
|
+
],
|
|
30
|
+
"watch-ignore": [
|
|
31
|
+
"lib/vendor"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/stevenvelozo/foxhound.git"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"orm",
|
|
40
|
+
"dal",
|
|
41
|
+
"query"
|
|
18
42
|
],
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "https://github.com/stevenvelozo/foxhound.git"
|
|
35
|
-
},
|
|
36
|
-
"keywords": [
|
|
37
|
-
"orm",
|
|
38
|
-
"dal",
|
|
39
|
-
"query"
|
|
40
|
-
],
|
|
41
|
-
"author": "Steven Velozo <steven@velozo.com> (http://velozo.com/)",
|
|
42
|
-
"license": "MIT",
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/stevenvelozo/foxhound/issues"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://github.com/stevenvelozo/foxhound",
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"browserify": "^17.0.0",
|
|
49
|
-
"chai": "4.3.7",
|
|
50
|
-
"gulp": "^4.0.2",
|
|
51
|
-
"gulp-babel": "^8.0.0",
|
|
52
|
-
"gulp-sourcemaps": "^3.0.0",
|
|
53
|
-
"gulp-terser": "^2.1.0",
|
|
54
|
-
"gulp-util": "^3.0.8",
|
|
55
|
-
"mocha": "10.2.0",
|
|
56
|
-
"nyc": "^15.1.0",
|
|
57
|
-
"vinyl-buffer": "^1.0.1",
|
|
58
|
-
"vinyl-source-stream": "^2.0.0"
|
|
59
|
-
},
|
|
60
|
-
"dependencies": {
|
|
61
|
-
"fable": "^3.0.11"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
43
|
+
"author": "Steven Velozo <steven@velozo.com> (http://velozo.com/)",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/stevenvelozo/foxhound/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/stevenvelozo/foxhound",
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"quackage": "^1.0.29"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"fable": "^3.0.119"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -2,8 +2,9 @@ getDialects = () =>
|
|
|
2
2
|
{
|
|
3
3
|
let tmpDialects = {};
|
|
4
4
|
|
|
5
|
-
tmpDialects.ALASQL = require('./dialects/ALASQL/FoxHound-Dialect-ALASQL.js');
|
|
6
5
|
tmpDialects.English = require('./dialects/English/FoxHound-Dialect-English.js');
|
|
6
|
+
tmpDialects.SQLite = require('./dialects/SQLite/FoxHound-Dialect-SQLite.js');
|
|
7
|
+
tmpDialects.ALASQL = require('./dialects/ALASQL/FoxHound-Dialect-ALASQL.js');
|
|
7
8
|
tmpDialects.MeadowEndpoints = require('./dialects/MeadowEndpoints/FoxHound-Dialect-MeadowEndpoints.js');
|
|
8
9
|
tmpDialects.MySQL = require('./dialects/MySQL/FoxHound-Dialect-MySQL.js');
|
|
9
10
|
tmpDialects.MSSQL = require('./dialects/MicrosoftSQL/FoxHound-Dialect-MSSQL.js');
|
|
@@ -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 = `${
|
|
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
|
-
|
|
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:
|
|
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
|
}
|