foxhound 2.0.19 → 2.0.21
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/README.md +3 -2
- package/docs/README.md +32 -11
- package/docs/_cover.md +3 -2
- package/docs/_sidebar.md +21 -1
- package/docs/_topbar.md +7 -0
- package/docs/api/README.md +73 -0
- package/docs/api/addFilter.md +170 -0
- package/docs/api/addJoin.md +128 -0
- package/docs/api/addRecord.md +108 -0
- package/docs/api/addSort.md +109 -0
- package/docs/api/behaviorFlags.md +123 -0
- package/docs/api/buildQuery.md +146 -0
- package/docs/api/clone.md +115 -0
- package/docs/api/queryOverrides.md +82 -0
- package/docs/api/setCap.md +115 -0
- package/docs/api/setDataElements.md +95 -0
- package/docs/api/setDialect.md +78 -0
- package/docs/api/setDistinct.md +76 -0
- package/docs/api/setIDUser.md +80 -0
- package/docs/api/setScope.md +70 -0
- package/docs/architecture.md +134 -42
- package/docs/dialects/README.md +2 -0
- package/docs/dialects/postgresql.md +126 -0
- package/docs/quickstart.md +196 -0
- package/docs/retold-catalog.json +40 -1
- package/docs/retold-keyword-index.json +7996 -2630
- package/package.json +2 -2
- package/source/Foxhound-Dialects.js +1 -1
- package/source/dialects/PostgreSQL/FoxHound-Dialect-PostgreSQL.js +17 -17
- package/test/FoxHound-Dialect-PostgreSQL_tests.js +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxhound",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"description": "A Database Query generation library.",
|
|
5
5
|
"main": "source/FoxHound.js",
|
|
6
6
|
"scripts": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/stevenvelozo/foxhound",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"quackage": "^1.0.
|
|
50
|
+
"quackage": "^1.0.60"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"fable": "^3.1.63"
|
|
@@ -176,7 +176,7 @@ var FoxHoundDialectPostgreSQL = function(pFable)
|
|
|
176
176
|
{
|
|
177
177
|
tmpFilter.push(
|
|
178
178
|
{
|
|
179
|
-
Column:
|
|
179
|
+
Column: generateSafeFieldName(pParameters.scope + '.' + tmpSchemaEntry.Column),
|
|
180
180
|
Operator: '=',
|
|
181
181
|
Value: 0,
|
|
182
182
|
Connector: 'AND',
|
|
@@ -220,21 +220,21 @@ var FoxHoundDialectPostgreSQL = function(pFable)
|
|
|
220
220
|
else if (tmpFilter[i].Operator === 'IN' || tmpFilter[i].Operator === "NOT IN")
|
|
221
221
|
{
|
|
222
222
|
tmpColumnParameter = tmpFilter[i].Parameter+'_w'+i;
|
|
223
|
-
tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator+' ( :'+tmpColumnParameter+' )';
|
|
223
|
+
tmpWhere += ' '+generateSafeFieldName(tmpFilter[i].Column)+' '+tmpFilter[i].Operator+' ( :'+tmpColumnParameter+' )';
|
|
224
224
|
pParameters.query.parameters[tmpColumnParameter] = tmpFilter[i].Value;
|
|
225
225
|
}
|
|
226
226
|
else if (tmpFilter[i].Operator === 'IS NULL')
|
|
227
227
|
{
|
|
228
|
-
tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator;
|
|
228
|
+
tmpWhere += ' '+generateSafeFieldName(tmpFilter[i].Column)+' '+tmpFilter[i].Operator;
|
|
229
229
|
}
|
|
230
230
|
else if (tmpFilter[i].Operator === 'IS NOT NULL')
|
|
231
231
|
{
|
|
232
|
-
tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator;
|
|
232
|
+
tmpWhere += ' '+generateSafeFieldName(tmpFilter[i].Column)+' '+tmpFilter[i].Operator;
|
|
233
233
|
}
|
|
234
234
|
else
|
|
235
235
|
{
|
|
236
236
|
tmpColumnParameter = tmpFilter[i].Parameter+'_w'+i;
|
|
237
|
-
tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator+' :'+tmpColumnParameter;
|
|
237
|
+
tmpWhere += ' '+generateSafeFieldName(tmpFilter[i].Column)+' '+tmpFilter[i].Operator+' :'+tmpColumnParameter;
|
|
238
238
|
pParameters.query.parameters[tmpColumnParameter] = tmpFilter[i].Value;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
@@ -267,7 +267,7 @@ var FoxHoundDialectPostgreSQL = function(pFable)
|
|
|
267
267
|
{
|
|
268
268
|
tmpOrderClause += ',';
|
|
269
269
|
}
|
|
270
|
-
tmpOrderClause += ' '+tmpOrderBy[i].Column;
|
|
270
|
+
tmpOrderClause += ' '+generateSafeFieldName(tmpOrderBy[i].Column);
|
|
271
271
|
|
|
272
272
|
if (tmpOrderBy[i].Direction == 'Descending')
|
|
273
273
|
{
|
|
@@ -387,16 +387,16 @@ var FoxHoundDialectPostgreSQL = function(pFable)
|
|
|
387
387
|
switch (tmpSchemaEntry.Type)
|
|
388
388
|
{
|
|
389
389
|
case 'UpdateDate':
|
|
390
|
-
tmpUpdate += ' '+tmpColumn+' = ' + SQL_NOW;
|
|
390
|
+
tmpUpdate += ' '+generateSafeFieldName(tmpColumn)+' = ' + SQL_NOW;
|
|
391
391
|
break;
|
|
392
392
|
case 'UpdateIDUser':
|
|
393
393
|
var tmpColumnParameter = tmpColumn+'_'+tmpCurrentColumn;
|
|
394
|
-
tmpUpdate += ' '+tmpColumn+' = :'+tmpColumnParameter;
|
|
394
|
+
tmpUpdate += ' '+generateSafeFieldName(tmpColumn)+' = :'+tmpColumnParameter;
|
|
395
395
|
pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser;
|
|
396
396
|
break;
|
|
397
397
|
default:
|
|
398
398
|
var tmpColumnDefaultParameter = tmpColumn+'_'+tmpCurrentColumn;
|
|
399
|
-
tmpUpdate += ' '+tmpColumn+' = :'+tmpColumnDefaultParameter;
|
|
399
|
+
tmpUpdate += ' '+generateSafeFieldName(tmpColumn)+' = :'+tmpColumnDefaultParameter;
|
|
400
400
|
pParameters.query.parameters[tmpColumnDefaultParameter] = tmpRecords[0][tmpColumn];
|
|
401
401
|
break;
|
|
402
402
|
}
|
|
@@ -440,18 +440,18 @@ var FoxHoundDialectPostgreSQL = function(pFable)
|
|
|
440
440
|
switch (tmpSchemaEntry.Type)
|
|
441
441
|
{
|
|
442
442
|
case 'Deleted':
|
|
443
|
-
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = 1';
|
|
443
|
+
tmpUpdateSql = ' '+generateSafeFieldName(tmpSchemaEntry.Column)+' = 1';
|
|
444
444
|
tmpHasDeletedField = true;
|
|
445
445
|
break;
|
|
446
446
|
case 'DeleteDate':
|
|
447
|
-
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = ' + SQL_NOW;
|
|
447
|
+
tmpUpdateSql = ' '+generateSafeFieldName(tmpSchemaEntry.Column)+' = ' + SQL_NOW;
|
|
448
448
|
break;
|
|
449
449
|
case 'UpdateDate':
|
|
450
|
-
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = ' + SQL_NOW;
|
|
450
|
+
tmpUpdateSql = ' '+generateSafeFieldName(tmpSchemaEntry.Column)+' = ' + SQL_NOW;
|
|
451
451
|
break;
|
|
452
452
|
case 'DeleteIDUser':
|
|
453
453
|
var tmpColumnParameter = tmpSchemaEntry.Column+'_'+tmpCurrentColumn;
|
|
454
|
-
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = :'+tmpColumnParameter;
|
|
454
|
+
tmpUpdateSql = ' '+generateSafeFieldName(tmpSchemaEntry.Column)+' = :'+tmpColumnParameter;
|
|
455
455
|
pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser;
|
|
456
456
|
break;
|
|
457
457
|
default:
|
|
@@ -501,15 +501,15 @@ var FoxHoundDialectPostgreSQL = function(pFable)
|
|
|
501
501
|
switch (tmpSchemaEntry.Type)
|
|
502
502
|
{
|
|
503
503
|
case 'Deleted':
|
|
504
|
-
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = 0';
|
|
504
|
+
tmpUpdateSql = ' '+generateSafeFieldName(tmpSchemaEntry.Column)+' = 0';
|
|
505
505
|
tmpHasDeletedField = true;
|
|
506
506
|
break;
|
|
507
507
|
case 'UpdateDate':
|
|
508
|
-
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = ' + SQL_NOW;
|
|
508
|
+
tmpUpdateSql = ' '+generateSafeFieldName(tmpSchemaEntry.Column)+' = ' + SQL_NOW;
|
|
509
509
|
break;
|
|
510
510
|
case 'UpdateIDUser':
|
|
511
511
|
var tmpColumnParameter = tmpSchemaEntry.Column+'_'+tmpCurrentColumn;
|
|
512
|
-
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = :'+tmpColumnParameter;
|
|
512
|
+
tmpUpdateSql = ' '+generateSafeFieldName(tmpSchemaEntry.Column)+' = :'+tmpColumnParameter;
|
|
513
513
|
pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser;
|
|
514
514
|
break;
|
|
515
515
|
default:
|
|
@@ -702,7 +702,7 @@ var FoxHoundDialectPostgreSQL = function(pFable)
|
|
|
702
702
|
{
|
|
703
703
|
tmpCreateSet += ',';
|
|
704
704
|
}
|
|
705
|
-
tmpCreateSet += ' '+tmpColumn;
|
|
705
|
+
tmpCreateSet += ' '+generateSafeFieldName(tmpColumn);
|
|
706
706
|
break;
|
|
707
707
|
}
|
|
708
708
|
}
|
|
@@ -87,7 +87,7 @@ suite
|
|
|
87
87
|
tmpQuery.buildCreateQuery();
|
|
88
88
|
_Fable.log.trace('Create Query', tmpQuery.query);
|
|
89
89
|
Expect(tmpQuery.query.body)
|
|
90
|
-
.to.equal('INSERT INTO "Animal" ( IDAnimal, Name, Age) VALUES ( :IDAnimal_0, :Name_1, :Age_2) RETURNING *;');
|
|
90
|
+
.to.equal('INSERT INTO "Animal" ( "IDAnimal", "Name", "Age") VALUES ( :IDAnimal_0, :Name_1, :Age_2) RETURNING *;');
|
|
91
91
|
}
|
|
92
92
|
);
|
|
93
93
|
test
|
|
@@ -135,7 +135,7 @@ suite
|
|
|
135
135
|
tmpQuery.buildReadQuery();
|
|
136
136
|
_Fable.log.trace('Simple Select Query', tmpQuery.query);
|
|
137
137
|
Expect(tmpQuery.query.body)
|
|
138
|
-
.to.equal('SELECT "Animal".* FROM "Animal" ORDER BY Cost DESC;');
|
|
138
|
+
.to.equal('SELECT "Animal".* FROM "Animal" ORDER BY "Cost" DESC;');
|
|
139
139
|
}
|
|
140
140
|
);
|
|
141
141
|
test
|
|
@@ -149,7 +149,7 @@ suite
|
|
|
149
149
|
tmpQuery.buildReadQuery();
|
|
150
150
|
_Fable.log.trace('Simple Select Query', tmpQuery.query);
|
|
151
151
|
Expect(tmpQuery.query.body)
|
|
152
|
-
.to.equal('SELECT DISTINCT "Animal".* FROM "Animal" ORDER BY Cost DESC;');
|
|
152
|
+
.to.equal('SELECT DISTINCT "Animal".* FROM "Animal" ORDER BY "Cost" DESC;');
|
|
153
153
|
}
|
|
154
154
|
);
|
|
155
155
|
test
|
|
@@ -169,7 +169,7 @@ suite
|
|
|
169
169
|
tmpQuery.buildReadQuery();
|
|
170
170
|
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
171
171
|
Expect(tmpQuery.query.body)
|
|
172
|
-
.to.equal('SELECT "Name", "Age", "Cost" FROM "Animal" WHERE Age = :Age_w0 ORDER BY Age, Cost LIMIT 10 OFFSET 0;');
|
|
172
|
+
.to.equal('SELECT "Name", "Age", "Cost" FROM "Animal" WHERE "Age" = :Age_w0 ORDER BY "Age", "Cost" LIMIT 10 OFFSET 0;');
|
|
173
173
|
}
|
|
174
174
|
);
|
|
175
175
|
test
|
|
@@ -189,7 +189,7 @@ suite
|
|
|
189
189
|
tmpQuery.buildReadQuery();
|
|
190
190
|
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
191
191
|
Expect(tmpQuery.query.body)
|
|
192
|
-
.to.equal('SELECT *, "Name", "Age", "Cost", "Animal".* FROM "Animal" WHERE Age = :Age_w0 ORDER BY Age, Cost LIMIT 10 OFFSET 0;');
|
|
192
|
+
.to.equal('SELECT *, "Name", "Age", "Cost", "Animal".* FROM "Animal" WHERE "Age" = :Age_w0 ORDER BY "Age", "Cost" LIMIT 10 OFFSET 0;');
|
|
193
193
|
}
|
|
194
194
|
);
|
|
195
195
|
test
|
|
@@ -213,7 +213,7 @@ suite
|
|
|
213
213
|
tmpQuery.buildReadQuery();
|
|
214
214
|
_Fable.log.trace('Select Query', tmpQuery.query);
|
|
215
215
|
Expect(tmpQuery.query.body)
|
|
216
|
-
.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 LIMIT 100;');
|
|
216
|
+
.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" LIMIT 100;');
|
|
217
217
|
}
|
|
218
218
|
);
|
|
219
219
|
test
|
|
@@ -229,7 +229,7 @@ suite
|
|
|
229
229
|
tmpQuery.buildUpdateQuery();
|
|
230
230
|
_Fable.log.trace('Update Query', tmpQuery.query);
|
|
231
231
|
Expect(tmpQuery.query.body)
|
|
232
|
-
.to.equal('UPDATE "Animal" SET Name = :Name_0, Age = :Age_1 WHERE IDAnimal = :IDAnimal_w0;');
|
|
232
|
+
.to.equal('UPDATE "Animal" SET "Name" = :Name_0, "Age" = :Age_1 WHERE "IDAnimal" = :IDAnimal_w0;');
|
|
233
233
|
}
|
|
234
234
|
);
|
|
235
235
|
test
|
|
@@ -244,7 +244,7 @@ suite
|
|
|
244
244
|
tmpQuery.buildCountQuery();
|
|
245
245
|
_Fable.log.trace('Count Query', tmpQuery.query);
|
|
246
246
|
Expect(tmpQuery.query.body)
|
|
247
|
-
.to.equal('SELECT COUNT(*) AS RowCount FROM "Animal" WHERE Age = :Age_w0;');
|
|
247
|
+
.to.equal('SELECT COUNT(*) AS RowCount FROM "Animal" WHERE "Age" = :Age_w0;');
|
|
248
248
|
}
|
|
249
249
|
);
|
|
250
250
|
test
|
|
@@ -263,7 +263,7 @@ suite
|
|
|
263
263
|
Expect(tmpQuery.query.body)
|
|
264
264
|
.to.contain('UPDATE "Animal" SET');
|
|
265
265
|
Expect(tmpQuery.query.body)
|
|
266
|
-
.to.contain('Deleted = 1');
|
|
266
|
+
.to.contain('"Deleted" = 1');
|
|
267
267
|
Expect(tmpQuery.query.body)
|
|
268
268
|
.to.contain('NOW()');
|
|
269
269
|
}
|
|
@@ -280,7 +280,7 @@ suite
|
|
|
280
280
|
tmpQuery.buildDeleteQuery();
|
|
281
281
|
_Fable.log.trace('Delete Query', tmpQuery.query);
|
|
282
282
|
Expect(tmpQuery.query.body)
|
|
283
|
-
.to.equal('DELETE FROM "Animal" WHERE IDAnimal = :IDAnimal_w0;');
|
|
283
|
+
.to.equal('DELETE FROM "Animal" WHERE "IDAnimal" = :IDAnimal_w0;');
|
|
284
284
|
}
|
|
285
285
|
);
|
|
286
286
|
test
|
|
@@ -299,7 +299,7 @@ suite
|
|
|
299
299
|
Expect(tmpQuery.query.body)
|
|
300
300
|
.to.contain('UPDATE "Animal" SET');
|
|
301
301
|
Expect(tmpQuery.query.body)
|
|
302
|
-
.to.contain('Deleted = 0');
|
|
302
|
+
.to.contain('"Deleted" = 0');
|
|
303
303
|
Expect(tmpQuery.query.body)
|
|
304
304
|
.to.contain('NOW()');
|
|
305
305
|
}
|