Open History to see the last commit
1---
2id: DuplicateAliasInSubqueryError
3title: DuplicateAliasInSubqueryError
4---
5
6# Class: DuplicateAliasInSubqueryError
7
8Defined in: [packages/db/src/errors.ts:495](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L495)
9
10Error thrown when a subquery uses the same alias as its parent query.
11This causes issues because parent and subquery would share the same input streams,
12leading to empty results or incorrect data (aggregation cross-leaking).
13
14## Extends
15
16- [`QueryCompilationError`](QueryCompilationError.md)
17
18## Constructors
19
20### Constructor
21
22```ts
23new DuplicateAliasInSubqueryError(alias, parentAliases): DuplicateAliasInSubqueryError;
24```
25
26Defined in: [packages/db/src/errors.ts:496](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L496)
27
28#### Parameters
29
30##### alias
31
32`string`
33
34##### parentAliases
35
36`string`[]
37
38#### Returns
39
40`DuplicateAliasInSubqueryError`
41
42#### Overrides
43
44[`QueryCompilationError`](QueryCompilationError.md).[`constructor`](QueryCompilationError.md#constructor)
45
46## Properties
47
48### cause?
49
50```ts
51optional cause: unknown;
52```
53
54Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
55
56#### Inherited from
57
58[`QueryCompilationError`](QueryCompilationError.md).[`cause`](QueryCompilationError.md#cause)
59
60***
61
62### message
63
64```ts
65message: string;
66```
67
68Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
69
70#### Inherited from
71
72[`QueryCompilationError`](QueryCompilationError.md).[`message`](QueryCompilationError.md#message)
73
74***
75
76### name
77
78```ts
79name: string;
80```
81
82Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076
83
84#### Inherited from
85
86[`QueryCompilationError`](QueryCompilationError.md).[`name`](QueryCompilationError.md#name)
87
88***
89
90### stack?
91
92```ts
93optional stack: string;
94```
95
96Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
97
98#### Inherited from
99
100[`QueryCompilationError`](QueryCompilationError.md).[`stack`](QueryCompilationError.md#stack)
101
102***
103
104### stackTraceLimit
105
106```ts
107static stackTraceLimit: number;
108```
109
110Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67
111
112The `Error.stackTraceLimit` property specifies the number of stack frames
113collected by a stack trace (whether generated by `new Error().stack` or
114`Error.captureStackTrace(obj)`).
115
116The default value is `10` but may be set to any valid JavaScript number. Changes
117will affect any stack trace captured _after_ the value has been changed.
118
119If set to a non-number value, or set to a negative number, stack traces will
120not capture any frames.
121
122#### Inherited from
123
124[`QueryCompilationError`](QueryCompilationError.md).[`stackTraceLimit`](QueryCompilationError.md#stacktracelimit)
125
126## Methods
127
128### captureStackTrace()
129
130```ts
131static captureStackTrace(targetObject, constructorOpt?): void;
132```
133
134Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51
135
136Creates a `.stack` property on `targetObject`, which when accessed returns
137a string representing the location in the code at which
138`Error.captureStackTrace()` was called.
139
140```js
141const myObject = {};
142Error.captureStackTrace(myObject);
143myObject.stack; // Similar to `new Error().stack`
144```
145
146The first line of the trace will be prefixed with
147`${myObject.name}: ${myObject.message}`.
148
149The optional `constructorOpt` argument accepts a function. If given, all frames
150above `constructorOpt`, including `constructorOpt`, will be omitted from the
151generated stack trace.
152
153The `constructorOpt` argument is useful for hiding implementation
154details of error generation from the user. For instance:
155
156```js
157function a() {
158 b();
159}
160
161function b() {
162 c();
163}
164
165function c() {
166 // Create an error without stack trace to avoid calculating the stack trace twice.
167 const { stackTraceLimit } = Error;
168 Error.stackTraceLimit = 0;
169 const error = new Error();
170 Error.stackTraceLimit = stackTraceLimit;
171
172 // Capture the stack trace above function b
173 Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
174 throw error;
175}
176
177a();
178```
179
180#### Parameters
181
182##### targetObject
183
184`object`
185
186##### constructorOpt?
187
188`Function`
189
190#### Returns
191
192`void`
193
194#### Inherited from
195
196[`QueryCompilationError`](QueryCompilationError.md).[`captureStackTrace`](QueryCompilationError.md#capturestacktrace)
197
198***
199
200### prepareStackTrace()
201
202```ts
203static prepareStackTrace(err, stackTraces): any;
204```
205
206Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55
207
208#### Parameters
209
210##### err
211
212`Error`
213
214##### stackTraces
215
216`CallSite`[]
217
218#### Returns
219
220`any`
221
222#### See
223
224https://v8.dev/docs/stack-trace-api#customizing-stack-traces
225
226#### Inherited from
227
228[`QueryCompilationError`](QueryCompilationError.md).[`prepareStackTrace`](QueryCompilationError.md#preparestacktrace)