Comparing version 1.0.3 to 1.0.4
@@ -159,4 +159,4 @@ const clone = require('lodash/clone'); | ||
const parameterizedValuesWithoutDefaultAndBlob = parameterizedValues | ||
.replace('DEFAULT, ', '') | ||
.replace(', DEFAULT', '') | ||
.replace(/DEFAULT, /g, '') | ||
.replace(/, DEFAULT/g, '') | ||
.replace('EMPTY_BLOB(), ', '') | ||
@@ -163,0 +163,0 @@ .replace(', EMPTY_BLOB()', ''); |
@@ -30,4 +30,2 @@ // All properties we can use to start a query chain | ||
'where', | ||
'whereLike', | ||
'whereILike', | ||
'andWhere', | ||
@@ -37,2 +35,8 @@ 'orWhere', | ||
'orWhereNot', | ||
'whereLike', | ||
'andWhereLike', | ||
'orWhereLike', | ||
'whereILike', | ||
'andWhereILike', | ||
'orWhereILike', | ||
'whereRaw', | ||
@@ -39,0 +43,0 @@ 'whereWrapped', |
@@ -694,2 +694,7 @@ // Builder | ||
// Adds a `or where like` clause to the query. | ||
orWhereLike(column, value) { | ||
return this._bool('or')._whereLike('whereLike', column, value); | ||
} | ||
// Adds a `where ilike` clause to the query. | ||
@@ -700,2 +705,7 @@ whereILike(column, value) { | ||
// Adds a `or where ilike` clause to the query. | ||
orWhereILike(column, value) { | ||
return this._bool('or')._whereLike('whereILike', column, value); | ||
} | ||
// Adds a `group by` clause to the query. | ||
@@ -1510,4 +1520,4 @@ groupBy(item) { | ||
orWhereJsonPath(column, operator, value) { | ||
return this._bool('or').whereJsonPath(column, operator, value); | ||
orWhereJsonPath(column, path, operator, value) { | ||
return this._bool('or').whereJsonPath(column, path, operator, value); | ||
} | ||
@@ -1731,2 +1741,4 @@ | ||
Builder.prototype.andWhereJsonPath = Builder.prototype.whereJsonPath; | ||
Builder.prototype.andWhereLike = Builder.prototype.whereLike; | ||
Builder.prototype.andWhereILike = Builder.prototype.whereILike; | ||
Builder.prototype.andHaving = Builder.prototype.having; | ||
@@ -1733,0 +1745,0 @@ Builder.prototype.andHavingIn = Builder.prototype.havingIn; |
@@ -127,4 +127,32 @@ // Query Compiler | ||
const statements = components.map((component) => this[component](this)); | ||
sql += compact(statements).join(' '); | ||
let unionStatement = ''; | ||
// Compute all statements to main query | ||
const statements = components.map((component) => { | ||
const statement = this[component](this); | ||
// We store the 'union' statement to append it at the end. | ||
// We still need to call the component sequentially because of | ||
// order of bindings. | ||
if (component === 'union') { | ||
unionStatement = statement; | ||
} else { | ||
return statement; | ||
} | ||
}); | ||
// Check if we need to wrap the main query. | ||
// We need to wrap main query if one of union have wrap options to true | ||
// to avoid error syntax (in PostgreSQL for example). | ||
const wrapMainQuery = | ||
this.grouped.union && | ||
this.grouped.union.map((u) => u.wrap).some((u) => u); | ||
const allStatements = | ||
(wrapMainQuery ? '(' : '') + | ||
compact(statements).join(' ') + | ||
(wrapMainQuery ? ')' : ''); | ||
if (this.onlyUnions()) { | ||
sql += unionStatement + ' ' + allStatements; | ||
} else { | ||
sql += allStatements + (unionStatement ? ' ' + unionStatement : ''); | ||
} | ||
return sql; | ||
@@ -710,5 +738,6 @@ } | ||
if (statement) { | ||
if (union.wrap) sql += '('; | ||
const wrap = union.wrap; | ||
if (wrap) sql += '('; | ||
sql += statement; | ||
if (union.wrap) sql += ')'; | ||
if (wrap) sql += ')'; | ||
} | ||
@@ -847,2 +876,3 @@ } | ||
onBasic(clause) { | ||
const toWrap = clause.value instanceof QueryBuilder; | ||
return ( | ||
@@ -864,2 +894,3 @@ wrap_( | ||
' ' + | ||
(toWrap ? '(' : '') + | ||
wrap_( | ||
@@ -871,3 +902,4 @@ clause.value, | ||
this.bindingsHolder | ||
) | ||
) + | ||
(toWrap ? ')' : '') | ||
); | ||
@@ -874,0 +906,0 @@ } |
{ | ||
"name": "knex", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3", | ||
@@ -117,3 +117,3 @@ "main": "knex", | ||
"JSONStream": "^1.3.5", | ||
"lint-staged": "^11.1.2", | ||
"lint-staged": "^12.3.4", | ||
"mocha": "^9.2.0", | ||
@@ -127,3 +127,3 @@ "mock-fs": "^5.1.2", | ||
"pg-query-stream": "^4.2.1", | ||
"prettier": "2.4.1", | ||
"prettier": "2.5.1", | ||
"rimraf": "^3.0.2", | ||
@@ -151,3 +151,3 @@ "sinon": "^13.0.1", | ||
}, | ||
"homepage": "https://knexjs.org", | ||
"homepage": "https://knex.github.io/documentation/", | ||
"keywords": [ | ||
@@ -182,2 +182,5 @@ "sql", | ||
{ | ||
"name": "Olivier Cavadenti" | ||
}, | ||
{ | ||
"name": "Simon Liden" | ||
@@ -192,5 +195,2 @@ }, | ||
"web": "https://briandamaged.org" | ||
}, | ||
{ | ||
"name": "Olivier Cavadenti" | ||
} | ||
@@ -197,0 +197,0 @@ ], |
@@ -1,2 +0,2 @@ | ||
# [knex.js](http://knexjs.org) | ||
# [knex.js](https://knex.github.io/documentation/) | ||
@@ -16,6 +16,6 @@ [![npm version](http://img.shields.io/npm/v/knex.svg)](https://npmjs.org/package/knex) | ||
- [transactions](https://knexjs.org/#Transactions) | ||
- [connection pooling](https://knexjs.org/#Installation-pooling) | ||
- [streaming queries](https://knexjs.org/#Interfaces-Streams) | ||
- both a [promise](https://knexjs.org/#Interfaces-Promises) and [callback](https://knexjs.org/#Interfaces-Callbacks) API | ||
- [transactions](https://knex.github.io/documentation/#Transactions) | ||
- [connection pooling](https://knex.github.io/documentation/#Installation-pooling) | ||
- [streaming queries](https://knex.github.io/documentation/#Interfaces-Streams) | ||
- both a [promise](https://knex.github.io/documentation/#Interfaces-Promises) and [callback](https://knex.github.io/documentation/#Interfaces-Callbacks) API | ||
- a [thorough test suite](https://github.com/knex/knex/actions) | ||
@@ -25,3 +25,3 @@ | ||
* Take a look at the [full documentation](https://knexjs.org) to get started! | ||
* Take a look at the [full documentation](https://knex.github.io/documentation) to get started! | ||
* Browse the [list of plugins and tools](https://github.com/knex/knex/blob/master/ECOSYSTEM.md) built for knex | ||
@@ -28,0 +28,0 @@ * Check out our [recipes wiki](https://github.com/knex/knex/wiki/Recipes) to search for solutions to some specific problems |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
832779
22176