drizzle-orm 0.10.42 → 0.10.43

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.
@@ -10,7 +10,7 @@ class PgJsonb extends columnType_1.default {
10
10
  super();
11
11
  this.getDbName = () => this.dbName;
12
12
  // public insertStrategy = (value: TCodeType): string => `'${JSON.stringify(value).replace(/'/g, "''")}'::jsonb`;
13
- this.insertStrategy = (value) => `${JSON.stringify(value).replace(/'/g, "''")}`;
13
+ this.insertStrategy = (value) => `${JSON.stringify(value)}`;
14
14
  this.dbName = 'JSONB';
15
15
  }
16
16
  selectStrategy(value) {
@@ -8,7 +8,7 @@ class PgText extends columnType_1.default {
8
8
  constructor() {
9
9
  super();
10
10
  this.getDbName = () => this.dbName;
11
- this.insertStrategy = (value) => `${value.replace(/'/g, "''")}`;
11
+ this.insertStrategy = (value) => `${value}`;
12
12
  this.dbName = 'TEXT';
13
13
  }
14
14
  selectStrategy(value) {
@@ -8,7 +8,7 @@ class PgVarChar extends columnType_1.default {
8
8
  constructor(size) {
9
9
  super();
10
10
  this.getDbName = () => this.dbName;
11
- this.insertStrategy = (value) => `${value.replace(/'/g, "''")}`;
11
+ this.insertStrategy = (value) => `${value}`;
12
12
  this.size = size;
13
13
  if (size) {
14
14
  this.dbName = `character varying(${size})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.10.42",
3
+ "version": "0.10.43",
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,104 +1,104 @@
1
1
  "use strict";
2
- // import { QueryResult } from 'pg';
3
- // import { drizzle } from '.';
4
- // import {
5
- // and, eq, greater, isNotNull, less, or,
6
- // } from './builders';
7
- // import { DB } from './db';
8
- // import DbConnector from './db/dbConnector';
9
- // import Session, { ISession } from './db/session';
10
- // import UsersTable from './docs/tables/usersTable';
11
- // import ConsoleLogger from './logger/consoleLogger';
12
- // class KnexSession extends ISession {
13
- // public execute(query: string, values?: any[]): Promise<QueryResult<any>> {
14
- // console.log(query);
15
- // console.log(values);
16
- // return { rows: [] } as any;
17
- // }
18
- // public parametrized(num: number): string {
19
- // return `?${num}`;
20
- // }
21
- // }
22
- // (async () => {
23
- // try {
24
- // // const db = await new DbConnector()
25
- // // .connectionString('postgresql://postgres@127.0.0.1/migrator')
26
- // // .connect();
27
- // const db = new DB(new KnexSession());
28
- // // db.useLogger(new ConsoleLogger());
29
- // const usersTable = new UsersTable(db);
30
- // await usersTable.select().where(or([
31
- // and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
32
- // eq(usersTable.role, 'bar'),
33
- // greater(usersTable.decimalField, 1),
34
- // ])).execute();
35
- // await usersTable.delete().where(or([
36
- // and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
37
- // eq(usersTable.role, 'bar'),
38
- // greater(usersTable.decimalField, 1),
39
- // ])).execute();
40
- // await usersTable.update().where(or([
41
- // and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
42
- // eq(usersTable.role, 'bar'),
43
- // greater(usersTable.decimalField, 1),
44
- // ])).set({
45
- // isArchived: false,
46
- // role: 'bar',
47
- // }).execute();
48
- // await usersTable.insert({
49
- // isArchived: false,
50
- // role: 'bar',
51
- // decimalField: 12,
52
- // createdAt: new Date(),
53
- // }).execute();
54
- // // drizzle.migrator(db).migrate({ migrationFolder: 'drizzle' });
55
- // // type g = ReturnType<typeof usersTable.updatedAt.getColumnType>['codeType'];
56
- // // type f = ExtractColumnType<typeof usersTable.updatedAt>;
57
- // // type f1 = ExtractColumnType1<f>;
58
- // // const citiesTable = new CitiesTable(db);
59
- // // await usersTable.insert({
60
- // // });
61
- // // const res = await citiesTable.update()
62
- // // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
63
- // // .where(eq(citiesTable.location, 'YR'))
64
- // // .set({
65
- // // metadata: [{
66
- // // fallback_image: true,
67
- // // team_image: 'https://files.slack.com/files-pri/T016CCC3FE3-F03461UR9M5/clinic_team_photo_1.jpg?pub_secret=560c098bfb',
68
- // // image_alt_text: 'Generic Physiotherapy Clinic image 1',
69
- // // logo: '',
70
- // // logo_alt_text: ''
71
- // // }],
72
- // // })
73
- // // // .leftJoin(CitiesTable, UsersTable, (table) => table.userId, (table) => table.id)
74
- // // // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
75
- // // .execute();
76
- // // console.log(res);
77
- // // const ser = new MigrationSerializer();
78
- // // const res = ser.generate([usersTable as AbstractTable<UsersTable>], []);
79
- // // console.log(JSON.stringify(res, null, 2));
80
- // // const f = {
81
- // // id: count(usersTable.id),
82
- // // };
83
- // // type d = ExtractModel<typeof f>;
84
- // // const res = await usersTable.select()
85
- // // .leftJoin(UsersTable, (table) => table.id, (table) => table.id)
86
- // // .leftJoin(UsersTable, CitiesTable, (table) => table.id, (table) => table.id)
87
- // // .execute();
88
- // // const res = await usersTable.select()
89
- // // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
90
- // // .leftJoin(UsersTable, (table) => table.foundationDate, (table) => table.id)
91
- // // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
92
- // // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
93
- // // // .groupBy({
94
- // // // usersTable: usersTable.id,
95
- // // // firstJoin: [usersTable.id],
96
- // // // secondJoin: usersTable.id,
97
- // // // thirdJoin: usersTable.id,
98
- // // // })
99
- // // .execute();
100
- // // console.log(res);
101
- // } catch (e) {
102
- // console.log(e);
103
- // }
104
- // })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const dbConnector_1 = __importDefault(require("./db/dbConnector"));
7
+ const session_1 = require("./db/session");
8
+ const usersTable_1 = __importDefault(require("./docs/tables/usersTable"));
9
+ class KnexSession extends session_1.ISession {
10
+ execute(query, values) {
11
+ console.log(query);
12
+ console.log(values);
13
+ return { rows: [] };
14
+ }
15
+ parametrized(num) {
16
+ return `${num}?`;
17
+ }
18
+ }
19
+ (async () => {
20
+ try {
21
+ const db = await new dbConnector_1.default()
22
+ .connectionString('postgresql://postgres@127.0.0.1/migrator')
23
+ .connect();
24
+ // const db = new DB(new KnexSession());
25
+ // db.useLogger(new ConsoleLogger());
26
+ const usersTable = new usersTable_1.default(db);
27
+ // await usersTable.select().where(or([
28
+ // and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
29
+ // eq(usersTable.role, 'bar'),
30
+ // greater(usersTable.decimalField, 1),
31
+ // ])).execute();
32
+ // await usersTable.delete().where(or([
33
+ // and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
34
+ // eq(usersTable.role, 'bar'),
35
+ // greater(usersTable.decimalField, 1),
36
+ // ])).execute();
37
+ // await usersTable.update().where(or([
38
+ // and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
39
+ // eq(usersTable.role, 'bar'),
40
+ // greater(usersTable.decimalField, 1),
41
+ // ])).set({
42
+ // isArchived: false,
43
+ // role: 'bar',
44
+ // }).execute();
45
+ await usersTable.insert({
46
+ isArchived: false,
47
+ role: 'bar',
48
+ decimalField: 12,
49
+ phone: ' tedss\'t',
50
+ media: [' tes\'t', ' t\'es\'t'],
51
+ createdAt: new Date(),
52
+ }).execute();
53
+ // drizzle.migrator(db).migrate({ migrationFolder: 'drizzle' });
54
+ // type g = ReturnType<typeof usersTable.updatedAt.getColumnType>['codeType'];
55
+ // type f = ExtractColumnType<typeof usersTable.updatedAt>;
56
+ // type f1 = ExtractColumnType1<f>;
57
+ // const citiesTable = new CitiesTable(db);
58
+ // await usersTable.insert({
59
+ // });
60
+ // const res = await citiesTable.update()
61
+ // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
62
+ // .where(eq(citiesTable.location, 'YR'))
63
+ // .set({
64
+ // metadata: [{
65
+ // fallback_image: true,
66
+ // team_image: 'https://files.slack.com/files-pri/T016CCC3FE3-F03461UR9M5/clinic_team_photo_1.jpg?pub_secret=560c098bfb',
67
+ // image_alt_text: 'Generic Physiotherapy Clinic image 1',
68
+ // logo: '',
69
+ // logo_alt_text: ''
70
+ // }],
71
+ // })
72
+ // // .leftJoin(CitiesTable, UsersTable, (table) => table.userId, (table) => table.id)
73
+ // // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
74
+ // .execute();
75
+ // console.log(res);
76
+ // const ser = new MigrationSerializer();
77
+ // const res = ser.generate([usersTable as AbstractTable<UsersTable>], []);
78
+ // console.log(JSON.stringify(res, null, 2));
79
+ // const f = {
80
+ // id: count(usersTable.id),
81
+ // };
82
+ // type d = ExtractModel<typeof f>;
83
+ // const res = await usersTable.select()
84
+ // .leftJoin(UsersTable, (table) => table.id, (table) => table.id)
85
+ // .leftJoin(UsersTable, CitiesTable, (table) => table.id, (table) => table.id)
86
+ // .execute();
87
+ // const res = await usersTable.select()
88
+ // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
89
+ // .leftJoin(UsersTable, (table) => table.foundationDate, (table) => table.id)
90
+ // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
91
+ // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
92
+ // // .groupBy({
93
+ // // usersTable: usersTable.id,
94
+ // // firstJoin: [usersTable.id],
95
+ // // secondJoin: usersTable.id,
96
+ // // thirdJoin: usersTable.id,
97
+ // // })
98
+ // .execute();
99
+ // console.log(res);
100
+ }
101
+ catch (e) {
102
+ console.log(e);
103
+ }
104
+ })();