sqlquerybuilder
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -87,2 +87,4 @@ var uuid = require('node-uuid'), pluralizer = require('pluralizer'), _ = require('lodash'); | ||
} | ||
} else { | ||
_selectAliases.push(props[i]); | ||
} | ||
@@ -89,0 +91,0 @@ if (i != props.length - 1) _sqlObject.select += ", "; |
{ | ||
"name": "sqlquerybuilder", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "Highly opinionated Sql Server Query Writer, mostly for internal use.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/sqlQueryBuilder", |
@@ -494,2 +494,36 @@ /** | ||
}); | ||
it('Should filter by yard name properly', function (done) { | ||
var reqquery ={ filters: 'Yard.Name.Contains("Okla")&&IsActive=true', | ||
sidx: 'AcquiredDate', | ||
sord: 'desc', | ||
RenderFormat: 'paged', | ||
page: '1', | ||
pagePercent: '0.3333333333333333', | ||
total: '238', | ||
rows: '100', | ||
totalPages: '3' }; | ||
var query = sqlBuilder() | ||
.select({"f.Id" : null,"AssetNumber":null,"ShortDescription":null,"glc.Name":"GLCategory.Name","ac.Number":"AccountCode", | ||
"oc.Name":"OperationalCategory.Name","f.InitialCost":null,"f.AcquiredDate":null,"y.Name":"Yard.Name", | ||
"dep.Name":"Department.Name", "f.FixedAssetTypeDisplayName":"FixedAssetType.DisplayName","f.VIN":null, | ||
"po.Number":"PONumber"}) | ||
.from("FixedAssets f") | ||
.join("AccountingProcessTypes glc", "glc.Id", "f.GLCategory_id") | ||
.join("AccountCodes ac","ac.Id","glc.AccountCode_id") | ||
.join("EquipmentTypes oc", "oc.Id", "f.OperationalCategory_id") | ||
.join("Yards y") | ||
.join("Departments dep") | ||
.leftJoin("Receivers r") | ||
.leftJoin("PurchaseOrders po", "po.Id", "r.PurchaseOrder_id") | ||
.processListRequest(reqquery) | ||
.build(); | ||
query.should | ||
.equal("WITH SelectedItems AS (SELECT f.Id, AssetNumber, ShortDescription, glc.Name AS 'GLCategory.Name', ac.Number AS 'AccountCode', oc.Name AS 'OperationalCategory.Name', f.InitialCost, f.AcquiredDate, y.Name AS 'Yard.Name', dep.Name AS 'Department.Name', f.FixedAssetTypeDisplayName AS 'FixedAssetType.DisplayName', f.VIN, po.Number AS 'PONumber', ROW_NUMBER() OVER (ORDER BY f.AcquiredDate DESC) AS Position FROM FixedAssets f JOIN AccountingProcessTypes glc ON glc.Id = f.GLCategory_id JOIN AccountCodes ac ON ac.Id = glc.AccountCode_id JOIN EquipmentTypes oc ON oc.Id = f.OperationalCategory_id JOIN Yards y ON f.Yard_id = y.Id JOIN Departments dep ON f.Department_id = dep.Id LEFT JOIN Receivers r ON f.Receiver_id = r.Id LEFT JOIN PurchaseOrders po ON po.Id = r.PurchaseOrder_id WHERE y.Name LIKE '%Okla%' AND f.IsActive = 1) SELECT *, (Select MAX(Position) From SelectedItems) as 'TotalRows' FROM SelectedItems WHERE Position > 0 AND Position <= 100 ") | ||
done(); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162939
3500