38 Commits

Author SHA1 Message Date
veikovx
932fa4b683 Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL

* Fix cancellation connection acquiring and test.

* Fix releasing connection in case query cancellation fails

* Add support for native enums on Postgres (#2632)

Reference https://www.postgresql.org/docs/current/static/sql-createtype.html

Closes #394

Signed-off-by: Will Soto <will.soto9@gmail.com>

* Removal of 'skim' (#2520)

* Allow overwriting log functions (#2625)

* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message

* Fixed onIn with empty values array (#2513)

* Drop support for strong-oracle (#2487)

* Remove babel-plugin-lodash (#2634)

While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.

* Add json support to the query builder for mysql (#2635)

* Add json support to the query builder for mysql

refs #1036

Based on #1902

* Clarify supported version

* fix wrapIdentifier not being called in postgres alter column (#2612)

* fix wrapIdentifier not being called in postgres alter column

* add test for wrapIdentifier call in postgres alter column

* add comment regarding issue

* add issue & PR #'s in comment

* Remove readable-stream and safe-buffer (#2640)

* Add json support to the query builder for mysql

refs #1036

Based on #1902

* Clarify supported version

* Use native Buffer and Stream implementations

* fixes 2630 (#2642)

* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)

* chore: add Node.js 10 (#2594)

* chore: add Node.js 10

* chore: trigger new build

* chore: update lockfile

* chore: trigger new build

* fix: use npm i instead of npm ci

* Fix mssql driver crashing (#2637)

* Run SQL Server tests locally running SQL server in docker

* WIP mssql test stuff

* Patched MSSQL driver to not crash knex anymore

* Removed semicolon from rollback stmt for oracle (#2564)

* Remove WebSQL dialect (#2647)

* Add json support to the query builder for mysql

refs #1036

Based on #1902

* Clarify supported version

* Use native Buffer and Stream implementations

* Remove WebSQL dialect

* add homepage field to package.json (#2650)

* Make the stream catch errors in the query (#2638)

* Make the stream catch errors in the query

* Fix another case in which stream doesnt emits error

* Linter stuff

* Remove setTimeout in tests

* Make a test not to check the MySQL error code

* Fix stream error catching for MariaDB and PostgreSQL

* Fix stream error catching in Oracle

* Throw the error after emitting it to the stream

* Throw the error without instantiating a new Error

* Various fixes to mssql dialect (#2653)

* Fixed float type of mssql to be float

* Many tests where postgres test was not actually ran at all

* Migrations to be mssql compatible

Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.

* Prevented mssql failing when invalid schema builder was executed by accident

Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started

* Fixed mssql trx rollback to always throw an error

Also modified some connection test query to be mssql compatible

* Fixed various bugs from MSSQL driver to make tests run

* Fixed mssql unique index to be compatible with other dialect implementations

* Enable running mssql tests on CI

* Test for #2588

* Updated tests to not be dependend on tables left from previous test rans

* Trying to make mssql server work on travis

* Updated changelog and version

* Drop mariadb support  (#2681)

* Dropped support for mariasql

* ESLint

* Fixed docs to build again

* Fix knex.initialize() and adds test (#2477)

* Fix knex.initialize() and adds test

* Fix knex.initialize() and adds test

* Added test for reinitializing pool after destroy

* Fixed destroy / reinitialization test

* Fixed the fix

* Implement missing schema support for mssql dialect

* chore: Update dependencies. Remove estraverse (#2691)

* Update dependencies. Remove estraverse

* Fix compatibility with new Sinon

* Increase mssql timeout

* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)

* Normalized and validated driverNames of test db clients and fixed oracle test setup

* Fixed failed queries from old query building tests which hadn't been ran in ages

* Allow selecting node version which is used to run oracledb docker tests

* Improved sql tester error messages

* Fixed rest of the oracledb tests

* Removed invalid flag from docker-compose

* Print mssql logs if initialization fails

* Fixed syntax error + final tests

* Added restart of failure for mssql DB initialization to try again if server was not ready

* Printout always mssql logs after container is started

* Fixed wait time printing after trying to connect

* Use npm run oracledb:test for testing oracle in travis

* Add Prettier (#2697)

* Add prettier
* Run files through prettier

* Istanbul -> NYC (#2700)

* istanbul -> nyc

* Update mocha

* Enforce code coverage (#2702)

* Enforce code coverage
* Update coverage numbers with current values

* version assignment on base class, copy on tx client, fix #2705

* Update changelog

* v0.15.1

* Added build step to test script. Fixes #2541 (#2712)

* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)

This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.

* Allow oracle failures for now

* Fix issue with select(0) (#2711)

* Fix issue with select(0). Fixes #2658

* Refactor migrator (#2695)

* Refactor migrator

* Fix exports

* Fix ESLint

* Fix migrator

* Fix reference to config

* Split some more

* Fix table builder

* Fix argument order

* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs

# Conflicts:
#	src/migrate/index.js
#	test/index.js
#	test/unit/migrate/migrator.js

* Fix #2715 (#2721)

* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision

* Bump changelog

* 0.15.2

* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)

* Add tests for multiple union arguments with callbacks and builders (#2749)

* Add tests for multiple union arguments

* Add some callback and raw tests to union unit tests

* Compile with before update so that bindings are put in correct order (#2733)

* Fix join using builder withSchema. (#2744)

* Use Datetime2 for MSSQL datetime + timestamp types (#2757)

* Use Datetime2 for MSSQL datetime + timestamp types

Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017

* Add tests for MSSQL datetime2 changes

* General/document breaking change (#2774)

* Add changelog entry for a breaking change

* Improve entry

* Allow timestamp with timezone on mssql databases (#2724)

* Allow timestamp with timezone on mssql databases

* Change timestamp parameter to use object instead of boolean

* Update dependencies (#2772)

* Feature/2690: Multiple migration directories (#2735)

* Implement support for multiple migration directories

* Add tests for new functionality

* Fix tape tests

* Pass migration directory upwards

* Fix multiple directory support

* Fix bugs

* Rollback correctly

* Fix remaining tests

* Address comments

* #2758: Implement fail-fast logic for dialect resolution (#2776)

* Implement fail-fast logic for dialect resolution, clean-up code around.

* Remove method that was deprecated long time ago

* Address additional comments

* Try addressing comments

* Set client explicitly

* Fix compatibility with older Node versions

* Use columnize instead of wrap in using(). (#2713)

* Use columnize instead of wrap in using().

This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.

* Exclude MSSQL from test as it does not support .using

* Change test to not use subquery

* Change test

* Introduced abstraction for getting migrations (#2775)

* Introduced abstraction for getting migrations

This would allow a webpack migration source which is compatible with bundling.

* Fixed migration validation with custom migration source

* Fixed issues after rebasing on muti directory PR

* Renamed parameter and fixed error message

* Addressed some PR comments

* Finished comment

* Moved filename extension filtering into fs-migrator

* Added test showing in memory custom migration source

* Cleaned up how to get config

* Fixed failing test

* Hopefully fix tests

* Fix Node.js 10 support in tests

* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
Tim Griesser
b20a7ad45d version assignment on base class, copy on tx client, fix #2705 2018-07-11 13:31:36 -04:00
Tim Griesser
232fe9f151
Add Prettier (#2697)
* Add prettier
* Run files through prettier
2018-07-09 08:10:34 -04:00
Facundo Matteo
ec8550249f Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query

* Fix another case in which stream doesnt emits error

* Linter stuff

* Remove setTimeout in tests

* Make a test not to check the MySQL error code

* Fix stream error catching for MariaDB and PostgreSQL

* Fix stream error catching in Oracle

* Throw the error after emitting it to the stream

* Throw the error without instantiating a new Error
2018-06-27 22:42:50 +03:00
Sami Koskimäki
1c65e69bc0 fixes 2630 (#2642) 2018-06-05 15:31:09 +03:00
Simon Lidén
65509c38ef Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
2018-05-29 11:42:03 -04: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
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ö
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ö
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
wubzz
98025fae55 searchPath should be case-sensitive (#2172)
Previously `{searchPath: 'TEST'}` would result in `test` rather than `TEST`.
2017-07-25 15:13:07 +02:00
smulesoft
31ba04a788 fixes #1833 on postgres (#2017)
* fixes #1833 on postgres

* adds @elhigu requested changes

* adds test when database is down

* adds script for docker support

* removes old comment

* fixes syntax

* fixes more syntax errors

* fixes final syntax errors

* Docker testing enabled only on linux for now
2017-06-01 22:41:35 +03:00
Tjerk Santegoeds
5c0b193fec fix: escapeObject parameter order for Postgres dialect. (#2003)
* fix: escapeObject parameter order for Postgres dialect.

* test: escapeObject for Postgres dialect.
2017-04-12 13:57:27 +03:00
Mikael Lepistö
137e1fe987 Allow passing version of connected db in configuration file (#1993)
* # This is a combination of 3 commits.
# The first commit's message is:
Allow passing config.version variable to knex instead of parsing the DB version from string returned form DB server.

This makes it possible to connect custom databases which are compatible with an official database of certain version.

# The 2nd commit message will be skipped:

#	Update checkVersion
#
#	To use `const` instead of `let` to fix lint error

# The 3rd commit message will be skipped:

#	Revert "Update checkVersion"
#
#	This reverts commit 248907decb94f0df2f2b3b9fe114738fb48394fc.

* Allow passing config.version variable to knex instead of parsing the DB version from string returned form DB server.

This makes it possible to connect custom databases which are compatible with an official database of certain version.
2017-03-27 00:21:15 +03:00
Casey Foster
19ed460f8b Properly close PG query stream on error (#1935)
Without calling `close()`, the `queryStream` will continue to execute a
query meaning there was no way to halt a long running query due to an
unrecoverable downstream error. I ran into this issue while streaming
IDs from a very large table as part of an ETL process. An error would
occur downstream in the transformation or loading step and I needed to
cancel the long-running extract stream, but there was no way to do so
and I'd eventually run out of connections in the pool.

This commit also handles the case when the non-callback version of
stream API was used and an exception was thrown. The issue was that the
promise was not reachable and therefore there was no way to add a
rejection handler. This resulted in an unavoidable `Unhandled Promise
Rejection` error.
2017-02-24 11:55:13 -05:00
Tim Griesser
5890e4d4ea Fix #1733, #920, incorrect postgres array bindings 2016-10-12 00:43:30 -04:00
Tim Griesser
fa30dfb858 Fix #1710 2016-10-09 14:33:51 -04:00
Tim Griesser
7069ce509e Revert to generic pool (#1665) 2016-09-13 18:12:23 -04:00
Tim Griesser
f5bad1ae54 Simplifying internal client structure 2016-09-13 08:15:58 -04:00
Tim Griesser
ee217ce2a1 Fix PG string escaping behavior (#1661)
* Modify test suite to test #1602
We shouldn’t be testing the “default” client class. Replace any
usages with postgresql

* Simplify knex.raw, deprecate global Knex.raw usage

* Remove unused bluebird shim

* Remove old / unused test comments

* Don't capture Pool2 error event

* Fix pg string escaping & parameterization #1602, #1548
2016-09-12 18:01:47 -04:00
Tim Griesser
6fa485302b Bluebird cleanup (#1618)
* Reference Bluebird directly, Remove deprecated .exec method
* Remove outdated bench scripts
* Remove old .jshintrc file
2016-08-09 17:23:07 -04:00
Rhys van der Waerden
2acd6e5daa Make spaces in import braces consistent
`import {module}` -> `import { module }`
2016-05-18 20:22:50 +10:00
Rhys van der Waerden
3846b7182c Make codebase conform to ESLint rules
Just a couple of changes.
2016-05-17 01:01:34 +10:00
wubzz
fa125712da A default ping fn in default pool settings, and silently ignore errors when querying 'ROLLBACK' on a dead connection by using Promise.Timeout. 2016-04-02 16:35:27 +02:00
freshsun
b34d03c45e update index.js to work with aliyun rds
aliyun rds return a simplified version "PostgreSQL x.x.x", and function checkVersion failed to handle it
2016-03-24 22:17:02 +08:00
wubzz
f37824a11e Fix indentation? 2016-03-15 18:12:36 +01:00
wubzz
1d27fb8550 Update lodash from 3.7.0 -> 4.6.0 2016-03-15 18:11:13 +01:00
gmichael225
4b2c0efff1 SQL compliant escaping, removed dialect-specific escaping for now 2015-12-24 11:33:48 +11:00
Brian Black
51907eebb9 mv src/dialects/postgres/string.js src/dialects/postgres/query/string.js 2015-11-29 18:54:05 -05:00
Brian Black
cee729cad0 Properly escape single quotes in postgres 2015-11-29 18:44:12 -05:00
Brian Black
c6230568cd SqlString is now per-dialect 2015-11-29 18:44:12 -05:00
Mikael Lepistö
0c74f786a5 Optionally use DEFAULT instead of NULL when translating undefined to SQL value. 2015-11-14 19:46:34 +02:00
Mikael Lepistö
b9d9a99f80 Added \? escape sequence to postgres dialect to allow using ? operator. 2015-08-25 10:19:35 +03:00
Daniel Teixeira
70e4692638 add support to postgres search_path 2015-08-09 23:04:57 -03:00
Tim Griesser
6cef074236 Fix correct files for #851 2015-06-01 09:22:27 -04:00
Tim Griesser
521a6f9e97 Remove use strict, assumed in ES6 2015-05-09 14:01:19 -04:00
Tim Griesser
7e884cb325 Babel src -> lib, remove gulp 2015-05-09 13:58:18 -04:00