43 Commits

Author SHA1 Message Date
Lorefnon
501d58a6d9 Address concerns around count typings (#3249)
* Use number instead of number | string for return type of count

Closes #3247

* Use an alias instead of interface for DeferredKeySelection

This prevents typescript from complaining when it has to be used in an exported signature without us having to expose internal type as public

Closes #3259

* Make count result type overridable

* Disable interface-over-type-literal rule
2019-06-06 08:24:28 +02:00
Lorefnon
0d1fb16240 Improve typings for aggregations (#3245) 2019-06-02 22:52:16 +02:00
Sangmin Lee
0521beac82 Add decimalNumbers to MySqlConnectionConfig interface (#3244) 2019-06-02 15:20:24 +02:00
Lorefnon
9f0da44ef2 Improve count typings (#3239)
- Make count generic, especially useful when being used with an alias object argument
- In case of alias object, partially infer the return type from the input.
2019-06-01 11:37:02 +02:00
Lorefnon
1b2b6bbf8c Update type of aggregation results to not be arrays when first had been invoked before (#3237)
Addresses: https://github.com/tgriesser/knex/issues/3229#issuecomment-497560577
2019-05-31 08:20:48 +02:00
Lorefnon
bd63288d41 Include undefined in Single row results (#3231) 2019-05-31 00:03:08 +02:00
Lee Allen
1fe5ee0ea3 Add migrate:down functionality (#3228) 2019-05-30 00:37:18 +02:00
Lorefnon
d62d280b4f Fix incorrect type definitions for single row queries (#3230)
Closes #3229
2019-05-29 22:48:10 +02:00
Igor Savin
5307dacc66
Implement support for returning started transaction without using transaction() methods callback function (#3099) 2019-05-26 18:03:07 -07:00
Lorefnon
fb91f654b8 Update Knex.Config types to include log (#3221)
Fixes #3148
2019-05-26 12:53:26 -07:00
Lorefnon
9c6ab963f6 Fix some more cases of missing typings (#3223)
* Fix some more cases of missing typings

- Add types for Seed API
- Add Knex#initialize (Closes #3192)

* Relax constraints on raw queries and add tests
2019-05-26 12:52:55 -07:00
Lorefnon
92cb805669 Support type safe refs (#3215) 2019-05-21 22:52:13 -07:00
Lorefnon
5dab3a5e74 Expose some utility types
Ref: https://github.com/tgriesser/knex/pull/3036#issuecomment-493751631

Co-authored-by: Sagar Chamling <sgr.raee@gmail.com>
2019-05-19 13:28:15 -07:00
Lorefnon
e2e044c0f2 Unify object options handling for datetime/timestamp across dialects and update type definitions (#3181)
* Fix windows incompatiblity in npm scripts

* Update timestamp and datetime signature in oracle dialect to be consistent with other dialects
2019-05-19 05:10:59 -07:00
Lee Allen
08478f2db9 Feature/add up for migrations (#3205)
* Add ability to run migrate:up command to only run the next migration

* Add cli test for migrate:up

* Add test for migrator

* Add stub

* Add type

* Fix wording of test
2019-05-19 04:14:52 -07:00
Lorefnon
3b3fdf4c91 Fix issues with typings of joins and some conflicts with Bluebird typings (#3209) 2019-05-19 03:53:48 -07:00
Lorefnon
edd807f96c Resolve more issues around generic typings (#3208)
- Fix: update, insert, delete didn't support deferring of result resolution unlike select.
  So knex.insert(...).into<User>('users') would fall back to any

- Correctly handling cases when deferred selection keys get cleared later eg. multiple returning invocations, clearSelect.

- Fix: first resolves to array member rather than array.

- Add explanations for some of the complex type applications.
2019-05-18 00:47:06 +02:00
Lorefnon
91192fe4c4 Make typings more compatible with previous version (#3195) 2019-05-16 22:25:37 +02:00
Igor Savin
cf435d9175
Prepare for 0.16.7 release (#3190) 2019-05-12 17:21:40 +02:00
Lorefnon
1f4c8839a6 Add default values for generic types (#3189) 2019-05-12 16:32:13 +02:00
Daniel Mills
617d36ea01 add clearHaving function and add test (#3141) 2019-05-12 10:20:26 +02:00
Lorefnon
6a4fecfe78 Make function types generic in type definitions (#3168)
* Make function types generic in type definitions

* Add dtslint and tests for type definitions
2019-05-04 10:34:07 +02:00
Max Beatty
70712f6689 add missing types to MigratorConfig (#3174) 2019-04-30 09:33:05 +02:00
Michaël Bitard
0e845489ca adding types for havingBetween orHavingBetween havingNotBetween orHavingNotBetween (#3144) 2019-04-16 00:38:26 +02:00
Felix Mosheev
1948c3d423 Add boolean as a column name in join (#3121) 2019-03-30 18:55:02 +01:00
Andrew Schmadel
b15ee3def1 make unionAll()'s call signature match union() (#3055)
* make unionAll()'s call signature match union()

consolidates the logic used by union() and unionAll(), allowing the two to be used interchangeably

* use spread args instead of arguments array

* Fix unionAll spread arguments
2019-03-29 19:55:32 +02:00
Felix Mosheev
11fdc0c90a Add missing clearOrder & clearCounters types (#3109) 2019-03-14 14:11:05 +01: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
Iacami Gevaerd
de1c9341b3 Include 'string' as accepted Knex constructor type definition (#3105) 2019-03-12 23:03:02 +01:00
Chathu Vishwaijith
cfcb55d1c4 Add size parameter to integer method (#3074)
* Add size parameter to integer method

Size parameter work when we pass it. But it's not in definition.

* Change parameter to length

* Update knex.d.ts

Fix typo
2019-03-04 13:04:11 +01:00
Will
a109a801b0 Update enum arguments to reflect latest signature (#3043)
* Update enum arguments to reflect latest signature

Reimplemented from https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29946

* Update knex.d.ts

Add missing option for PostgreSQL
2019-03-04 00:11:36 +01:00
thekuom
71e097b663 add intersect() (#3023)
* add intersect()

* update intersect integration tests to validate results

* use const instead of var, remove .only in test, remove commented out type
2019-03-03 20:57:40 +01:00
Martin Mouterde
a2b7e0e322 schemaName is missing in MigratorConfig typings (#3016)
* schemaName is missing in MigratorConfig typings

add a schemaName value to MigratorConfig.

* update MigratorConfig typings

- change type of `directory` from `string` to `string | string[]`
- add `sortDirsSeparately` as boolean optional config.
2019-01-28 19:08:23 +01:00
Felipe Menegossi
4f8cf79500 Add "constraintName" arg to TS definition (#3006)
Add constraintName optional argument to TableBuilder.primary() TypeScript definition.
Currently, if you give the second argument, TS will tell that primary() expects only 1 argument, when in fact it supports the second optional argument to define the constraint name into the database.
2019-01-22 11:12:31 +01:00
EthanHur
7b8b74dbef add .queryContext() type definition Knex.Raw (#3002) 2019-01-16 10:25:54 +01:00
EthanHur
d857872f62 typescript type support for .asCallback() (#2963) 2019-01-16 09:12:15 +02:00
jasmeeto
5bc8deebe1 Issue 2970: Add toNative() definition in typescript (#2996) 2019-01-13 17:33:00 +01:00
Demur Rumed
83fcefe4e0 Fix typings (#2960)
* Fix typings

* Fixed JoinRaw, RawQueryBuilder and RawBuilder interfaces.

* Update knex.d.ts
2019-01-04 21:49:39 +01:00
André Cruz
c2dff7f843 Implemented extra boolean param for rollback() (#2968)
* Implemented extra boolean param for rollback()
Extra parameter allows all migrations to be rolled back.

* Removed spurious log

* Removed stray debugger instruction

* Moved to arrow functions
2018-12-20 17:05:28 -06:00
moonchang, Jang
8173e3fbfd Add queryContext to type declarations (#2931) 2018-11-26 14:37:38 +01:00
EthanHur
4db047df02 support multiple columns in .orderBy() (#2881)
* support multiple columns in `.orderBy()`

* add unit tests of order by

* orderByArray function to private

* use isString in string check
2018-11-06 22:30:06 +01:00
sgoll
cdccb12b72 Adjust typing for forUpdate()/forShare() variant with table names (#2858) 2018-10-14 19:39:43 -04:00
Tim Griesser
b2450a94dc
Manage types internally (#2845)
* Manage types internally
* Update CONTRIBUTING
2018-10-08 17:54:26 -04:00