rado 1.2.0 → 1.3.0-preview.0

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.
Files changed (86) hide show
  1. package/README.md +163 -257
  2. package/dist/compat.d.ts +3 -0
  3. package/dist/core/Builder.d.ts +16 -9
  4. package/dist/core/Builder.js +52 -4
  5. package/dist/core/Column.d.ts +38 -25
  6. package/dist/core/Column.js +56 -27
  7. package/dist/core/Constraint.d.ts +2 -1
  8. package/dist/core/Constraint.js +2 -1
  9. package/dist/core/Database.d.ts +5 -4
  10. package/dist/core/Database.js +14 -13
  11. package/dist/core/Emitter.d.ts +2 -2
  12. package/dist/core/Index.d.ts +1 -1
  13. package/dist/core/Internal.d.ts +19 -2
  14. package/dist/core/Internal.js +29 -11
  15. package/dist/core/Param.js +2 -0
  16. package/dist/core/Queries.d.ts +1 -0
  17. package/dist/core/Queries.js +11 -1
  18. package/dist/core/Resolver.js +2 -2
  19. package/dist/core/Schema.d.ts +1 -3
  20. package/dist/core/Selection.d.ts +9 -4
  21. package/dist/core/Selection.js +94 -5
  22. package/dist/core/Sql.d.ts +4 -3
  23. package/dist/core/Sql.js +8 -2
  24. package/dist/core/Table.d.ts +18 -11
  25. package/dist/core/Table.js +45 -25
  26. package/dist/core/View.d.ts +34 -0
  27. package/dist/core/View.js +153 -0
  28. package/dist/core/Virtual.d.ts +7 -2
  29. package/dist/core/Virtual.js +14 -10
  30. package/dist/core/expr/Conditions.d.ts +7 -7
  31. package/dist/core/expr/Include.d.ts +2 -2
  32. package/dist/core/expr/Include.js +1 -1
  33. package/dist/core/expr/Input.d.ts +1 -1
  34. package/dist/core/expr/Input.js +5 -1
  35. package/dist/core/query/CTE.d.ts +3 -5
  36. package/dist/core/query/CTE.js +1 -13
  37. package/dist/core/query/Delete.d.ts +10 -10
  38. package/dist/core/query/Delete.js +2 -2
  39. package/dist/core/query/Insert.d.ts +6 -5
  40. package/dist/core/query/Insert.js +22 -9
  41. package/dist/core/query/Query.d.ts +26 -11
  42. package/dist/core/query/Select.d.ts +41 -8
  43. package/dist/core/query/Select.js +235 -25
  44. package/dist/core/query/Shared.d.ts +2 -1
  45. package/dist/core/query/Shared.js +8 -5
  46. package/dist/core/query/Update.d.ts +9 -9
  47. package/dist/core/query/Update.js +24 -12
  48. package/dist/driver/better-sqlite3.js +4 -0
  49. package/dist/driver/bun-sqlite.js +3 -0
  50. package/dist/driver/d1.js +3 -0
  51. package/dist/driver/libsql.js +4 -0
  52. package/dist/driver/mysql2.js +5 -0
  53. package/dist/driver/pg.d.ts +17 -1
  54. package/dist/driver/pg.js +10 -1
  55. package/dist/driver/pglite.js +21 -6
  56. package/dist/driver/sql.js.js +4 -0
  57. package/dist/index.d.ts +1 -0
  58. package/dist/index.js +1 -0
  59. package/dist/mysql/columns.d.ts +30 -30
  60. package/dist/mysql/columns.js +25 -24
  61. package/dist/mysql/dialect.js +6 -2
  62. package/dist/mysql/diff.js +1 -1
  63. package/dist/mysql.d.ts +1 -0
  64. package/dist/mysql.js +2 -0
  65. package/dist/postgres/columns.d.ts +103 -33
  66. package/dist/postgres/columns.js +317 -35
  67. package/dist/postgres/diff.js +3 -3
  68. package/dist/postgres/enum.d.ts +17 -0
  69. package/dist/postgres/enum.js +64 -0
  70. package/dist/postgres/schema.d.ts +19 -0
  71. package/dist/postgres/schema.js +47 -0
  72. package/dist/postgres.d.ts +3 -1
  73. package/dist/postgres.js +9 -2
  74. package/dist/sqlite/columns.d.ts +29 -14
  75. package/dist/sqlite/columns.js +41 -9
  76. package/dist/sqlite/dialect.js +3 -1
  77. package/dist/sqlite/diff.js +1 -1
  78. package/dist/sqlite/functions.d.ts +1 -1
  79. package/dist/sqlite/functions.js +1 -1
  80. package/dist/sqlite.d.ts +1 -0
  81. package/dist/sqlite.js +3 -6
  82. package/dist/universal/columns.d.ts +8 -8
  83. package/dist/universal/columns.js +43 -26
  84. package/dist/universal/functions.d.ts +1 -1
  85. package/dist/universal/functions.js +1 -1
  86. package/package.json +54 -37
package/dist/driver/pg.js CHANGED
@@ -9,6 +9,9 @@ var PreparedStatement = class {
9
9
  this.sql = sql;
10
10
  this.name = name;
11
11
  }
12
+ client;
13
+ sql;
14
+ name;
12
15
  all(params) {
13
16
  return this.client.query({
14
17
  name: this.name,
@@ -45,6 +48,8 @@ var PgDriver = class _PgDriver {
45
48
  this.client = client;
46
49
  this.depth = depth;
47
50
  }
51
+ client;
52
+ depth;
48
53
  parsesJson = true;
49
54
  supportsTransactions = true;
50
55
  async exec(query) {
@@ -86,7 +91,11 @@ var PgDriver = class _PgDriver {
86
91
  }
87
92
  };
88
93
  function connect(client) {
89
- return new AsyncDatabase(new PgDriver(client), postgresDialect, postgresDiff);
94
+ return new AsyncDatabase(
95
+ new PgDriver(client),
96
+ postgresDialect,
97
+ postgresDiff
98
+ );
90
99
  }
91
100
  export {
92
101
  PgDriver,
@@ -3,19 +3,33 @@ import { AsyncDatabase } from "../core/Database.js";
3
3
  import { postgresDialect } from "../postgres/dialect.js";
4
4
  import { postgresDiff } from "../postgres/diff.js";
5
5
  import { setTransaction } from "../postgres/transactions.js";
6
+ var RAW_DATE_TIME_PARSERS = {
7
+ 20: (value) => value,
8
+ // int8 / bigint (e.g. count(*))
9
+ 1082: (value) => value,
10
+ // date
11
+ 1114: (value) => value,
12
+ // timestamp
13
+ 1184: (value) => value
14
+ // timestamptz
15
+ };
6
16
  var PreparedStatement = class {
7
17
  constructor(client, sql) {
8
18
  this.client = client;
9
19
  this.sql = sql;
10
20
  }
21
+ client;
22
+ sql;
11
23
  all(params) {
12
24
  return this.client.query(this.sql, params, {
13
- rowMode: "object"
25
+ rowMode: "object",
26
+ parsers: RAW_DATE_TIME_PARSERS
14
27
  }).then((res) => res.rows);
15
28
  }
16
29
  async run(params) {
17
30
  await this.client.query(this.sql, params, {
18
- rowMode: "array"
31
+ rowMode: "array",
32
+ parsers: RAW_DATE_TIME_PARSERS
19
33
  });
20
34
  }
21
35
  get(params) {
@@ -23,7 +37,8 @@ var PreparedStatement = class {
23
37
  }
24
38
  values(params) {
25
39
  return this.client.query(this.sql, params, {
26
- rowMode: "array"
40
+ rowMode: "array",
41
+ parsers: RAW_DATE_TIME_PARSERS
27
42
  }).then((res) => res.rows);
28
43
  }
29
44
  free() {
@@ -34,15 +49,15 @@ var PGliteDriver = class _PGliteDriver {
34
49
  this.client = client;
35
50
  this.depth = depth;
36
51
  }
52
+ client;
53
+ depth;
37
54
  parsesJson = true;
38
55
  supportsTransactions = true;
39
56
  async exec(query) {
40
57
  await this.client.exec(query);
41
58
  }
42
59
  close() {
43
- if ("close" in this.client) {
44
- return Promise.resolve();
45
- }
60
+ if ("close" in this.client) return this.client.close();
46
61
  throw new Error("Cannot close a transaction");
47
62
  }
48
63
  prepare(sql) {
@@ -8,6 +8,8 @@ var PreparedStatement = class {
8
8
  this.client = client;
9
9
  this.stmt = stmt;
10
10
  }
11
+ client;
12
+ stmt;
11
13
  *iterate(params) {
12
14
  this.stmt.bind(params);
13
15
  while (this.stmt.step()) yield this.stmt.getAsObject();
@@ -41,6 +43,8 @@ var SqlJsDriver = class _SqlJsDriver {
41
43
  this.client = client;
42
44
  this.depth = depth;
43
45
  }
46
+ client;
47
+ depth;
44
48
  parsesJson = false;
45
49
  supportsTransactions = true;
46
50
  exec(query) {
package/dist/index.d.ts CHANGED
@@ -18,3 +18,4 @@ export * from './core/query/Update.js';
18
18
  export * from './core/Selection.js';
19
19
  export * from './core/Sql.js';
20
20
  export * from './core/Table.js';
21
+ export * from './core/View.js';
package/dist/index.js CHANGED
@@ -19,3 +19,4 @@ export * from "./core/query/Update.js";
19
19
  export * from "./core/Selection.js";
20
20
  export * from "./core/Sql.js";
21
21
  export * from "./core/Table.js";
22
+ export * from "./core/View.js";
@@ -1,71 +1,71 @@
1
- import { type Column, type ColumnArguments, JsonColumn } from '../core/Column.js';
1
+ import { Column, type ColumnArguments, JsonColumn } from '../core/Column.js';
2
2
  type Precision = 0 | 1 | 2 | 3 | 4 | 5 | 6;
3
3
  export declare function bigint(...args: ColumnArguments<{
4
4
  mode: 'number';
5
5
  unsigned?: boolean;
6
- }>): Column<number | null>;
6
+ }>): Column<number>;
7
7
  export declare function bigint(...args: ColumnArguments<{
8
8
  unsigned?: boolean;
9
- }>): Column<bigint | null>;
9
+ }>): Column<bigint>;
10
10
  export declare function binary(...args: ColumnArguments<{
11
11
  length?: number;
12
- }>): Column<Uint8Array | null>;
13
- export declare function boolean(name?: string): Column<boolean | null>;
14
- export declare function blob(name?: string): Column<Uint8Array | null>;
12
+ }>): Column<Uint8Array>;
13
+ export declare function boolean(name?: string): Column<boolean>;
14
+ export declare function blob(name?: string): Column<Uint8Array>;
15
15
  export declare function char(...args: ColumnArguments<{
16
16
  length?: number;
17
- }>): Column<string | null>;
17
+ }>): Column<string>;
18
18
  export declare function date(...args: ColumnArguments<{
19
19
  mode: 'string';
20
- }>): Column<string | null>;
20
+ }>): Column<string>;
21
21
  export declare function date(...args: ColumnArguments<{
22
22
  mode: 'date';
23
- }>): Column<Date | null>;
23
+ }>): Column<Date>;
24
24
  export declare function datetime(...args: ColumnArguments<{
25
25
  fsp?: Precision;
26
- }>): Column<Date | null>;
26
+ }>): Column<Date>;
27
27
  export declare function datetime(...args: ColumnArguments<{
28
28
  mode: 'string';
29
29
  fsp?: Precision;
30
- }>): Column<string | null>;
30
+ }>): Column<string>;
31
31
  export declare function decimal(...args: ColumnArguments<{
32
32
  precision?: number;
33
33
  scale?: number;
34
- }>): Column<number | null>;
35
- export declare function float(name?: string): Column<number | null>;
36
- export declare function integer(name?: string): Column<number | null>;
34
+ }>): Column<number>;
35
+ export declare function float(name?: string): Column<number>;
36
+ export declare function integer(name?: string): Column<number>;
37
37
  export declare const int: typeof integer;
38
- export declare function json<T>(name?: string): JsonColumn<T | null>;
38
+ export declare function json<T>(name?: string): JsonColumn<T>;
39
39
  export declare function mediumint(...args: ColumnArguments<{
40
40
  unsigned?: boolean;
41
- }>): Column<number | null>;
42
- export declare function real(name?: string): Column<number | null>;
43
- export declare function serial(name?: string): Column<number | null>;
41
+ }>): Column<number>;
42
+ export declare function real(name?: string): Column<number>;
43
+ export declare function serial(name?: string): Column<number>;
44
44
  export declare function smallint(...args: ColumnArguments<{
45
45
  unsigned?: boolean;
46
- }>): Column<number | null>;
47
- export declare function text(name?: string): Column<string | null>;
48
- export declare function tinytext(name?: string): Column<string | null>;
49
- export declare function mediumtext(name?: string): Column<string | null>;
50
- export declare function longtext(name?: string): Column<string | null>;
46
+ }>): Column<number>;
47
+ export declare function text(name?: string): Column<string>;
48
+ export declare function tinytext(name?: string): Column<string>;
49
+ export declare function mediumtext(name?: string): Column<string>;
50
+ export declare function longtext(name?: string): Column<string>;
51
51
  export declare function time(...args: ColumnArguments<{
52
52
  fsp?: Precision;
53
- }>): Column<string | null>;
53
+ }>): Column<string>;
54
54
  export declare function timestamp(...args: ColumnArguments<{
55
55
  fsp?: Precision;
56
- }>): Column<Date | null>;
56
+ }>): Column<Date>;
57
57
  export declare function timestamp(...args: ColumnArguments<{
58
58
  mode: 'string';
59
59
  fsp?: Precision;
60
- }>): Column<string | null>;
60
+ }>): Column<string>;
61
61
  export declare function tinyint(...args: ColumnArguments<{
62
62
  unsigned?: boolean;
63
- }>): Column<number | null>;
63
+ }>): Column<number>;
64
64
  export declare function varbinary(...args: ColumnArguments<{
65
65
  length?: number;
66
- }>): Column<Uint8Array | null>;
66
+ }>): Column<Uint8Array>;
67
67
  export declare function varchar(...args: ColumnArguments<{
68
68
  length?: number;
69
- }>): Column<string | null>;
70
- export declare function year(name?: string): Column<number | null>;
69
+ }>): Column<string>;
70
+ export declare function year(name?: string): Column<number>;
71
71
  export {};
@@ -1,12 +1,13 @@
1
1
  // src/mysql/columns.ts
2
2
  import {
3
+ Column,
3
4
  JsonColumn,
4
5
  column,
5
6
  columnConfig
6
7
  } from "../core/Column.js";
7
8
  function bigint(...args) {
8
9
  const { name, options } = columnConfig(args);
9
- return column({
10
+ return new Column({
10
11
  name,
11
12
  type: column[options?.unsigned ? "bigint unsigned" : "bigint"](),
12
13
  mapFromDriverValue: options?.mode === "number" ? Number : BigInt
@@ -14,21 +15,21 @@ function bigint(...args) {
14
15
  }
15
16
  function binary(...args) {
16
17
  const { name, options } = columnConfig(args);
17
- return column({ name, type: column.binary(options?.length) });
18
+ return new Column({ name, type: column.binary(options?.length) });
18
19
  }
19
20
  function boolean(name) {
20
- return column({ name, type: column.boolean() });
21
+ return new Column({ name, type: column.boolean() });
21
22
  }
22
23
  function blob(name) {
23
- return column({ name, type: column.blob() });
24
+ return new Column({ name, type: column.blob() });
24
25
  }
25
26
  function char(...args) {
26
27
  const { name, options } = columnConfig(args);
27
- return column({ name, type: column.char(options?.length) });
28
+ return new Column({ name, type: column.char(options?.length) });
28
29
  }
29
30
  function date(...args) {
30
31
  const { name, options } = columnConfig(args);
31
- return column({
32
+ return new Column({
32
33
  name,
33
34
  type: column.date(),
34
35
  mapFromDriverValue(value) {
@@ -41,7 +42,7 @@ function date(...args) {
41
42
  }
42
43
  function datetime(...args) {
43
44
  const { name, options } = columnConfig(args);
44
- return column({
45
+ return new Column({
45
46
  name,
46
47
  type: column.datetime(options?.fsp),
47
48
  mapFromDriverValue(value) {
@@ -54,16 +55,16 @@ function datetime(...args) {
54
55
  }
55
56
  function decimal(...args) {
56
57
  const { name, options } = columnConfig(args);
57
- return column({
58
+ return new Column({
58
59
  name,
59
60
  type: column.decimal(options?.precision, options?.scale)
60
61
  });
61
62
  }
62
63
  function float(name) {
63
- return column({ name, type: column.float() });
64
+ return new Column({ name, type: column.float() });
64
65
  }
65
66
  function integer(name) {
66
- return column({ name, type: column.integer() });
67
+ return new Column({ name, type: column.integer() });
67
68
  }
68
69
  var int = integer;
69
70
  function json(name) {
@@ -77,43 +78,43 @@ function json(name) {
77
78
  }
78
79
  function mediumint(...args) {
79
80
  const { name, options } = columnConfig(args);
80
- return column({
81
+ return new Column({
81
82
  name,
82
83
  type: column[options?.unsigned ? "mediumint unsigned" : "mediumint"]()
83
84
  });
84
85
  }
85
86
  function real(name) {
86
- return column({ name, type: column.real() });
87
+ return new Column({ name, type: column.real() });
87
88
  }
88
89
  function serial(name) {
89
- return column({ name, type: column.serial() });
90
+ return new Column({ name, type: column.serial() });
90
91
  }
91
92
  function smallint(...args) {
92
93
  const { name, options } = columnConfig(args);
93
- return column({
94
+ return new Column({
94
95
  name,
95
96
  type: column[options?.unsigned ? "smallint unsigned" : "smallint"]()
96
97
  });
97
98
  }
98
99
  function text(name) {
99
- return column({ name, type: column.text() });
100
+ return new Column({ name, type: column.text() });
100
101
  }
101
102
  function tinytext(name) {
102
- return column({ name, type: column.tinytext() });
103
+ return new Column({ name, type: column.tinytext() });
103
104
  }
104
105
  function mediumtext(name) {
105
- return column({ name, type: column.mediumtext() });
106
+ return new Column({ name, type: column.mediumtext() });
106
107
  }
107
108
  function longtext(name) {
108
- return column({ name, type: column.longtext() });
109
+ return new Column({ name, type: column.longtext() });
109
110
  }
110
111
  function time(...args) {
111
112
  const { name, options } = columnConfig(args);
112
- return column({ name, type: column.time(options?.fsp) });
113
+ return new Column({ name, type: column.time(options?.fsp) });
113
114
  }
114
115
  function timestamp(...args) {
115
116
  const { name, options } = columnConfig(args);
116
- return column({
117
+ return new Column({
117
118
  name,
118
119
  type: column.timestamp(options?.fsp),
119
120
  mapFromDriverValue(value) {
@@ -126,21 +127,21 @@ function timestamp(...args) {
126
127
  }
127
128
  function tinyint(...args) {
128
129
  const { name, options } = columnConfig(args);
129
- return column({
130
+ return new Column({
130
131
  name,
131
132
  type: column[options?.unsigned ? "tinyint unsigned" : "tinyint"]()
132
133
  });
133
134
  }
134
135
  function varbinary(...args) {
135
136
  const { name, options } = columnConfig(args);
136
- return column({ name, type: column.varbinary(options?.length) });
137
+ return new Column({ name, type: column.varbinary(options?.length) });
137
138
  }
138
139
  function varchar(...args) {
139
140
  const { name, options } = columnConfig(args);
140
- return column({ name, type: column.varchar(options?.length) });
141
+ return new Column({ name, type: column.varchar(options?.length) });
141
142
  }
142
143
  function year(name) {
143
- return column({ name, type: column.year() });
144
+ return new Column({ name, type: column.year() });
144
145
  }
145
146
  export {
146
147
  bigint,
@@ -5,6 +5,8 @@ import { NamedParam, ValueParam } from "../core/Param.js";
5
5
  var BACKTICK = "`";
6
6
  var ESCAPE_BACKTICK = "``";
7
7
  var MATCH_BACKTICK = /`/g;
8
+ var ESCAPE_BACKSLASH = "\\\\";
9
+ var MATCH_BACKSLASH = /\\/g;
8
10
  var SINGLE_QUOTE = "'";
9
11
  var ESCAPE_SINGLE_QUOTE = "''";
10
12
  var MATCH_SINGLE_QUOTE = /'/g;
@@ -24,7 +26,9 @@ var mysqlDialect = new Dialect(
24
26
  target.emit(this);
25
27
  this.sql += asSql ? "->>" : "->";
26
28
  this.sql += this.quoteString(
27
- `$${segments.map((p) => typeof p === "number" ? `[${p}]` : `.${p}`).join("")}`
29
+ `$${segments.map(
30
+ (p) => typeof p === "number" ? `[${p}]` : `.${JSON.stringify(p)}`
31
+ ).join("")}`
28
32
  );
29
33
  }
30
34
  emitInline(value) {
@@ -36,7 +40,7 @@ var mysqlDialect = new Dialect(
36
40
  this.sql += this.quoteString(JSON.stringify(value));
37
41
  }
38
42
  quoteString(input) {
39
- return SINGLE_QUOTE + input.replace(MATCH_SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE) + SINGLE_QUOTE;
43
+ return SINGLE_QUOTE + input.replace(MATCH_BACKSLASH, ESCAPE_BACKSLASH).replace(MATCH_SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE) + SINGLE_QUOTE;
40
44
  }
41
45
  emitIdentifier(identifier) {
42
46
  this.sql += BACKTICK + identifier.replace(MATCH_BACKTICK, ESCAPE_BACKTICK) + BACKTICK;
@@ -1,9 +1,9 @@
1
1
  // src/mysql/diff.ts
2
2
  import { formatColumn } from "../core/Column.js";
3
+ import { eq } from "../core/expr/Conditions.js";
3
4
  import { getData, getTable } from "../core/Internal.js";
4
5
  import { schema } from "../core/Schema.js";
5
6
  import { sql } from "../core/Sql.js";
6
- import { eq } from "../core/expr/Conditions.js";
7
7
  import { txGenerator } from "../universal.js";
8
8
  import * as column from "./columns.js";
9
9
  import { mysqlDialect } from "./dialect.js";
package/dist/mysql.d.ts CHANGED
@@ -3,6 +3,7 @@ export { index, uniqueIndex } from './core/Index.js';
3
3
  export { except, exceptAll, intersect, intersectAll, union, unionAll } from './core/query/Select.js';
4
4
  export { schema as mysqlSchema } from './core/Schema.js';
5
5
  export { alias, table as mysqlTable, tableCreator as mysqlTableCreator } from './core/Table.js';
6
+ export { view as mysqlView } from './core/View.js';
6
7
  export * from './mysql/builder.js';
7
8
  export * from './mysql/columns.js';
8
9
  export * from './mysql/dialect.js';
package/dist/mysql.js CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  table,
16
16
  tableCreator
17
17
  } from "./core/Table.js";
18
+ import { view } from "./core/View.js";
18
19
  export * from "./mysql/builder.js";
19
20
  export * from "./mysql/columns.js";
20
21
  export * from "./mysql/dialect.js";
@@ -29,6 +30,7 @@ export {
29
30
  schema as mysqlSchema,
30
31
  table as mysqlTable,
31
32
  tableCreator as mysqlTableCreator,
33
+ view as mysqlView,
32
34
  primaryKey,
33
35
  union,
34
36
  unionAll,
@@ -1,63 +1,133 @@
1
- import { type Column, type ColumnArguments, JsonColumn } from '../core/Column.js';
1
+ import { Column, type ColumnArguments, type Nullability } from '../core/Column.js';
2
2
  type Precision = 0 | 1 | 2 | 3 | 4 | 5 | 6;
3
3
  type IntervalFields = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'year to month' | 'day to hour' | 'day to minute' | 'day to second' | 'hour to minute' | 'hour to second' | 'minute to second';
4
- export declare function bigint(name: string | undefined, options: {
4
+ type PointTuple = [number, number];
5
+ type PointXY = {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ type LineTuple = [number, number, number];
10
+ type LineABC = {
11
+ a: number;
12
+ b: number;
13
+ c: number;
14
+ };
15
+ type GeometryBaseType = 'geometry' | 'point' | 'line' | 'linestring' | 'polygon' | 'multipoint' | 'multilinestring' | 'multipolygon' | 'geometrycollection' | 'circularstring' | 'compoundcurve' | 'curvepolygon' | 'multicurve' | 'multisurface' | 'polyhedralsurface' | 'triangle' | 'tin';
16
+ type GeometryType = `${GeometryBaseType}${'' | 'z' | 'm' | 'zm'}`;
17
+ export declare class PgColumn<Value = unknown, Nulls extends Nullability = Nullability> extends Column<Value, Nulls> {
18
+ notNull(): PgColumn<Value, [false, Nulls[1]]>;
19
+ unique(name?: string, config?: {
20
+ nulls: 'distinct' | 'not distinct';
21
+ }): PgColumn<Value, Nulls>;
22
+ array(size?: number): PgColumn<Array<Value>, Nulls>;
23
+ generatedAlwaysAsIdentity(): PgColumn<Value, Nulls>;
24
+ generatedByDefaultAsIdentity(): PgColumn<Value, Nulls>;
25
+ }
26
+ export declare function bigint(...args: ColumnArguments<{
5
27
  mode: 'number';
6
- }): Column<number | null>;
7
- export declare function bigint(name?: string): Column<bigint | null>;
8
- export declare function bigserial(name: string | undefined, options: {
28
+ }>): PgColumn<number>;
29
+ export declare function bigint(...args: ColumnArguments<{
30
+ mode?: 'bigint';
31
+ }>): PgColumn<bigint>;
32
+ export declare function bigserial(...args: ColumnArguments<{
9
33
  mode: 'number';
10
- }): Column<number | null>;
11
- export declare function bigserial(name?: string): Column<bigint | null>;
34
+ }>): PgColumn<number>;
35
+ export declare function bigserial(...args: ColumnArguments<{
36
+ mode?: 'bigint';
37
+ }>): PgColumn<bigint>;
12
38
  export declare function char(name?: string, options?: {
13
39
  length: number;
14
- }): Column<string | null>;
15
- export declare function cidr(name?: string): Column<string | null>;
40
+ }): PgColumn<string>;
41
+ export declare function bit(...args: ColumnArguments<{
42
+ dimensions?: number;
43
+ }>): PgColumn<string>;
44
+ export declare function varbit(...args: ColumnArguments<{
45
+ dimensions?: number;
46
+ }>): PgColumn<string>;
47
+ export declare function cidr(name?: string): PgColumn<string>;
16
48
  export declare function date(name?: string, options?: {
17
49
  mode: 'string';
18
- }): Column<string | null>;
50
+ }): PgColumn<string>;
19
51
  export declare function date(name: string | undefined, options: {
20
52
  mode: 'date';
21
- }): Column<Date | null>;
22
- export declare function doublePrecision(name?: string): Column<number | null>;
23
- export declare function inet(name?: string): Column<string | null>;
24
- export declare function integer(name?: string): Column<number | null>;
53
+ }): PgColumn<Date>;
54
+ export declare function doublePrecision(name?: string): PgColumn<number>;
55
+ export declare function inet(name?: string): PgColumn<string>;
56
+ export declare function integer(name?: string): PgColumn<number>;
25
57
  export declare const int: typeof integer;
26
- export declare function oid(name?: string): Column<number | null>;
58
+ export declare function oid(name?: string): PgColumn<number>;
59
+ export declare function point(...args: ColumnArguments<{
60
+ mode?: 'tuple';
61
+ }>): PgColumn<PointTuple>;
62
+ export declare function point(...args: ColumnArguments<{
63
+ mode: 'xy';
64
+ }>): PgColumn<PointXY>;
65
+ export declare function line(...args: ColumnArguments<{
66
+ mode?: 'tuple';
67
+ }>): PgColumn<LineTuple>;
68
+ export declare function line(...args: ColumnArguments<{
69
+ mode: 'abc';
70
+ }>): PgColumn<LineABC>;
27
71
  export declare function interval(...args: ColumnArguments<{
28
72
  fields?: IntervalFields;
29
73
  precision?: Precision;
30
- }>): Column<string | null>;
31
- export declare function serial(name?: string): Column<number>;
32
- export declare function boolean(name?: string): Column<boolean | null>;
33
- export declare function bytea(name?: string): Column<Uint8Array | null>;
34
- export declare function text(name?: string): Column<string | null>;
35
- export declare function json<T>(name?: string): JsonColumn<T | null>;
36
- export declare function jsonb<T>(name?: string): JsonColumn<T | null>;
37
- export declare function macaddr(name?: string): Column<string | null>;
38
- export declare function macaddr8(name?: string): Column<string | null>;
74
+ }>): PgColumn<string>;
75
+ export declare function serial(name?: string): PgColumn<number>;
76
+ export declare function boolean(name?: string): PgColumn<boolean>;
77
+ export declare function bytea(name?: string): PgColumn<Uint8Array>;
78
+ export declare function text(name?: string): PgColumn<string>;
79
+ export declare function json<T>(name?: string): PgColumn<T>;
80
+ export declare function jsonb<T>(name?: string): PgColumn<T>;
81
+ export declare function geometry(...args: ColumnArguments<{
82
+ type?: GeometryType;
83
+ mode?: 'tuple' | 'xy';
84
+ }>): PgColumn<PointTuple | PointXY | string>;
85
+ export declare function vector(...args: ColumnArguments<{
86
+ dimensions: number;
87
+ }>): PgColumn<string>;
88
+ export declare function halfvec(...args: ColumnArguments<{
89
+ dimensions: number;
90
+ }>): PgColumn<string>;
91
+ export declare function sparsevec(...args: ColumnArguments<{
92
+ dimensions: number;
93
+ }>): PgColumn<string>;
94
+ export declare function macaddr(name?: string): PgColumn<string>;
95
+ export declare function macaddr8(name?: string): PgColumn<string>;
39
96
  export declare function numeric(...args: ColumnArguments<{
40
97
  precision?: number;
41
98
  scale?: number;
42
- }>): Column<number | null>;
43
- export declare function real(name?: string): Column<number | null>;
44
- export declare function smallint(name?: string): Column<number | null>;
45
- export declare function smallserial(name?: string): Column<number | null>;
99
+ }>): PgColumn<string>;
100
+ export declare function numeric(...args: ColumnArguments<{
101
+ precision?: number;
102
+ scale?: number;
103
+ mode: 'number';
104
+ }>): PgColumn<number>;
105
+ export declare function numeric(...args: ColumnArguments<{
106
+ precision?: number;
107
+ scale?: number;
108
+ mode: 'bigint';
109
+ }>): PgColumn<bigint>;
110
+ export declare function real(name?: string): PgColumn<number>;
111
+ export declare function smallint(name?: string): PgColumn<number>;
112
+ export declare function smallserial(name?: string): PgColumn<number>;
46
113
  export declare function time(...args: ColumnArguments<{
47
114
  precision?: Precision;
48
115
  withTimeZone?: boolean;
49
- }>): Column<string | null>;
116
+ }>): PgColumn<string>;
50
117
  export declare function timestamp(...args: ColumnArguments<{
118
+ mode?: 'date';
51
119
  precision?: Precision;
52
120
  withTimeZone?: boolean;
53
- }>): Column<Date | null>;
121
+ withTimezone?: boolean;
122
+ }>): PgColumn<Date>;
54
123
  export declare function timestamp(...args: ColumnArguments<{
55
124
  mode: 'string';
56
125
  precision?: Precision;
57
126
  withTimeZone?: boolean;
58
- }>): Column<string | null>;
59
- export declare function uuid(name?: string): Column<string | null>;
127
+ withTimezone?: boolean;
128
+ }>): PgColumn<string>;
129
+ export declare function uuid(name?: string): PgColumn<string>;
60
130
  export declare function varchar(...args: ColumnArguments<{
61
131
  length: number;
62
- }>): Column<string | null>;
132
+ }>): PgColumn<string>;
63
133
  export {};