drizzle-orm 0.10.22 → 0.10.23

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.
@@ -6,8 +6,11 @@ class SetObject extends updates_1.UpdateExpr {
6
6
  super();
7
7
  this.toQuery = (position) => {
8
8
  const nextPosition = position || 1;
9
- const query = `"${this._column.getColumnName()}"=${this._value === null || this._value === undefined ? 'null' : `$${nextPosition}`}`;
10
- return { query, values: [this._column.getColumnType().insertStrategy(this._value)] };
9
+ const valueToInsert = this._value === null || this._value === undefined
10
+ ? this._value
11
+ : this._column.getColumnType().insertStrategy(this._value);
12
+ const query = `"${this._column.getColumnName()}"=$${nextPosition}`;
13
+ return { query, values: [valueToInsert] };
11
14
  };
12
15
  this._column = column;
13
16
  this._value = value;
@@ -17,7 +17,8 @@ class BuilderError extends Error {
17
17
  Reason: ${reason.message}
18
18
  Query builder: ${BuilderType[builderType]}
19
19
  Table name: ${tableName}
20
- Filter query: ${filter ? filter.toQuery() : 'undefined'}
20
+ Filter query: ${filter ? filter.toQuery().query : 'undefined'}
21
+ Values: ${filter ? filter.toQuery().values : 'undefined'}
21
22
  Column names: ${columns.map((column) => column.getColumnName()).join(', ')}\n-----\n`;
22
23
  }
23
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.10.22",
3
+ "version": "0.10.23",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/test.d.ts CHANGED
@@ -0,0 +1 @@
1
+ export {};
package/test.js CHANGED
@@ -1,57 +1,62 @@
1
1
  "use strict";
2
- // import DbConnector from './db/dbConnector';
3
- // import CitiesTable from './docs/tables/citiesTable';
4
- // import UsersTable from './docs/tables/usersTable';
5
- // import ConsoleLogger from './logger/consoleLogger';
6
- // import MigrationSerializer from './serializer/serializer';
7
- // import AbstractTable from './tables/abstractTable';
8
- // (async () => {
9
- // try {
10
- // const db = await new DbConnector()
11
- // .connectionString('postgresql://postgres@127.0.0.1/migrator')
12
- // .connect();
13
- // const usersTable = new UsersTable(db);
14
- // const citiesTable = new CitiesTable(db);
15
- // db.useLogger(new ConsoleLogger());
16
- // const res = await usersTable.select()
17
- // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
18
- // .leftJoin(CitiesTable, (table) => table.id, (table) => table.id)
19
- // // .leftJoin(CitiesTable, UsersTable, (table) => table.userId, (table) => table.id)
20
- // // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
21
- // .execute();
22
- // // const ser = new MigrationSerializer();
23
- // // const res = ser.generate([usersTable as AbstractTable<UsersTable>], []);
24
- // // console.log(JSON.stringify(res, null, 2));
25
- // // const f = {
26
- // // id: count(usersTable.id),
27
- // // };
28
- // // type d = ExtractModel<typeof f>;
29
- // // const res = await usersTable.select({
30
- // // piska: count(),
31
- // // mongodibil: count(usersTable.phone),
32
- // // })
33
- // // .where({
34
- // // piska: eq(),
35
- // // mongodibil: eq(usersTable.phone),
36
- // // }).leftJoin(UsersTable, (table) => table.id, (table) => table.id)
37
- // // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
38
- // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
39
- // // .orderBy((table, join1, join2, join3) => [{table.id}, join1.id, join1.phone])
40
- // // .execute();
41
- // // const res = await usersTable.select()
42
- // // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
43
- // // .leftJoin(UsersTable, (table) => table.foundationDate, (table) => table.id)
44
- // // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
45
- // // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
46
- // // // .groupBy({
47
- // // // usersTable: usersTable.id,
48
- // // // firstJoin: [usersTable.id],
49
- // // // secondJoin: usersTable.id,
50
- // // // thirdJoin: usersTable.id,
51
- // // // })
52
- // // .execute();
53
- // // console.log(res);
54
- // } catch (e) {
55
- // console.log(e);
56
- // }
57
- // })();
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const static_1 = require("./builders/requestBuilders/where/static");
4
+ const dbConnector_1 = require("./db/dbConnector");
5
+ const citiesTable_1 = require("./docs/tables/citiesTable");
6
+ const usersTable_1 = require("./docs/tables/usersTable");
7
+ const consoleLogger_1 = require("./logger/consoleLogger");
8
+ (async () => {
9
+ try {
10
+ const db = await new dbConnector_1.default()
11
+ .connectionString('postgresql://postgres@127.0.0.1/migrator')
12
+ .connect();
13
+ const usersTable = new usersTable_1.default(db);
14
+ const citiesTable = new citiesTable_1.default(db);
15
+ db.useLogger(new consoleLogger_1.default());
16
+ const phone = undefined;
17
+ const res = await usersTable.update()
18
+ // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
19
+ .where(static_1.eq(usersTable.id, 16))
20
+ .set({
21
+ phone,
22
+ })
23
+ // .leftJoin(CitiesTable, UsersTable, (table) => table.userId, (table) => table.id)
24
+ // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
25
+ .execute();
26
+ // const ser = new MigrationSerializer();
27
+ // const res = ser.generate([usersTable as AbstractTable<UsersTable>], []);
28
+ // console.log(JSON.stringify(res, null, 2));
29
+ // const f = {
30
+ // id: count(usersTable.id),
31
+ // };
32
+ // type d = ExtractModel<typeof f>;
33
+ // const res = await usersTable.select({
34
+ // piska: count(),
35
+ // mongodibil: count(usersTable.phone),
36
+ // })
37
+ // .where({
38
+ // piska: eq(),
39
+ // mongodibil: eq(usersTable.phone),
40
+ // }).leftJoin(UsersTable, (table) => table.id, (table) => table.id)
41
+ // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
42
+ // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
43
+ // .orderBy((table, join1, join2, join3) => [{table.id}, join1.id, join1.phone])
44
+ // .execute();
45
+ // const res = await usersTable.select()
46
+ // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
47
+ // .leftJoin(UsersTable, (table) => table.foundationDate, (table) => table.id)
48
+ // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
49
+ // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
50
+ // // .groupBy({
51
+ // // usersTable: usersTable.id,
52
+ // // firstJoin: [usersTable.id],
53
+ // // secondJoin: usersTable.id,
54
+ // // thirdJoin: usersTable.id,
55
+ // // })
56
+ // .execute();
57
+ // console.log(res);
58
+ }
59
+ catch (e) {
60
+ console.log(e);
61
+ }
62
+ })();