drizzle-orm 0.10.12 → 0.10.15

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.
@@ -45,7 +45,8 @@ class SelectAggregator extends abstractAggregator_1.default {
45
45
  this.orderBy = (column, order) => {
46
46
  if (column !== null && column !== undefined) {
47
47
  this._orderBy.push('ORDER BY ');
48
- this._orderBy.push(`${column.getColumnName()} `);
48
+ const columnParent = this._joinCache[column.getParent().tableName()] ? this._joinCache[column.getParent().tableName()] : column.getParent().tableName();
49
+ this._orderBy.push(`${columnParent}.${ecranate_1.ecranate(column.getColumnName())} `);
49
50
  this._orderBy.push(order_1.default[order]);
50
51
  }
51
52
  return this;
@@ -15,7 +15,7 @@ class ConstArray extends where_1.default {
15
15
  finalArray.push(`$${nextPosition}`);
16
16
  finalValues.push(`${value.toISOString()}`);
17
17
  }
18
- if (ecranate_1.shouldEcranate(value)) {
18
+ else if (ecranate_1.shouldEcranate(value)) {
19
19
  finalArray.push(`$${nextPosition}`);
20
20
  finalValues.push(`${value.toString()}`);
21
21
  }
@@ -28,7 +28,7 @@ class ConstArray extends where_1.default {
28
28
  }
29
29
  nextPosition += 1;
30
30
  }
31
- return { query: finalArray.join(','), values: finalValues };
31
+ return { query: finalArray.join(''), values: finalValues };
32
32
  };
33
33
  this.values = values;
34
34
  }
package/columns/column.js CHANGED
@@ -16,7 +16,15 @@ class AbstractColumn {
16
16
  this.getParent = () => this.parent;
17
17
  this.getParentName = () => this.parentTableName;
18
18
  this.defaultValue = (value) => {
19
- this.defaultParam = value;
19
+ if (Defaults[value] !== undefined) {
20
+ this.defaultParam = value;
21
+ }
22
+ else if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'bigint') {
23
+ this.defaultParam = value;
24
+ }
25
+ else {
26
+ this.defaultParam = `'${value}'`;
27
+ }
20
28
  return this;
21
29
  };
22
30
  this.unique = () => {
@@ -9,6 +9,9 @@ class PgInteger extends columnType_1.default {
9
9
  this.dbName = 'INT';
10
10
  }
11
11
  selectStrategy(value) {
12
+ if (typeof value === 'string') {
13
+ return value ? parseInt(value, 10) : undefined;
14
+ }
12
15
  return value;
13
16
  }
14
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.10.12",
3
+ "version": "0.10.15",
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,45 +1,50 @@
1
1
  "use strict";
2
- // import DbConnector from './db/dbConnector';
3
- // import UsersTable from './docs/tables/usersTable';
4
- // import ConsoleLogger from './logger/consoleLogger';
5
- // import { count } from './tables/aggregators';
6
- // (async () => {
7
- // try {
8
- // const db = await new DbConnector()
9
- // .connectionString('postgresql://postgres@127.0.0.1/migrator')
10
- // .connect();
11
- // const usersTable = new UsersTable(db);
12
- // db.useLogger(new ConsoleLogger());
13
- // // const f = {
14
- // // id: count(usersTable.id),
15
- // // };
16
- // // type d = ExtractModel<typeof f>;
17
- // // const res = await usersTable.select({
18
- // // piska: count(),
19
- // // mongodibil: count(usersTable.phone),
20
- // // })
21
- // // .where({
22
- // // piska: eq(),
23
- // // mongodibil: eq(usersTable.phone),
24
- // // }).leftJoin(UsersTable, (table) => table.id, (table) => table.id)
25
- // // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
26
- // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
27
- // // .orderBy((table, join1, join2, join3) => [{table.id}, join1.id, join1.phone])
28
- // // .execute();
29
- // const res = await usersTable.select()
30
- // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
31
- // .leftJoin(UsersTable, (table) => table.id, (table) => table.id)
32
- // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
33
- // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
34
- // // .groupBy({
35
- // // usersTable: usersTable.id,
36
- // // firstJoin: [usersTable.id],
37
- // // secondJoin: usersTable.id,
38
- // // thirdJoin: usersTable.id,
39
- // // })
40
- // .execute();
41
- // console.log(res);
42
- // } catch (e) {
43
- // console.log(e);
44
- // }
45
- // })();
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dbConnector_1 = require("./db/dbConnector");
4
+ const usersTable_1 = require("./docs/tables/usersTable");
5
+ const consoleLogger_1 = require("./logger/consoleLogger");
6
+ const serializer_1 = require("./serializer/serializer");
7
+ (async () => {
8
+ try {
9
+ const db = await new dbConnector_1.default()
10
+ .connectionString('postgresql://postgres@127.0.0.1/migrator')
11
+ .connect();
12
+ const usersTable = new usersTable_1.default(db);
13
+ db.useLogger(new consoleLogger_1.default());
14
+ const ser = new serializer_1.default();
15
+ const res = ser.generate([usersTable], []);
16
+ console.log(JSON.stringify(res, null, 2));
17
+ // const f = {
18
+ // id: count(usersTable.id),
19
+ // };
20
+ // type d = ExtractModel<typeof f>;
21
+ // const res = await usersTable.select({
22
+ // piska: count(),
23
+ // mongodibil: count(usersTable.phone),
24
+ // })
25
+ // .where({
26
+ // piska: eq(),
27
+ // mongodibil: eq(usersTable.phone),
28
+ // }).leftJoin(UsersTable, (table) => table.id, (table) => table.id)
29
+ // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
30
+ // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
31
+ // .orderBy((table, join1, join2, join3) => [{table.id}, join1.id, join1.phone])
32
+ // .execute();
33
+ // const res = await usersTable.select()
34
+ // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
35
+ // .leftJoin(UsersTable, (table) => table.id, (table) => table.id)
36
+ // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
37
+ // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
38
+ // // .groupBy({
39
+ // // usersTable: usersTable.id,
40
+ // // firstJoin: [usersTable.id],
41
+ // // secondJoin: usersTable.id,
42
+ // // thirdJoin: usersTable.id,
43
+ // // })
44
+ // .execute();
45
+ // console.log(res);
46
+ }
47
+ catch (e) {
48
+ console.log(e);
49
+ }
50
+ })();