Comparing version 0.0.10 to 0.0.11
@@ -47,3 +47,3 @@ /* SQB.js | ||
if (!table) return this; | ||
this._table = table instanceof Table || table.isRaw ? table : new Table(String(table)); | ||
this._table = table.isRaw ? table : new Table(String(table)); | ||
return this; | ||
@@ -50,0 +50,0 @@ } |
@@ -15,6 +15,34 @@ /* SQB.js | ||
constructor(config){ | ||
constructor(config) { | ||
super(config); | ||
this.dialect = 'oracle'; | ||
} | ||
/** | ||
* Serialize Select statement | ||
* | ||
* @param {Select} obj Select statement object | ||
* @return {String} | ||
* @protected | ||
*/ | ||
_serializeSelect(obj) { | ||
let sql = super._serializeSelect(obj); | ||
if (obj._limit || obj._offset) { | ||
sql = | ||
'select * from (select rownum row$number, t.* from (' + | ||
(this.prettyPrint ? '\n ' : '') + | ||
sql + | ||
(this.prettyPrint ? '\n ' : '') + | ||
') t) ' + | ||
(obj._alias ? obj._alias+' ': '')+ | ||
(this.prettyPrint ? '\n' : '') + | ||
'where '; | ||
if (obj._offset) | ||
sql += ' and row$number >= ' + obj._offset; | ||
if (obj._limit) | ||
sql += (obj._offset ? ' and ': ' ') + 'row$number <= ' + obj._limit; | ||
} | ||
return sql; | ||
} | ||
_serializeTablesNames(tables) { | ||
@@ -21,0 +49,0 @@ let s = super._serializeTablesNames(tables); |
@@ -36,3 +36,3 @@ /* SQB.js | ||
// We build a new map of upper keys for case insensitivity | ||
let values = config.params && typeof config.params === 'object' ? config.params: {}, | ||
let values = config.params && typeof config.params === 'object' ? config.params : {}, | ||
obj = {}; | ||
@@ -134,3 +134,3 @@ Object.getOwnPropertyNames(values).forEach( | ||
if (obj._table.type === 'raw') | ||
sb.append(this._serializeRaw(obj._table)); | ||
sb.append(this._serializeRaw(obj._table) + ' '); | ||
else if (obj._table.type === 'table') | ||
@@ -137,0 +137,0 @@ sb.append(this._serializeTableName(obj._table) + ' '); |
{ | ||
"name": "sqb", | ||
"description": "Lightweight, multi-dialect SQL query builder for JavaScript", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"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
40677
1148