sqlquerybuilder
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -491,5 +491,12 @@ var uuid = require('node-uuid'), pluralizer = require('pluralizer'), _ = require('lodash'); | ||
if (contains !== -1) { | ||
var containsAlias = _selectProps[_selectAliases.indexOf(filter.substr(0, contains))]; | ||
whereString += (containsAlias ? containsAlias : (_sqlObject.fromAlias + "." + filter.substr(0, contains))) + | ||
" LIKE '%" + | ||
var prop = filter.substr(0, contains); | ||
var containsAlias = _selectProps[_selectAliases.indexOf(prop)]; | ||
if(containsAlias){ | ||
whereString += containsAlias; | ||
}else if(prop.indexOf(".") !== -1){ | ||
whereString += prop; | ||
}else{ | ||
whereString += _sqlObject.fromAlias + "." + prop; | ||
} | ||
whereString += " LIKE '%" + | ||
filter.substr(contains + 11, filter.lastIndexOf("\"") - (contains + 11)) + | ||
@@ -496,0 +503,0 @@ "%'"; |
{ | ||
"name": "sqlquerybuilder", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "Highly opinionated Sql Server Query Writer, mostly for internal use.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/sqlQueryBuilder", |
@@ -473,2 +473,23 @@ /** | ||
}); | ||
it('it is called with filters with an alias that includes a tablename', function(done){ | ||
var req = { | ||
query: { | ||
rows: 100, | ||
page: 1, | ||
filters: 'Yard.Name.Contains("athen")' | ||
} | ||
}; | ||
(sqlBuilder() | ||
.select("al.Id, al.Name, al.Code, y.Name as [Yard.Name]") | ||
.from("AccountLocations al") | ||
.leftJoin("Yards y") | ||
.processListRequest(req.query) | ||
.build()) | ||
.should.equal("WITH SelectedItems AS (SELECT al.Id, al.Name, al.Code, y.Name as [Yard.Name], ROW_NUMBER() OVER (ORDER BY al.Created) AS Position FROM AccountLocations al " + | ||
"LEFT JOIN Yards y ON al.Yard_id = y.Id WHERE Yard.Name LIKE '%athen%') 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
160474
3466