sqlquerybuilder
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -15,2 +15,6 @@ module.exports = function pagingAndLists(self) { | ||
self.processListRequest = function processListRequest(reqquery) { | ||
if(reqquery.query){ | ||
reqquery = reqquery.query; | ||
} | ||
if (reqquery.filters) { | ||
@@ -17,0 +21,0 @@ self.whereFilters(reqquery.filters); |
{ | ||
"name": "sqlquerybuilder", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "Highly opinionated Sql Server Query Writer, mostly for internal use.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
@@ -562,2 +562,53 @@ /** | ||
}); | ||
it('Should filter by contains properly', function (done) { | ||
var reqquery ={ filters: 'InvoiceCustomerName.Contains("EOG Re")&&IsActive=true', | ||
sidx: 'InvoiceNumber', | ||
sord: 'asc', | ||
RenderFormat: 'paged', | ||
page: '1', | ||
pagePercent: '0.3333333333333333', | ||
total: '205', | ||
rows: '100', | ||
totalPages: '3' }; | ||
var req = { query: reqquery }; | ||
var query = sqlBuilder().from('InvoiceSalesTaxInfoView') | ||
.select({ | ||
Id: null, | ||
Created: null, | ||
LastModified: null, | ||
IsActive: null, | ||
ModifiedBy: null, | ||
'TotalTax':null, | ||
'Total':null, | ||
'TaxableTotal':null, | ||
'NonTaxableTotal':null, | ||
TaxRate:null, | ||
InvoiceNumber:null, | ||
InvoiceCustomerName:null, | ||
InvoiceYard:null, | ||
InvoiceDate:null, | ||
InvoiceStateDisplayName:'InvoiceState.DisplayName', | ||
InvoiceStateValue:'InvoiceState.Value', | ||
StatusDisplayName:'Status.DisplayName', | ||
StatusValue:'Status.Value', | ||
InvoiceIsProcessed:null, | ||
SalesTaxZoneState:null, | ||
SalesTaxZoneName:null | ||
}) | ||
.processListRequest(req) | ||
.build(); | ||
query.should | ||
.equal("WITH SelectedItems AS (SELECT Id, Created, LastModified, IsActive, ModifiedBy, TotalTax, Total, TaxableTotal, NonTaxableTotal, TaxRate, InvoiceNumber, InvoiceCustomerName, InvoiceYard, InvoiceDate, InvoiceStateDisplayName AS 'InvoiceState.DisplayName', InvoiceStateValue AS 'InvoiceState.Value', StatusDisplayName AS 'Status.DisplayName', StatusValue AS 'Status.Value', InvoiceIsProcessed, SalesTaxZoneState, SalesTaxZoneName, ROW_NUMBER() OVER (ORDER BY InvoiceNumber ASC) AS Position FROM InvoiceSalesTaxInfoView WHERE InvoiceCustomerName LIKE '%EOG Re%' AND InvoiceSalesTaxInfoView.IsActive = 1) SELECT *, (Select MAX(Position) From SelectedItems) as 'TotalRows' FROM SelectedItems WHERE Position > 0 AND Position <= 100 ") | ||
done(); | ||
}); | ||
}); |
181468
3852