pqb 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pqb",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Postgres query builder",
5
5
  "homepage": "https://porm.netlify.app/guide/query-builder.html",
6
6
  "repository": {
@@ -1,12 +1,18 @@
1
- import { db } from '../test-utils';
1
+ import { assertType, User } from '../test-utils';
2
+ import { raw } from '../common';
3
+ import { columnTypes } from '../columnSchema';
2
4
 
3
5
  describe('then', () => {
4
6
  describe('catch', () => {
5
- it.only('should catch error', (done) => {
6
- db('kokoko').catch((err) => {
7
- expect(err.message).toBe(`relation "kokoko" does not exist`);
7
+ it('should catch error', (done) => {
8
+ const query = User.select({
9
+ column: raw(columnTypes.boolean(), 'koko'),
10
+ }).catch((err) => {
11
+ expect(err.message).toBe(`column "koko" does not exist`);
8
12
  done();
9
13
  });
14
+
15
+ assertType<Awaited<typeof query>, { column: boolean }[] | void>();
10
16
  });
11
17
  });
12
18
  });
@@ -44,11 +44,11 @@ export class Then {
44
44
  }
45
45
  }
46
46
 
47
- async catch<Result>(
48
- this: Query,
47
+ async catch<T extends Query, Result>(
48
+ this: T,
49
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
50
  fn: (reason: any) => Result | PromiseLike<Result>,
51
- ): Promise<Result> {
51
+ ): Promise<ReturnType<T['then']> | Result> {
52
52
  return this.then(undefined, fn);
53
53
  }
54
54
  }