@prisma-next/sql-relational-core 0.3.0-pr.95.1 → 0.3.0-pr.98.1

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 (41) hide show
  1. package/dist/ast/predicate.d.ts +2 -2
  2. package/dist/ast/predicate.d.ts.map +1 -1
  3. package/dist/ast/types.d.ts +9 -21
  4. package/dist/ast/types.d.ts.map +1 -1
  5. package/dist/{chunk-2MAKNVCP.js → chunk-5N34PNVZ.js} +1 -25
  6. package/dist/chunk-5N34PNVZ.js.map +1 -0
  7. package/dist/{chunk-2BWK6XEY.js → chunk-D4JLPIWO.js} +1 -1
  8. package/dist/chunk-D4JLPIWO.js.map +1 -0
  9. package/dist/{chunk-HV334QHG.js → chunk-J6O2HVBM.js} +2 -2
  10. package/dist/{chunk-HV334QHG.js.map → chunk-J6O2HVBM.js.map} +1 -1
  11. package/dist/{chunk-3F4RFQIB.js → chunk-M23L3JHG.js} +35 -45
  12. package/dist/chunk-M23L3JHG.js.map +1 -0
  13. package/dist/{chunk-L2FZU4IV.js → chunk-U7IAFPVU.js} +11 -29
  14. package/dist/chunk-U7IAFPVU.js.map +1 -0
  15. package/dist/exports/ast.js +2 -2
  16. package/dist/exports/guards.d.ts +1 -1
  17. package/dist/exports/guards.d.ts.map +1 -1
  18. package/dist/exports/guards.js +3 -13
  19. package/dist/exports/operations-registry.js +2 -2
  20. package/dist/exports/schema.js +4 -3
  21. package/dist/exports/types.js +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/operations-registry.d.ts.map +1 -1
  24. package/dist/schema.d.ts +9 -14
  25. package/dist/schema.d.ts.map +1 -1
  26. package/dist/types.d.ts +30 -69
  27. package/dist/types.d.ts.map +1 -1
  28. package/dist/utils/guards.d.ts +16 -43
  29. package/dist/utils/guards.d.ts.map +1 -1
  30. package/package.json +7 -7
  31. package/src/ast/predicate.ts +11 -3
  32. package/src/ast/types.ts +9 -23
  33. package/src/exports/guards.ts +0 -5
  34. package/src/operations-registry.ts +73 -112
  35. package/src/schema.ts +29 -40
  36. package/src/types.ts +52 -102
  37. package/src/utils/guards.ts +18 -88
  38. package/dist/chunk-2BWK6XEY.js.map +0 -1
  39. package/dist/chunk-2MAKNVCP.js.map +0 -1
  40. package/dist/chunk-3F4RFQIB.js.map +0 -1
  41. package/dist/chunk-L2FZU4IV.js.map +0 -1
@@ -1,9 +1,17 @@
1
- import type { BinaryExpr, BinaryOp, ExistsExpr, Expression, ParamRef, SelectAst } from './types';
1
+ import type {
2
+ BinaryExpr,
3
+ BinaryOp,
4
+ ColumnRef,
5
+ ExistsExpr,
6
+ OperationExpr,
7
+ ParamRef,
8
+ SelectAst,
9
+ } from './types';
2
10
 
3
11
  export function createBinaryExpr(
4
12
  op: BinaryOp,
5
- left: Expression,
6
- right: Expression | ParamRef,
13
+ left: ColumnRef | OperationExpr,
14
+ right: ColumnRef | ParamRef,
7
15
  ): BinaryExpr {
8
16
  return {
9
17
  kind: 'bin',
package/src/ast/types.ts CHANGED
@@ -32,27 +32,13 @@ export interface OperationExpr {
32
32
  readonly kind: 'operation';
33
33
  readonly method: string;
34
34
  readonly forTypeId: string;
35
- readonly self: Expression;
36
- readonly args: ReadonlyArray<Expression | ParamRef | LiteralExpr>;
35
+ readonly self: ColumnRef | OperationExpr;
36
+ readonly args: ReadonlyArray<ColumnRef | ParamRef | LiteralExpr | OperationExpr>;
37
37
  readonly returns: ReturnSpec;
38
38
  readonly lowering: SqlLoweringSpec;
39
39
  }
40
40
 
41
- /**
42
- * Unified expression type - the canonical AST representation for column references
43
- * and operation expressions. This is what all builders convert to via toExpr().
44
- */
45
- export type Expression = ColumnRef | OperationExpr;
46
-
47
- /**
48
- * Interface for any builder that can produce an Expression.
49
- * Implemented by ColumnBuilder and ExpressionBuilder.
50
- */
51
- export interface ExpressionSource {
52
- toExpr(): Expression;
53
- }
54
-
55
- export function isOperationExpr(expr: Expression): expr is OperationExpr {
41
+ export function isOperationExpr(expr: ColumnRef | OperationExpr): expr is OperationExpr {
56
42
  return expr.kind === 'operation';
57
43
  }
58
44
 
@@ -61,8 +47,8 @@ export type BinaryOp = 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte';
61
47
  export interface BinaryExpr {
62
48
  readonly kind: 'bin';
63
49
  readonly op: BinaryOp;
64
- readonly left: Expression;
65
- readonly right: Expression | ParamRef;
50
+ readonly left: ColumnRef | OperationExpr;
51
+ readonly right: ColumnRef | ParamRef;
66
52
  }
67
53
 
68
54
  export interface ExistsExpr {
@@ -96,9 +82,9 @@ export interface IncludeAst {
96
82
  readonly table: TableRef;
97
83
  readonly on: JoinOnExpr;
98
84
  readonly where?: BinaryExpr | ExistsExpr;
99
- readonly orderBy?: ReadonlyArray<{ expr: Expression; dir: Direction }>;
85
+ readonly orderBy?: ReadonlyArray<{ expr: ColumnRef | OperationExpr; dir: Direction }>;
100
86
  readonly limit?: number;
101
- readonly project: ReadonlyArray<{ alias: string; expr: Expression }>;
87
+ readonly project: ReadonlyArray<{ alias: string; expr: ColumnRef | OperationExpr }>;
102
88
  };
103
89
  }
104
90
 
@@ -109,10 +95,10 @@ export interface SelectAst {
109
95
  readonly includes?: ReadonlyArray<IncludeAst>;
110
96
  readonly project: ReadonlyArray<{
111
97
  alias: string;
112
- expr: Expression | IncludeRef | LiteralExpr;
98
+ expr: ColumnRef | IncludeRef | OperationExpr | LiteralExpr;
113
99
  }>;
114
100
  readonly where?: BinaryExpr | ExistsExpr;
115
- readonly orderBy?: ReadonlyArray<{ expr: Expression; dir: Direction }>;
101
+ readonly orderBy?: ReadonlyArray<{ expr: ColumnRef | OperationExpr; dir: Direction }>;
116
102
  readonly limit?: number;
117
103
  }
118
104
 
@@ -1,15 +1,10 @@
1
1
  export {
2
2
  collectColumnRefs,
3
- expressionFromSource,
4
3
  extractBaseColumnRef,
5
4
  getColumnInfo,
6
5
  getColumnMeta,
7
6
  getOperationExpr,
8
7
  isColumnBuilder,
9
- isExpressionBuilder,
10
- isExpressionSource,
11
8
  isOperationExpr,
12
9
  isParamPlaceholder,
13
- isValueSource,
14
- toExpression,
15
10
  } from '../utils/guards';
@@ -3,71 +3,59 @@ import { hasAllCapabilities } from '@prisma-next/operations';
3
3
  import { planInvalid } from '@prisma-next/plan';
4
4
  import type { StorageColumn } from '@prisma-next/sql-contract/types';
5
5
  import type { SqlOperationSignature } from '@prisma-next/sql-operations';
6
- import type {
7
- BinaryOp,
8
- Expression,
9
- ExpressionSource,
10
- LiteralExpr,
11
- OperationExpr,
12
- ParamRef,
13
- } from './ast/types';
14
- import type {
15
- AnyBinaryBuilder,
16
- AnyOrderBuilder,
17
- ColumnBuilder,
18
- ExpressionBuilder,
19
- OperationTypes,
20
- ParamPlaceholder,
21
- } from './types';
6
+ import type { BinaryOp, ColumnRef, LiteralExpr, OperationExpr, ParamRef } from './ast/types';
7
+ import type { AnyColumnBuilder, ColumnBuilder, OperationTypes, ParamPlaceholder } from './types';
22
8
  import { isParamPlaceholder } from './utils/guards';
23
9
 
24
- /**
25
- * Type guard to check if a value is an ExpressionSource (has toExpr method).
26
- */
27
- function isExpressionSource(value: unknown): value is ExpressionSource {
10
+ function isColumnBuilder(value: unknown): value is AnyColumnBuilder {
28
11
  return (
29
12
  typeof value === 'object' &&
30
13
  value !== null &&
31
- 'toExpr' in value &&
32
- typeof (value as ExpressionSource).toExpr === 'function'
14
+ 'kind' in value &&
15
+ (value as { kind: unknown }).kind === 'column'
33
16
  );
34
17
  }
35
18
 
36
19
  /**
37
- * Executes an operation and returns an ExpressionBuilder.
20
+ * Executes an operation and returns a column-shaped result object.
38
21
  * This is the canonical entrypoint for operation invocation, enabling
39
22
  * future enhancements like telemetry, caching, or tracing.
40
23
  *
41
- * The returned ExpressionBuilder:
42
- * - Has `kind: 'expression'` to distinguish it from ColumnBuilder
43
- * - Contains the operation expression in `expr`
44
- * - Provides `toExpr()` method to get the Expression
45
- * - Provides comparison and ordering methods for chaining
46
- *
47
24
  * @param signature - The operation signature from the registry
48
- * @param selfBuilder - The expression source that the operation is called on
25
+ * @param selfBuilder - The column builder that the operation is called on
49
26
  * @param args - The arguments passed to the operation
50
27
  * @param columnMeta - The metadata of the column the operation is called on
51
- * @returns An ExpressionBuilder containing the operation expression
28
+ * @returns A column-shaped builder with the operation expression attached
52
29
  */
53
30
  function executeOperation(
54
31
  signature: SqlOperationSignature,
55
- selfBuilder: ExpressionSource,
32
+ selfBuilder: AnyColumnBuilder,
56
33
  args: unknown[],
57
34
  columnMeta: StorageColumn,
58
35
  operationRegistry?: OperationRegistry,
59
36
  contractCapabilities?: Record<string, Record<string, boolean>>,
60
- ): ExpressionBuilder {
37
+ ): AnyColumnBuilder & { _operationExpr?: OperationExpr } {
61
38
  if (args.length !== signature.args.length) {
62
39
  throw planInvalid(
63
40
  `Operation ${signature.method} expects ${signature.args.length} arguments, got ${args.length}`,
64
41
  );
65
42
  }
66
43
 
67
- // Get the Expression from the self builder using toExpr()
68
- const selfExpr: Expression = selfBuilder.toExpr();
69
-
70
- const operationArgs: Array<Expression | ParamRef | LiteralExpr> = [];
44
+ // Check if this column builder has an existing operation expression
45
+ const selfBuilderWithExpr = selfBuilder as unknown as {
46
+ _operationExpr?: OperationExpr;
47
+ table: string;
48
+ column: string;
49
+ };
50
+ const selfExpr: ColumnRef | OperationExpr = selfBuilderWithExpr._operationExpr
51
+ ? selfBuilderWithExpr._operationExpr
52
+ : {
53
+ kind: 'col',
54
+ table: selfBuilderWithExpr.table,
55
+ column: selfBuilderWithExpr.column,
56
+ };
57
+
58
+ const operationArgs: Array<ColumnRef | ParamRef | LiteralExpr | OperationExpr> = [];
71
59
  for (let i = 0; i < args.length; i++) {
72
60
  const arg = args[i];
73
61
  const argSpec = signature.args[i];
@@ -85,14 +73,25 @@ function executeOperation(
85
73
  name: arg.name,
86
74
  });
87
75
  } else if (argSpec.kind === 'typeId') {
88
- // Accept ExpressionSource (ColumnBuilder or ExpressionBuilder)
89
- if (!isExpressionSource(arg)) {
90
- throw planInvalid(
91
- `Argument ${i} must be an ExpressionSource (ColumnBuilder or ExpressionBuilder)`,
92
- );
76
+ if (!isColumnBuilder(arg)) {
77
+ throw planInvalid(`Argument ${i} must be a ColumnBuilder`);
78
+ }
79
+ const colBuilderWithExpr = arg as unknown as {
80
+ _operationExpr?: OperationExpr;
81
+ table: string;
82
+ column: string;
83
+ };
84
+ // Check if the column builder has an operation expression
85
+ if (colBuilderWithExpr._operationExpr) {
86
+ operationArgs.push(colBuilderWithExpr._operationExpr);
87
+ } else {
88
+ // Fall back to raw ColumnRef
89
+ operationArgs.push({
90
+ kind: 'col',
91
+ table: colBuilderWithExpr.table,
92
+ column: colBuilderWithExpr.column,
93
+ });
93
94
  }
94
- // Use toExpr() to get the Expression
95
- operationArgs.push(arg.toExpr());
96
95
  } else if (argSpec.kind === 'literal') {
97
96
  operationArgs.push({
98
97
  kind: 'literal',
@@ -119,19 +118,18 @@ function executeOperation(
119
118
  }
120
119
  : columnMeta;
121
120
 
122
- const createComparisonMethod =
123
- (op: BinaryOp) =>
124
- (value: ParamPlaceholder | ExpressionSource): AnyBinaryBuilder =>
125
- Object.freeze({
126
- kind: 'binary' as const,
127
- op,
128
- left: operationExpr,
129
- right: value,
130
- }) as AnyBinaryBuilder;
131
-
132
- const baseResult: ExpressionBuilder = {
133
- kind: 'expression' as const,
134
- expr: operationExpr,
121
+ const createComparisonMethod = (op: BinaryOp) => (value: ParamPlaceholder) =>
122
+ Object.freeze({
123
+ kind: 'binary' as const,
124
+ op,
125
+ left: operationExpr,
126
+ right: value,
127
+ });
128
+
129
+ const baseResult = {
130
+ kind: 'column' as const,
131
+ table: selfBuilderWithExpr.table,
132
+ column: selfBuilderWithExpr.column,
135
133
  get columnMeta() {
136
134
  return returnColumnMeta;
137
135
  },
@@ -141,84 +139,41 @@ function executeOperation(
141
139
  lt: createComparisonMethod('lt'),
142
140
  gte: createComparisonMethod('gte'),
143
141
  lte: createComparisonMethod('lte'),
144
- asc(): AnyOrderBuilder {
142
+ asc() {
145
143
  return Object.freeze({
146
144
  kind: 'order' as const,
147
145
  expr: operationExpr,
148
146
  dir: 'asc' as const,
149
147
  });
150
148
  },
151
- desc(): AnyOrderBuilder {
149
+ desc() {
152
150
  return Object.freeze({
153
151
  kind: 'order' as const,
154
152
  expr: operationExpr,
155
153
  dir: 'desc' as const,
156
154
  });
157
155
  },
158
- toExpr(): OperationExpr {
159
- return operationExpr;
160
- },
161
- get __jsType(): unknown {
162
- return undefined;
163
- },
156
+ _operationExpr: operationExpr,
157
+ } as unknown as AnyColumnBuilder & {
158
+ _operationExpr?: OperationExpr;
164
159
  };
165
160
 
166
161
  // If the return type is a typeId, attach operations for that type
167
162
  if (returnTypeId && operationRegistry) {
168
- const resultWithOps = attachOperationsToExpressionBuilder(
169
- baseResult,
163
+ const resultWithOps = attachOperationsToColumnBuilder(
164
+ baseResult as ColumnBuilder<string, StorageColumn, unknown, Record<string, never>>,
170
165
  returnColumnMeta,
171
166
  operationRegistry,
172
167
  contractCapabilities,
173
- );
168
+ ) as AnyColumnBuilder & {
169
+ _operationExpr?: OperationExpr;
170
+ };
174
171
  return Object.freeze(resultWithOps);
175
172
  }
176
173
 
177
174
  return Object.freeze(baseResult);
178
175
  }
179
176
 
180
- /**
181
- * Attaches operation methods to an ExpressionBuilder for chained operations.
182
- * When an operation returns a typeId, the result ExpressionBuilder needs
183
- * operation methods for that type.
184
- */
185
- function attachOperationsToExpressionBuilder(
186
- expressionBuilder: ExpressionBuilder,
187
- columnMeta: StorageColumn,
188
- registry: OperationRegistry,
189
- contractCapabilities?: Record<string, Record<string, boolean>>,
190
- ): ExpressionBuilder {
191
- const codecId = columnMeta.codecId;
192
- if (!codecId) {
193
- return expressionBuilder;
194
- }
195
-
196
- const operations = registry.byType(codecId) as SqlOperationSignature[];
197
- if (operations.length === 0) {
198
- return expressionBuilder;
199
- }
200
-
201
- const builderWithOps = expressionBuilder as ExpressionBuilder & Record<string, unknown>;
202
-
203
- for (const operation of operations) {
204
- if (operation.capabilities && operation.capabilities.length > 0) {
205
- if (!contractCapabilities) {
206
- continue;
207
- }
208
-
209
- if (!hasAllCapabilities(operation.capabilities, contractCapabilities)) {
210
- continue;
211
- }
212
- }
213
- // Method sugar: attach operation as a method on the expression builder
214
- builderWithOps[operation.method] = function (this: ExpressionBuilder, ...args: unknown[]) {
215
- return executeOperation(operation, this, args, columnMeta, registry, contractCapabilities);
216
- };
217
- }
218
-
219
- return builderWithOps;
220
- }
221
-
222
177
  export function attachOperationsToColumnBuilder<
223
178
  ColumnName extends string,
224
179
  ColumnMeta extends StorageColumn,
@@ -263,12 +218,18 @@ export function attachOperationsToColumnBuilder<
263
218
  }
264
219
  }
265
220
  // Method sugar: attach operation as a method on the column builder
266
- // Operations return ExpressionBuilder, not ColumnBuilder
267
221
  (builderWithOps as Record<string, unknown>)[operation.method] = function (
268
222
  this: ColumnBuilder<ColumnName, ColumnMeta, JsType, Record<string, never>>,
269
223
  ...args: unknown[]
270
224
  ) {
271
- return executeOperation(operation, this, args, columnMeta, registry, contractCapabilities);
225
+ return executeOperation(
226
+ operation,
227
+ this as unknown as ColumnBuilder<string, StorageColumn, unknown>,
228
+ args,
229
+ columnMeta,
230
+ registry,
231
+ contractCapabilities,
232
+ );
272
233
  };
273
234
  }
274
235
 
package/src/schema.ts CHANGED
@@ -7,10 +7,11 @@ import type {
7
7
  SqlStorage,
8
8
  StorageColumn,
9
9
  } from '@prisma-next/sql-contract/types';
10
- import type { BinaryOp, ColumnRef, ExpressionSource, TableRef } from './ast/types';
10
+ import type { BinaryOp, TableRef } from './ast/types';
11
11
  import { attachOperationsToColumnBuilder } from './operations-registry';
12
12
  import type { QueryLaneContext } from './query-lane-context';
13
13
  import type {
14
+ AnyColumnBuilderBase,
14
15
  BinaryBuilder,
15
16
  CodecTypes as CodecTypesType,
16
17
  ColumnBuilder,
@@ -20,6 +21,7 @@ import type {
20
21
  OrderBuilder,
21
22
  ParamPlaceholder,
22
23
  } from './types';
24
+ import { isColumnBuilder } from './types';
23
25
 
24
26
  type TableColumns<Table extends { columns: Record<string, StorageColumn> }> = Table['columns'];
25
27
 
@@ -42,8 +44,7 @@ export class ColumnBuilderImpl<
42
44
  ColumnName extends string,
43
45
  ColumnMeta extends StorageColumn,
44
46
  JsType = unknown,
45
- > implements ExpressionSource
46
- {
47
+ > {
47
48
  readonly kind = 'column' as const;
48
49
 
49
50
  constructor(
@@ -61,76 +62,64 @@ export class ColumnBuilderImpl<
61
62
  return undefined as unknown as JsType;
62
63
  }
63
64
 
64
- /**
65
- * Converts this column builder to a ColumnRef expression.
66
- * This is the canonical way to get an AST node from a builder.
67
- */
68
- toExpr(): ColumnRef {
69
- return Object.freeze({
70
- kind: 'col' as const,
71
- table: this.table,
72
- column: this.column,
73
- });
74
- }
75
-
76
65
  private createBinaryBuilder(
77
66
  op: BinaryOp,
78
- value: ParamPlaceholder | ExpressionSource,
67
+ value: ParamPlaceholder | AnyColumnBuilderBase,
79
68
  ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
80
69
  if (value == null) {
81
- throw planInvalid(
82
- 'Parameter placeholder or expression source required for column comparison',
83
- );
70
+ throw planInvalid('Parameter placeholder or column builder required for column comparison');
84
71
  }
85
- // Check for ExpressionSource first (has toExpr method)
86
- if ('toExpr' in value && typeof value.toExpr === 'function') {
72
+ if (value.kind === 'param-placeholder' || isColumnBuilder(value)) {
87
73
  return Object.freeze({
88
74
  kind: 'binary' as const,
89
75
  op,
90
- left: this.toExpr(),
76
+ left: this as unknown as ColumnBuilder<ColumnName, ColumnMeta, JsType>,
91
77
  right: value,
92
78
  }) as BinaryBuilder<ColumnName, ColumnMeta, JsType>;
93
79
  }
94
- // Must be a ParamPlaceholder
95
- if ('kind' in value && value.kind === 'param-placeholder') {
96
- return Object.freeze({
97
- kind: 'binary' as const,
98
- op,
99
- left: this.toExpr(),
100
- right: value,
101
- }) as BinaryBuilder<ColumnName, ColumnMeta, JsType>;
102
- }
103
- throw planInvalid('Parameter placeholder or expression source required for column comparison');
80
+ throw planInvalid('Parameter placeholder or column builder required for column comparison');
104
81
  }
105
82
 
106
- eq(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
83
+ eq(
84
+ value: ParamPlaceholder | AnyColumnBuilderBase,
85
+ ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
107
86
  return this.createBinaryBuilder('eq', value);
108
87
  }
109
88
 
110
- neq(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
89
+ neq(
90
+ value: ParamPlaceholder | AnyColumnBuilderBase,
91
+ ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
111
92
  return this.createBinaryBuilder('neq', value);
112
93
  }
113
94
 
114
- gt(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
95
+ gt(
96
+ value: ParamPlaceholder | AnyColumnBuilderBase,
97
+ ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
115
98
  return this.createBinaryBuilder('gt', value);
116
99
  }
117
100
 
118
- lt(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
101
+ lt(
102
+ value: ParamPlaceholder | AnyColumnBuilderBase,
103
+ ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
119
104
  return this.createBinaryBuilder('lt', value);
120
105
  }
121
106
 
122
- gte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
107
+ gte(
108
+ value: ParamPlaceholder | AnyColumnBuilderBase,
109
+ ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
123
110
  return this.createBinaryBuilder('gte', value);
124
111
  }
125
112
 
126
- lte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
113
+ lte(
114
+ value: ParamPlaceholder | AnyColumnBuilderBase,
115
+ ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {
127
116
  return this.createBinaryBuilder('lte', value);
128
117
  }
129
118
 
130
119
  asc(): OrderBuilder<ColumnName, ColumnMeta, JsType> {
131
120
  return Object.freeze({
132
121
  kind: 'order' as const,
133
- expr: this.toExpr(),
122
+ expr: this as unknown as ColumnBuilder<ColumnName, ColumnMeta, JsType>,
134
123
  dir: 'asc' as const,
135
124
  }) as OrderBuilder<ColumnName, ColumnMeta, JsType>;
136
125
  }
@@ -138,7 +127,7 @@ export class ColumnBuilderImpl<
138
127
  desc(): OrderBuilder<ColumnName, ColumnMeta, JsType> {
139
128
  return Object.freeze({
140
129
  kind: 'order' as const,
141
- expr: this.toExpr(),
130
+ expr: this as unknown as ColumnBuilder<ColumnName, ColumnMeta, JsType>,
142
131
  dir: 'desc' as const,
143
132
  }) as OrderBuilder<ColumnName, ColumnMeta, JsType>;
144
133
  }