2646 Commits

Author SHA1 Message Date
wubzz
543e92fc1f
Throw an error if .update() results in an empty sql (#2472)
* Throw an error if .update() results in an empty sql

* Indentation
2018-02-15 13:28:35 +01:00
wubzz
f1faaf9180
Add warning when using .returning() in sqlite3. Fixes #1660 (#2471) 2018-02-15 13:28:25 +01:00
wubzz
f78ee074be
containsUndefined should only validate plain objects. Fixes #1898 (#2468)
* containsUndefined should only validate plain objects. Fixes #1898

* Fix lint issues
2018-02-14 17:00:50 +01:00
Mikael Lepistö
ca702cf4d1 Updated changelog and bumped version up 0.14.3 2018-02-08 22:45:48 +02:00
Mikael Lepistö
44ccb33cb5
Fixes #1303 (#2458) 2018-02-08 21:53:38 +02:00
Sami Koskimäki
8771bd4781 Use tarn as pool (#2450)
* replace generic-pool with Tarn

* fix bug where mariadb client didn't propagate connection errors to pool

* destroy connection if a query times out (and cancellation is not enabled)

Before this change, when a query timeout happened without { cancel: true }
the connection was immediately released back to the pool. If the query
timed out because of a time consuming query, the released connection would
still execute the query to its end and the connection would be useless until
that time. This commit marks the connection as disposed so that the pool never
again gives that connection to anyone, and destorys it in the near future.

* fix a weird database version dependent casing bug in a tests

* fix an unstable test that failed randomly because the query order was not guaranteed
2018-02-07 11:17:17 +02:00
Mikael Lepistö
053736fa4a
Added info about new dialect and about minimal test cases 2018-02-03 16:22:46 +02:00
Adam Cofer
5f81e8aeb9 Add redshift support without changing cli or package.json (#2233)
* Add a Redshift dialect that inherits from Postgres.

* Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect.

* Update the Redshift dialect to be compatible with master.

* Update package.json

* Disable liftoff cli

* Remove the CLI

* Add lib to the repo

* Allow the escaping of named bindings.

* Update dist

* Update the Redshift dialect’s instantiation of the query and column compilers.

* Update the distribution

* Fix a merge conflict

* Take lib back out

* Trying to bring back in line with tgreisser/knex

* Add npm 5 package-lock

* Bring cli.js back in line

* Bring cli.js back in line

* Progress commit on redshift integration tests

* Revert "Progress commit on redshift integration tests"

This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c.

* Progress commit

* Working not null on primary columns in createTable

* Working redshift unit tests

* Working unit and integration tests, still need to fix migration tests

* Brought datatypes more in line with what redshift actually supports

* Added query compiler unit tests

* Add a hacky returning clause for redshift ugh

* Working migration integration tests

* Working insert integration tests

* Allow multiple insert returning values

* Working select integration tests

* Working join integration tests

* Working aggregate integration tests

* All integration suite tests working

* Put docker index for reconnect tests back

* Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly

* Leave redshift integration tests in place, but do not run them by default

* Fix mysql order by test

* Fix more tests

* Change test db name to knex_test for consistency

* Address PR comments
2018-02-03 15:33:02 +02:00
Joel Mukuthu
bf1fa63118 Add queryContext to schema and query builders (#2314)
* feat(query-builder): add hookContext for wrapIdentifier

* refactor: use isUndefined

* test(transaction): test passing of hookContext

* feat(runnner): pass context to postProcessResponse

* test(runner): test postProcessResponse for raw responses

* test(raw): test passing of hookContext

* feat: add hookContext to Raw and SchemaBuilder

* test(transaction): fix test for hookContext

* chore: fix lint error

* fix: check for hookContext before calling it

* test(transaction): fix hookContext test

* chore: remove whitespace

* test(hookContext): test cloning of context object

* refactor: hookContext -> queryContext

* minor: use more descriptive variable name

i.e. refactor: `context` => `queryContext`

* fix: remove unnecessary checks for query builder

* fix(Raw): pass query builder to formatter

* fix(SchemaCompiler): pass schema builder to formatter

* refactor: add addQueryContext helper

* feat: add queryContext to TableBuilder and ColumnBuilder

* fix(TableCompiler): pass table builder to formatter

* fix(ColumnCompiler): pass column builder to formatter

* fix(pushQuery): fix passing builder to formatter

* test(Schema|Table|ColumnCompiler): test passing queryContext

* fix(SchemaCompiler): pass queryContext to TableCompiler

* fix(TableCompiler): pass queryContext to ColumnCompiler

* test: add queryContext tests for all schema dialects

* test(TableCompiler): test overwriting queryContext from SchemaCompiler

* test(Raw): test passing queryContext to wrapIdentifier

* tests: run all the tests
2018-02-02 00:41:01 +02:00
Igor Savin
09eb12638c Update dependencies and fix ESLint warnings accordingly (#2433)
* Update dependencies. Tweak ESLint rules to work more like they used to before

* Fix indentation

* Remove unnecessary escapes.

* Remove unused 'usingClause' parameter.

* Address CI failures.

* Revert "Remove unused 'usingClause' parameter."

This reverts commit aaa4d71e914faa1c4c1313c26bbdd26067b0b448.

* eslint: add ignore with todo

* dependencies: update
2018-02-01 23:46:12 +02:00
tmeinders
c1997e9502 Fixing issue with add columns on tables failing if using both after and collate (#2432)
* Fixing issue with add columns on tables failing if using both after and collate

* Adding tests for collate modifier alongside first and after modifiers
2018-01-24 02:06:25 +02:00
P-Seebauer
15706c0d00 2351 CLI sets exit-code 1 if the command supplied was not parseable (#2358)
* CLI Sets exit code to 1 if the command wasn't parseable

* Fix color output for errors in the cli
2018-01-19 00:29:38 +02:00
Igor Savin
9f8d2eddbf Update dependencies (#2422) 2018-01-12 12:02:41 +02:00
godfrey
59f6cba178 Set toNative() to be not enumerable (#2388) 2018-01-03 17:56:34 +02:00
Sami Koskimäki
45f5ffbad0 Use wrapIdentifier in columnInfo. fixes #2402 (#2405)
* Make postgres client wrapIdentifierImpl independent of `this` context

 * Also fixes a bug where only single digit indices were accepted.

* add customWrapIdentifier helper for client

 * customWrapIdentifier is one more level of abstraction for the wrapIdentifier "pipeline"
   that allows the custom wrapIdentifier to be called without calling the `wrapIdentifierImpl`

* bufix: use custom wrapIdentifier in columnInfo. fixes #2402
2018-01-03 00:05:48 +02:00
Mikael Lepistö
82bfdba494
Disable oracledb tests from non LTS nodes (#2407)
Fixes test suite
2018-01-02 22:47:51 +02:00
tankers746
3f8970117e Shifted returning before joins for updates (MSSQL) (#2399)
When using OUTPUT with a join in MSSQL the OUTPUT needs to come before
the joins.

https://stackoverflow.com/questions/4170389/inner-join-within-update-output-in-one-t-sql-query
2018-01-01 11:42:18 -06:00
Jiri Spac
6ffcaedc38 fixes #2373 (#2374)
only log the migration name when it is not falsy
2017-12-08 13:26:14 +02:00
tomulin1
5e12b23e1b Incorrectly set UV_THREADPOOL_SIZE (#2372)
Incorrectly set UV_THREADPOOL_SIZE when passed from system variables. It's recognized as string (windows).
2017-12-08 13:13:51 +02:00
Ivo Meißner
fbf371f4e9 Added decimal variable precision / scale support (#2353)
* Added postgres decimal variable precision / scale support

* Decimal column no precision support all dialects + tests
2017-11-30 23:05:39 +02:00
Mikael Lepistö
aac0565c62 Updated change log + version for 0.14.2 0,14,2 2017-11-24 23:27:28 +02:00
Jürg Lehni
b5ba51a01e Fix truncate() on sqlite3 dialect (#2348)
Relates to #2312: ids were not correctly reset anymore
2017-11-24 09:00:20 +02:00
Mikael Lepistö
aeec0a29c8 Updated package version and changelog 0.14.1 2017-11-19 18:45:41 +02:00
Mikael Lepistö
c0ac1077b6
More pool tests and test on borrow default (#2341)
* Test pool eviction when DB closes connection

* Added couple of tests for how pool works and added testOnBorrow to defaults
2017-11-19 18:43:28 +02:00
wubzz
95e5cf8e1c
Support multiple searchPaths while preserving case-sensitive feature … (#2340)
* Support multiple searchPaths while preserving case-sensitive feature (by using Array syntax). Fixes #2335

* ESLint

* Added changelog text
2017-11-18 17:09:05 +01:00
Mikael Lepistö
e405d669a6
Fixed passing connection errors directly to the query (#2336)
* Fixed passing connection errors directly to the query

* Added missing use strict and fixed select to be oracle compatible.

* Fixed dialect name which is mixed in different configs

* Oracledb didnt have database config attribute
2017-11-17 21:03:43 +02:00
Mikael Lepistö
211a611b8c Fixed typo in issue template 2017-11-14 22:27:03 +02:00
Mikael Lepistö
4b9e44f8ef Added issue template and runkit example. 2017-11-14 22:23:11 +02:00
Jiri Spac
69cccdc89a add link to objection ORM (#2252)
IMHO objection deserves it's spot right there beside bookshelf
2017-11-07 20:00:10 -05:00
Mikael Lepistö
bf8aa4db10
Release 0.14 change log and version bump (#2310)
* Change log update for 0.14 release

* Bumped version up to 0.14
2017-11-07 00:27:06 +02:00
Jonathan Stewmon
7c1a0d4fc0 mysql stream should support query options (#2301) 2017-11-05 18:47:21 +02:00
Richard Ižip
74f2a031f3 Throw error on non-string table comment (#2126)
* Throw error on non-string table comment

* add unit tests for all dialects
* removed non-valid comments retyping to ''

* Change dockerode version

* reverted dockerode version locking
2017-11-01 00:22:07 +02:00
Michael Shim
53314cbde5 Making containsUndefined check for own properties (#1711) 2017-11-01 00:15:53 +02:00
Konstantin Tarkus
f66b524af7 Call to knex.migrate.currentVersion causes an error #2111 (#2123) 2017-11-01 00:10:26 +02:00
Mikael Lepistö
7d18837404
Allow update queries in with statements. Fixes #2263. (#2298) 2017-10-31 21:33:28 +02:00
Rich Dillon
85d088af34 Update each out-of-date dependency according to david-dm.org. (#2297) 2017-10-28 01:52:36 +03:00
Selwyn
f40d69d2ec Update v8flags to version 3.0.0 (#2288)
The v8flags dependency got updated so that it follows the OS cache location conventions. See [the PR](https://github.com/js-cli/js-v8flags/pull/38) for more information.
2017-10-25 22:37:00 +03:00
Juuso Tapaninen
fddfd3b3d8 Escape table name in SQLite columnInfo call (#2281)
Fixes #2184. Not escaping the table name could lead to issues
with some table names. Table name group, for example, would
result in an error.
2017-10-23 09:13:09 +03:00
Aurélio A. Heckert
e59cc197d6 Update interpret version (#2283) 2017-10-23 08:46:51 +03:00
Rich Dillon
d0d22e0948 Track the current migration file for use in error message. Print filename of errored migration (#2272) 2017-10-18 10:50:30 +03:00
Ivan Filho
11536f92ff Implemented select syntax: select({ alias: 'column' }) (#2227)
* added object syntax for aliases

* added mixed tests for alias pair feature

* fixed double aliasing for subqueries

* fixed last untested commit

* Added support for passing query builder inside object syntax and using the syntax in raw identifiers
2017-10-17 01:43:20 +03:00
Mike
b092a271fa Allow raw expressions in query builder aggregate methods (#2257)
The aggregate methods include `count`, `min`, `max`, `sum`, `avg`,
`countDistinct`, `sumDistinct`, and `avgDistinct`, all of which
can now receive raw expressions, e.g.

```js
knex('users').count(knex.raw("data->'active'"));
```

There seems to be some demand for this, and I think it's cleaner than the alternative of

```js
knex('users').select(knex.raw("count(data->'active')"));
```
2017-10-14 18:19:06 +03:00
Mikael Lepistö
9658c78d4f Post processing hook for query result (#2261) 2017-10-12 18:16:15 +03:00
Mark Wubben
0ccd591bcb Fix connection error propagation when streaming (#2199)
* Fix connection error propagation when streaming

If stream() is used without a handler, make sure to emit connection
errors on the stream itself.

* Test stream error emission

* Improve test
2017-10-03 19:39:10 +03:00
Rich Dillon
7032dffe70 Fix comments not being applied to increments columns (#2243)
* Removed check increments check on the modifiers. Implemented a default lookup map on the generic columncompiler

* Ignore VS Code User Workspace Settings

* Added test case to assert comments are added to increments columns

* Shortened line length and added explicit db tests for postgres and mysql dialects

* Added check for modifiers on incrementing types and only allow comment modifiers
2017-09-28 08:54:20 +03:00
Mikael Lepistö
15639d03db Build native sql for a dialect without to string (#2237)
* Exposed also positionBinding method to client base class and refactored calls to em

* Added toSQL().toNative() getter which returns dialect specfic sql and bindings.

* Refactored toSQL method implementation
2017-09-27 13:12:40 +03:00
Mikael Lepistö
491cc788c2 Updated oprator list and allow operator transformation for e.g. escaping ? (#2239) 2017-09-23 14:34:59 +03:00
Mikael Lepistö
b5d93f10b1 Configuration option to allow override/hook to identifier wrapping code (#2217) 2017-09-08 14:58:59 +03:00
Jonathan Stewmon
9122cbf6df upgrade generic-pool to 3.1.7 (#2208)
* Upgrade generic-pool to v3.1.7 (Attempt)

* Remove callback from pool create function

* Fix ESLint

* Send whole poolConfig to generic-pool (for idleTimeoutMillis etc)

* fix compatibility issues with generic-pool v3
- restore Client.poolDefaults to allow dialect overrides
- connection validators should always resolve with a boolean
- rely on generic pool acquire timeouts to avoid unhandled rejections
- simplify promise usage, avoiding Promise constructor anti-pattern
- enable testOnBorrow in docker tests to evict broken connections
- enable docker tests on Darwin
- enable docker tests for mysql2 dialect

* validate timeout settings and to 60s

* simplify Client.destroy promise handling

* return destroyRawConnection promise from dialects
2017-09-06 22:51:29 +03:00
rfink
8f7d2e2977 Adding NOT ILIKE for postgres (#2195) 2017-08-24 11:09:57 +03:00