sqlquerybuilder
Advanced tools
Comparing version 0.0.75 to 0.0.76
@@ -168,3 +168,3 @@ var _ = require('lodash'), | ||
reference = subFilter.substr(0, opIndex); | ||
whereString += "CONVERT(DATETIMEOFFSET," + self._whereJoin(reference) + ")" + | ||
whereString += (self._isDateTimeField(reference) ? ("CONVERT(DATETIMEOFFSET," + self._whereJoin(reference) + ")" ) : self._whereJoin(reference))+ | ||
" >= '" + | ||
@@ -179,3 +179,3 @@ sqlescape(subFilter.substr(opIndex + 2, subFilter.length - opIndex)) + | ||
reference = subFilter.substr(0, opIndex); | ||
whereString += "CONVERT(DATETIMEOFFSET," + self._whereJoin(reference) + ")" + | ||
whereString += (self._isDateTimeField(reference) ? ("CONVERT(DATETIMEOFFSET," + self._whereJoin(reference) + ")" ) : self._whereJoin(reference))+ | ||
" > '" + | ||
@@ -190,3 +190,3 @@ sqlescape(subFilter.substr(opIndex + 1, subFilter.length - opIndex)) + //.replace(/-/g, "/") + | ||
reference = subFilter.substr(0, opIndex); | ||
whereString += "CONVERT(DATETIMEOFFSET," + self._whereJoin(reference) + ")" + | ||
whereString += (self._isDateTimeField(reference) ? ("CONVERT(DATETIMEOFFSET," + self._whereJoin(reference) + ")" ) : self._whereJoin(reference))+ | ||
" <= '" + | ||
@@ -201,3 +201,3 @@ sqlescape(subFilter.substr(opIndex + 2, subFilter.length - opIndex - 1)) + //.replace(/-/g, "/") + | ||
reference = subFilter.substr(0, opIndex); | ||
whereString += "CONVERT(DATETIMEOFFSET," + self._whereJoin(reference) + ")" + | ||
whereString += (self._isDateTimeField(reference) ? ("CONVERT(DATETIMEOFFSET," + self._whereJoin(reference) + ")" ) : self._whereJoin(reference))+ | ||
" < '" + | ||
@@ -204,0 +204,0 @@ sqlescape(subFilter.substr(opIndex + 1, subFilter.length - opIndex - 1)) + |
{ | ||
"name": "sqlquerybuilder", | ||
"version": "0.0.75", | ||
"version": "0.0.76", | ||
"description": "Highly opinionated Sql Server Query Writer, mostly for internal use.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
@@ -405,2 +405,22 @@ var sqlQueryBuilder = require('../../../lib/index'), | ||
}); | ||
it('Doesnt Select Total on Ranges as DateTimes', function(done){ | ||
sqlBuilder() | ||
.select("TicketView.*") | ||
.from("TicketView").leftJoin("TicketFields on TicketFields.Id=TicketView.TicketField") | ||
.processListRequest({filters:"Total>0&&Total<100&&IsActive=true", | ||
sidx:"Date", | ||
sord:"desc", | ||
RenderFormat:"paged", | ||
page:1, | ||
pagePercent:0.0024691358024691358, | ||
total:40417, | ||
rows:100, | ||
totalPages:405}) | ||
.build().should.equal("WITH SelectedItems AS (SELECT TicketView.*, "+ | ||
"ROW_NUMBER() OVER (ORDER BY CONVERT(DATETIMEOFFSET,TicketView.Date) DESC) "+ | ||
"AS Position FROM TicketView LEFT JOIN TicketFields on TicketFields.Id=TicketView.TicketField "+ | ||
"WHERE TicketView.Total > '0' AND TicketView.Total < '100' AND TicketView.IsActive = 1) "+ | ||
"SELECT *, (Select MAX(Position) From SelectedItems) as 'TotalRows' FROM SelectedItems WHERE Position > 0 AND Position <= 100 "); | ||
done(); | ||
}); | ||
}); |
241942
4866