sqlquerybuilder
Advanced tools
Comparing version 0.0.24 to 0.0.25
@@ -72,3 +72,3 @@ module.exports = function selects(self) { | ||
if (tableName.indexOf('.') !== -1) { | ||
if (tableName.indexOf('.') !== -1 && tableName[0] !== '(') { | ||
var nameParts = tableName.split('.'); | ||
@@ -75,0 +75,0 @@ |
{ | ||
"name": "sqlquerybuilder", | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"description": "Highly opinionated Sql Server Query Writer, mostly for internal use.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
@@ -181,3 +181,10 @@ /** | ||
it('It should be able to use a function as a select parameter', function (done) { | ||
// var query = sqlBuilder().from('Items').selectJoin(q) | ||
var queryObj ={ | ||
"Id": 'Key', | ||
"(case (select fbs.Value from FieldbookSettings fbs where fbs.Name = 'ItemNumberingSettings.DisplayNumberInItemDropdowns') when 'True' then (Items.Number + ' - ' + Items.Name) else Items.Name end)": 'Value' | ||
}; | ||
var query = sqlBuilder().from('Items').selectJoin(queryObj).where({IsActive: true}).build(); | ||
query.should.equal("SELECT Id AS 'Key', (case (select fbs.Value from FieldbookSettings fbs where fbs.Name = 'ItemNumberingSettings.DisplayNumberInItemDropdowns') when 'True' then (Items.Number + ' - ' + Items.Name) else Items.Name end) AS 'Value' FROM Items WHERE Items.IsActive = 1 "); | ||
done(); | ||
@@ -184,0 +191,0 @@ }); |
179115
3806