Comparing version 0.0.5 to 0.0.6
@@ -30,3 +30,3 @@ /** | ||
let arg = arguments[i]; | ||
if (!(arg.isCondition || arg.isConditionGroup)) | ||
if (!(arg.isCondition || arg.isConditionGroup || arg.isRaw)) | ||
throw new Error('Only array of Condition instance allowed'); | ||
@@ -33,0 +33,0 @@ this._items.push(arg); |
@@ -9,6 +9,6 @@ /** | ||
get dialect() { | ||
return 'oracle'; | ||
constructor(config){ | ||
super(config); | ||
this.dialect = 'oracle'; | ||
} | ||
_generateFrom(tables) { | ||
@@ -15,0 +15,0 @@ let s = super._generateFrom(tables); |
@@ -25,3 +25,3 @@ /** | ||
constructor(config) { | ||
this._dialect = config && config.dialect; | ||
this.dialect = config && config.dialect; | ||
this.prettyPrint = config && !!config.prettyPrint; | ||
@@ -33,6 +33,2 @@ this.namedParams = !config || config.namedParams === undefined || !!config.namedParams; | ||
get dialect() { | ||
return this._dialect; | ||
} | ||
build(obj) { | ||
@@ -59,3 +55,3 @@ this.sql = ''; | ||
if (s = this._generateFrom(obj._tables)) { | ||
sb.append((this.prettyPrint && sb.line.length > 40 ? '\n' : (sb.line ? ' ' : '')) + s); | ||
sb.append((this.prettyPrint && sb.line.length > 40 ? '\n' : ' ') + s); | ||
} | ||
@@ -129,17 +125,16 @@ | ||
table = tables[i]; | ||
let ss; | ||
if (table.isRaw) | ||
str += (str ? ', ' : ' ') + this._generateRaw(table); | ||
ss = this._generateRaw(table); | ||
else if (table.type === 'table') { | ||
str += (str ? ', ' : ' ') + | ||
(table.schema ? table.schema + '.' : '') + | ||
ss = (table.schema ? table.schema + '.' : '') + | ||
table.table + | ||
(table.alias ? ' ' + table.alias : '') | ||
} else if (table.type === 'select') { | ||
let s = this._generateSelectSql(table); | ||
if (s) | ||
str += ' (' + s + ')' + (table._alias ? ' ' + table._alias : ''); | ||
} else if (table.type === 'raw') { | ||
let s = this._generateRaw(table); | ||
if (s) str += ' ' + s; | ||
if (ss = this._generateSelectSql(table)) | ||
ss = '(' + ss + ')' + (table._alias ? ' ' + table._alias : ''); | ||
} | ||
if (ss) | ||
str += (str ? ', ' : ' ') + ss; | ||
} | ||
@@ -182,3 +177,3 @@ return str ? 'from' + str : ''; | ||
str = '(' + this._generateSelectSql(item.field) + ') '; | ||
else str = this.reservedWords.indexOf(item.field) >= 0 ? '"' + item.field + '"' : item.field + ' '; | ||
else str = this.reservedWords.indexOf(item.field) >= 0 ? '"' + item.field + '" ' : item.field + ' '; | ||
@@ -185,0 +180,0 @@ if (item.param) { |
{ | ||
"name": "sqb", | ||
"description": "Lightweight, multi-dialect SQL query builder for JavaScript", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": "Panates Ltd.", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
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
27513
800