87 Commits

Author SHA1 Message Date
Igor Savin
80a2516734
Throw better error when trying to modify schema while using unsupported dialect (#3609) 2020-01-05 00:04:41 +01:00
Lorefnon
79ccb7d8bd Lift up dialect specific methods in the CreateTableBuilder (#3532) 2019-11-21 15:22:29 +01:00
Alexandre BODIN
0214f11663 Make sqlite3 hasColumn case insensitive (#3435) 2019-11-14 19:31:59 +01:00
Igor Savin
1c65562440 Prepare 0.20.0 release 2019-10-25 20:17:26 +02:00
Lorefnon
20bd04b594 Fix bugs in replacement logic used when dropping columns in SQLite. (#3476) 2019-10-11 22:38:01 +02:00
Ihor Sakaylyuk
1ef1a4ef07 Fix native enum with specified schema (#3307) (#3400) 2019-08-24 17:37:29 +02:00
Igor Savin
871dadb348
More consistent handling of nested transactions (#3393) 2019-08-16 16:28:25 +02:00
Igor Savin
e971c5198b
Update dependencies, fix new eslint errors (#3339) 2019-07-10 20:47:56 +02:00
Lorefnon
56c3af8512 Fix issues around specifying default values for columns (#3318) 2019-06-30 20:08:15 +02:00
Igor Savin
4b6429ebf9
Reduce bluebird usage (#3267) 2019-06-08 02:34:41 +02:00
elunic
19926d8eba [#3033] fix: sqlite3 drop/renameColumn() breaks with postProcessResponse (#3040)
* [#3033] fix: sqlite3 drop/renameColumn() breaks with postProcessResponse

* When postProcessResponse is configured, and client.processResponse()
returns a Promise (e.g. for custom cases such as sqlite3 dropColumn()),
then that Promise is not awaited, but handed to postProcessResponse,
which might break is (e.g. with Objection's knexSnakeCaseMappers()).

* when reinserting data in the modified table, the rows are now being
handled with the "mapped" identifiers (instead of the unmapped)

* add tests, fix hasColumn

* add hasColumn tests for add mysql + snakeCaseMappers

* Improve tests and fix more cases related to processing

* Fix SQLite-specific tests

* MySQL is not case-sensitive, pg is
2019-03-13 22:58:59 +01:00
Randy Garces
c2bf7a375c MSSQL removes support column width/length on data type int and tinyint (#2738)
* MSSQL remove support column width/length on data type int

- fixes error `Cannot specify a column width on data type int`
- ignore length even if pass as agrument

* Add integration test for numeric lengths

* Fix syntax

* Add test that actually executes SQL

* Fix failing tests

* Fix tests
2019-03-05 01:02:06 +01:00
Eric Kennedy
1c0dc2c913 Add option of existingType to .enum method to support repeated use of enums (#2719)
* Update table column .enu to take an option that does not manually create the type

* Add tests for psql enum existingType

* Avoid utilizing enum values when using an existing type
2018-11-09 09:47:15 +01:00
Henry Williams
2611e5a300 Fix linter errors in tests (#2859)
* fix lint errors for tests
2018-10-15 22:29:53 -04:00
Igor Savin
96a8e3a4d8 Add support for named unique, primary and foreign keys to SQLite3 (#2840)
* Add support for named unique, primary and foreign keys to SQLite3

* Add integration testing for named keys

* Improve tests for primary and unique keys

* Improve tests for foreign keys

* Run prettier

* Fix tests

* Fix additional test
2018-10-11 19:14:26 +03:00
Will Morgan
fac313f27f 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
2018-08-13 15:33:37 -05:00
Fabian Kantereit
e08c14b7b1 Implement missing schema support for mssql dialect 2018-07-10 12:55:12 -04:00
Tim Griesser
232fe9f151
Add Prettier (#2697)
* Add prettier
* Run files through prettier
2018-07-09 08:10:34 -04:00
Mikael Lepistö
cb3a85e738
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
2018-07-08 14:10:51 +03:00
Mikael Lepistö
e2f617b968
Drop mariadb support (#2681)
* Dropped support for mariasql

* ESLint
2018-07-01 23:06:26 +03:00
Mikael Lepistö
b349ac4a8c
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
2018-06-29 10:47:06 +03:00
Will
7a60e310c8 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>
2018-05-29 10:09:13 -04:00
Michael Oliver
db390b11e6 Increment floats (#2614)
* Fix increment/decrement with float values

* parse float in mariadb

* mysql produces float(8, 2), not double
2018-05-19 11:49:00 +03: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
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
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
Richard Ižip
16a4eb1455 Fix adding more columns in Oracle (#2115)
* Fix incorrent unit tests to reflect
  current changes
2017-06-10 21:01:57 +03:00
irsl
5fc456cb69 integration test for sqlite3, referencing non-existent column in the query (#2104)
* integration test for sqlite3, referencing non-existent column in the query

* making node 0.12 happy
2017-06-10 01:20:59 +03:00
Ronny Badilla
198da1b273 Change the way that MySQL verifies if a table exists (#2097) 2017-06-09 23:19:37 +03:00
irsl
a47a077330 Field identifiers were not quoted properly in Sqlite3 dialect (#2087)
* field wrapping changed from quotes to backticks in sqlite3 dialect; unit tests adjusted accordingly

* addColumn was accidently removed
2017-05-28 23:48:18 +03:00
GONZO
68af752bbe fixed table alter attributes order. (first, after) (#2062)
* fixed table alter attribute order. (first, after)

* add test cases, alter table position with comment.

* add real database test cases.

* after, first tests only mysql or mariadb.
2017-05-15 13:16:15 +03:00
Carlos Ramos
18581f9632 Add support for enum columns to SQlite3 dialect (#2055) 2017-05-10 20:04:13 +03:00
vellotis
fe4ec15ae0 Support custom foreign key names (continued work of #1311) (#1726)
* Added support for custom foreign key name

* Update unit test for #1311

* Fix TableCompiler::foreign to respect previous behavior + typo

* Add dialect specific unit tests

* Fixed comment

Actually trying to trigger travis to run tests with latest travis configuration... (maybe it just doesn't run tests against merged branch..)
2017-02-17 00:35:43 +02:00
Mikael Lepistö
77e67334a3 Alter column syntax for table, implements changing type, nullability and default (#1914)
* Added support for altering columns

* Add mysql dialect key for alter (modify)

* Added tests for .alter()

* Updated dialects for .alter() on column

* .alter() for mssql and tests

* Added an error for sqlite3 alter column

Sqlite does not support alter column at all

* Implemented schema alter column support for postgresql

* Added unit test for alter column and fixed postgres implementation

* Add test case for adding multiple columns at once (oracle check)

* Try upgrading CI mysql / postgres and distro

* Disabled adding multiple columns test from oracle

* Fixed node 0.12 test compatibility

* Fixed review comments
2017-02-16 20:34:59 +02:00
statyan
6ecd8f3793 Fixed knex #1577 (#1578)
* Fixed knex #1577
Aslo corrected tests for primarykey

* Fix for installing from github

* Fix for installing from github

* Fix for installing from github
2016-07-20 11:22:17 +10:00
wubzz
c2c31ce859 Change default constraintName in .primary() to match docs and .dropPrimary() 2016-05-19 22:13:09 +02:00
wubzz
5a6ab64d06 Ensure .primary() and .dropPrimary() are the same across all dialects. 2016-05-19 21:30:17 +02:00
Wolfgang Faust
a7f609aa4f mssql dialect: Fix integration tests that check for quoted wrappers.
PR #1289 made it quote the index/constraint names, but did not update the tests accordingly.
2016-04-21 20:56:41 +00:00
wubzz
d3b1fcc4b8 Fixed test, forgot ES6 is not supported in the test suite. 2016-04-01 23:39:04 +02:00
wubzz
0b45356456 .renameColumn should not drop defaultValue or nullable state. Currently this happens for mysql. Fixes #933 2016-04-01 23:37:12 +02:00
Max Claus Nunes
8d6264e96b wrap index names 2016-03-16 21:52:51 -03:00
wubzz
faca736ed5 Fix jshint issues 2016-03-11 23:32:43 +01:00
wubzz
2738697f42 Add a TypeError when failing to supply a callback function to .createTable and .table. 2016-03-11 23:22:30 +01:00
wubzz
7cc827f6cf Merge pull request #1258 from jurko-gospodnetic/code-cleanup
Code cleanup (trimmed trailing spaces & removed tabs)
2016-03-08 13:13:48 +01:00
Ngoc Tran
ac294c5d47 Renamed table name to more accurately reflect test. 2016-03-08 01:31:22 -08:00
Ngoc Tran
755ad78df4 Fixes #1220 bug to now throw TypeError if parameter passed into inTable() is not typeof === 'string'. 2016-03-08 01:28:58 -08:00
Jurko Gospodnetić
16a076c1a0 trim trailing spaces
Only left alone ones in `test/tape/transactions.js` which would just
cause unnecessary conflicts and get cleaned up by separate pull
request #1257 anyway.
2016-03-08 08:44:01 +01:00
Ngoc Tran
60f8062cfe Fixes #1220, https://github.com/tgriesser/knex/issues/1220, inTable(undefined) fails silently error by making sure it throws an error if the user passes an undefined table name. 2016-03-07 03:33:17 -08:00
Sky Morey
f99d3952a1 changed mssql to compact create format. changed unique index to unique constraint 2015-12-14 16:20:45 -06:00
Sky Morey
371815d7e6 made SCHEMA upper case for mssql 2015-12-14 09:56:53 -06:00