Comparing version 0.2.8 to 0.2.9
{ | ||
"name": "sqb", | ||
"description": "Lightweight, multi-dialect SQL query builder for JavaScript", | ||
"version": "0.2.8", | ||
"description": "Plugin-driven, multi-dialect SQL query builder and Database connection framework for JavaScript", | ||
"version": "0.2.9", | ||
"author": "Panates Ltd.", | ||
@@ -20,3 +20,2 @@ "contributors": [ | ||
"database", | ||
"oracle", | ||
"framework" | ||
@@ -23,0 +22,0 @@ ], |
@@ -16,2 +16,3 @@ # SQB | ||
```js | ||
require('sqb-serializer-oracle'); /* Loads Oracle serialization plug-in */ | ||
const sqb = require('sqb'), | ||
@@ -23,5 +24,5 @@ /* Shortcuts for more clear coding */ | ||
serializer = sqb.serializer({ | ||
dialect:'oracle', | ||
prettyPrint: true, | ||
namedParams: false | ||
dialect:'oracle', // Use Oracle serializer | ||
prettyPrint: true, // Pretty sql output | ||
namedParams: false // Serialize named params (:prm) except (?) | ||
}); | ||
@@ -28,0 +29,0 @@ |
@@ -28,2 +28,3 @@ /* SQB-connect | ||
//noinspection JSUnusedGlobalSymbols | ||
get closed() { | ||
@@ -36,2 +37,3 @@ return true; | ||
//noinspection JSUnusedGlobalSymbols | ||
/** | ||
@@ -38,0 +40,0 @@ * @protected |
@@ -26,5 +26,2 @@ /* SQB | ||
/* Register built-in serializers */ | ||
require('./dialects/oracle_serializer'); | ||
Object.assign(sqlObjects, { | ||
@@ -31,0 +28,0 @@ |
@@ -417,3 +417,3 @@ /* SQB | ||
const sb = new StringBuilder(this.prettyPrint ? undefined : 0); | ||
let s; | ||
let s, logop = 'and'; | ||
sb.indent += 4; | ||
@@ -423,13 +423,18 @@ for (let i = 0; i < group.length; i++) { | ||
if (item.isRaw) | ||
if (item.isRaw) { | ||
logop = item.logicalOperator || logop; | ||
s = this._serializeRaw(item); | ||
} | ||
else if (item.type === 'conditiongroup') { | ||
logop = item.logicalOperator; | ||
s = this._serializeConditionGroup(item); | ||
if (s) s = '(' + s + ')'; | ||
} else | ||
} else { | ||
logop = item.logicalOperator; | ||
s = this._serializeCondition(item); | ||
} | ||
if (s) | ||
sb.append((sb.line ? ' ' + item.logicalOperator + ' ' : '') + s); | ||
sb.append((sb.line ? ' ' + logop + ' ' : '') + s); | ||
} | ||
@@ -642,3 +647,3 @@ return sb.toString(); | ||
else | ||
sb.append(' ' + join.table) | ||
sb.append(' ' + this._serializeTableName(join.table)) | ||
} | ||
@@ -645,0 +650,0 @@ |
@@ -49,2 +49,5 @@ /* SQB | ||
logop = arg; | ||
} else if (arg.type === 'raw') { | ||
arg.logicalOperator = logop; | ||
self._items.push(arg); | ||
} else | ||
@@ -51,0 +54,0 @@ throw new TypeError('Invalid argument'); |
@@ -13,2 +13,3 @@ /* SQB | ||
const ConditionGroup = require('./conditiongroup'); | ||
const TableName = require('./tablename'); | ||
@@ -30,3 +31,3 @@ /** | ||
this.joinType = joinType; | ||
this.table = table; | ||
this.table = table.isSelect || table.isRaw ? table : new TableName(String(table)); | ||
this.conditions = new ConditionGroup(); | ||
@@ -33,0 +34,0 @@ } |
@@ -13,3 +13,3 @@ /* SQB | ||
const SqlObject = require('./abstract'); | ||
const Table = require('./tablename'); | ||
const TableName = require('./tablename'); | ||
const Column = require('./column'); | ||
@@ -132,3 +132,3 @@ const Join = require('./join'); | ||
for (const arg of arguments) | ||
this._tables.push(arg.isSelect || arg.isRaw ? arg : new Table(String(arg))); | ||
this._tables.push(arg.isSelect || arg.isRaw ? arg : new TableName(String(arg))); | ||
return this; | ||
@@ -135,0 +135,0 @@ } |
@@ -48,9 +48,13 @@ /* SQB | ||
//noinspection JSUnusedGlobalSymbols | ||
then(callback) { | ||
then(options, callback) { | ||
if (typeof options === 'function') { | ||
callback = options; | ||
options = undefined; | ||
} | ||
if (this.connection) | ||
return this.connection.execute(this).then(callback); | ||
return this.connection.execute(this, undefined, options).then(callback); | ||
else { | ||
const dbpool = this.dbpool; | ||
assert.ok(dbpool, 'This statement is not executable'); | ||
return dbpool.connect(conn => conn.execute(this)).then(callback); | ||
return dbpool.connect(conn => conn.execute(this, undefined, options)).then(callback); | ||
} | ||
@@ -57,0 +61,0 @@ } |
155
63531
22
1845