sqlquerybuilder
Advanced tools
Comparing version 0.0.28 to 0.0.30
@@ -175,3 +175,3 @@ module.exports = function where(self) { | ||
// Dropdown filters | ||
var equalComparer = filter.indexOf("="); | ||
var equalComparer = filter.indexOf("=="); | ||
if (equalComparer != -1) { | ||
@@ -186,2 +186,16 @@ var dropAlias = self._selectProps[self._selectAliases.indexOf(filter.substr(1, equalComparer - 1))]; | ||
equalComparer = filter.indexOf("="); | ||
if (equalComparer != -1) { | ||
var pars = filter.split('='); | ||
var dropAlias2 = self._selectProps[self._selectAliases.indexOf(pars[0])]; | ||
console.log('dropAlias', dropAlias2); | ||
whereString += "(" + (dropAlias2 ? dropAlias2 : (self._sqlObject.fromAlias + "." + pars[0])); | ||
whereString += pars[1].toUpperCase() === "NULL" ? " IS " : " = "; | ||
whereString += pars[1] + | ||
")"; | ||
console.log('werheString', whereString); | ||
continue; | ||
} | ||
// Yes/No filters | ||
@@ -188,0 +202,0 @@ var bang = filter.indexOf("!"); |
{ | ||
"name": "sqlquerybuilder", | ||
"version": "0.0.28", | ||
"version": "0.0.30", | ||
"description": "Highly opinionated Sql Server Query Writer, mostly for internal use.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
@@ -564,4 +564,2 @@ /** | ||
it('Should filter by contains properly', function (done) { | ||
var reqquery ={ filters: 'InvoiceCustomerName.Contains("EOG Re")&&IsActive=true', | ||
@@ -614,2 +612,43 @@ sidx: 'InvoiceNumber', | ||
}); | ||
it('Should give the propery query for a view', function (done) { | ||
var reqquery ={ filters: 'IsActive=true&&TerritoryId=null', | ||
sidx: 'Created', | ||
sord: 'asc', | ||
RenderFormat: 'paged', | ||
page: '', | ||
pagePercent: '0', | ||
total: '', | ||
rows: '100', | ||
totalPages: '' }; | ||
var query = sqlBuilder() | ||
.from('MaintenanceAssignmentView') | ||
.select({ | ||
'Status': null, | ||
'Description': 'Description', | ||
'CreatorFirstName': 'CreatorFirstName', | ||
'TerritoryId': 'TerritoryId', | ||
'ServiceTicketId': 'ServiceTicketId', | ||
'ServiceTicketNumber': 'ServiceTicketNumber', | ||
'YardId': 'YardId', | ||
'Yard': 'Yard', | ||
'Equipment': 'Equipment', | ||
'JobInstructions': 'JobInstructions', | ||
'Categories': 'Categories', | ||
'Created': 'Created', | ||
'Id': 'Id', | ||
"(CreatorFirstName + ' ' + CreatorLastName)": 'CreatorName', | ||
"(CASE WHEN Status = 'Rejected' Then 1 else 1 END)": 'IsRejected' | ||
}) | ||
.where({Status: 'Complete'}) | ||
.processListRequest(reqquery) | ||
.build(); | ||
query.should | ||
.equal("WITH SelectedItems AS (SELECT Status, Description AS 'Description', CreatorFirstName AS 'CreatorFirstName', TerritoryId AS 'TerritoryId', ServiceTicketId AS 'ServiceTicketId', ServiceTicketNumber AS 'ServiceTicketNumber', YardId AS 'YardId', Yard AS 'Yard', Equipment AS 'Equipment', JobInstructions AS 'JobInstructions', Categories AS 'Categories', Created AS 'Created', Id AS 'Id', (CreatorFirstName + ' ' + CreatorLastName) AS 'CreatorName', (CASE WHEN Status = 'Rejected' Then 1 else 1 END) AS 'IsRejected', ROW_NUMBER() OVER (ORDER BY Created ASC) AS Position FROM MaintenanceAssignmentView WHERE MaintenanceAssignmentView.Status = 'Complete' AND MaintenanceAssignmentView.IsActive = 1 AND (TerritoryId IS null)) 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
184348
3901