Skip to content

Commit 73c1cb1

Browse files
committed
feat(core): use const for type var of join
1 parent 1a01bb3 commit 73c1cb1

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

packages/core/src/database.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ export class Database<S = any, C extends Context = Context> extends Service<unde
114114
return new Selection(this.getDriver(table), table, query)
115115
}
116116

117-
join<U extends Join1.Input<S>>(tables: U, callback?: Join1.Predicate<S, U>, optional?: boolean[]): Selection<Join1.Output<S, U>>
118-
join<U extends Join2.Input<S>>(tables: U, callback?: Join2.Predicate<S, U>, optional?: Dict<boolean, Keys<U>>): Selection<Join2.Output<S, U>>
117+
join<const U extends Join1.Input<S>>(tables: U, callback?: Join1.Predicate<S, U>, optional?: boolean[]): Selection<Join1.Output<S, U>>
118+
join<const U extends Join2.Input<S>>(tables: U, callback?: Join2.Predicate<S, U>, optional?: Dict<boolean, Keys<U>>): Selection<Join2.Output<S, U>>
119119
join(tables: any, query?: any, optional?: any) {
120120
if (Array.isArray(tables)) {
121121
const sel = new Selection(this.getDriver(tables[0]), Object.fromEntries(tables.map((name) => [name, this.select(name)])))

packages/tests/src/json.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ namespace JsonTests {
165165
})
166166

167167
it('$.object on cell', async () => {
168-
const res = await database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
168+
const res = await database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
169169
.groupBy('bar', {
170170
x: row => $.array($.object(row.foo)),
171171
})
@@ -179,7 +179,7 @@ namespace JsonTests {
179179
})
180180

181181
it('$.array groupBy', async () => {
182-
await expect(database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
182+
await expect(database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
183183
.groupBy(['foo'], {
184184
x: row => $.array(row.bar.obj.x),
185185
y: row => $.array(row.bar.obj.y),
@@ -191,7 +191,7 @@ namespace JsonTests {
191191
{ foo: { id: 2, value: 2 }, x: [3], y: ['c'] },
192192
])
193193

194-
await expect(database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
194+
await expect(database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
195195
.groupBy(['foo'], {
196196
x: row => $.array(row.bar.obj.x),
197197
y: row => $.array(row.bar.obj.y),
@@ -203,7 +203,7 @@ namespace JsonTests {
203203
['c'],
204204
])
205205

206-
await expect(database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
206+
await expect(database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
207207
.groupBy(['foo'], {
208208
x: row => $.array(row.bar.obj.x),
209209
y: row => $.array(row.bar.obj.y),
@@ -234,7 +234,7 @@ namespace JsonTests {
234234
})
235235

236236
it('$.array in json', async () => {
237-
const res = await database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
237+
const res = await database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
238238
.groupBy('foo', {
239239
bars: row => $.array($.object({
240240
value: row.bar.value,
@@ -278,7 +278,7 @@ namespace JsonTests {
278278
})
279279

280280
it('$.array with expressions', async () => {
281-
const res = await database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
281+
const res = await database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
282282
.groupBy('foo', {
283283
bars: row => $.array($.object({
284284
value: row.bar.value,
@@ -307,7 +307,7 @@ namespace JsonTests {
307307
})
308308

309309
it('$.array nested', async () => {
310-
const res = await database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
310+
const res = await database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
311311
.orderBy(row => row.foo.id)
312312
.groupBy('foo', {
313313
y: row => $.array(row.bar.obj.x),
@@ -325,7 +325,7 @@ namespace JsonTests {
325325
})
326326

327327
it('non-aggr func', async () => {
328-
const res = await database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
328+
const res = await database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
329329
.groupBy('foo', {
330330
y: row => $.array(row.bar.obj.x),
331331
})
@@ -346,7 +346,7 @@ namespace JsonTests {
346346
})
347347

348348
it('non-aggr func inside aggr', async () => {
349-
const res = await database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
349+
const res = await database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
350350
.orderBy(row => row.foo.id)
351351
.groupBy('foo', {
352352
y: row => $.array(row.bar.obj.x),

packages/tests/src/selection.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,18 @@ namespace SelectionTests {
277277
export function join(database: Database<Tables>) {
278278
it('inner join', async () => {
279279
await expect(database
280-
.join(['foo', 'bar'] as const)
280+
.join(['foo', 'bar'])
281281
.execute()
282282
).to.eventually.have.length(18)
283283

284284
await expect(database
285-
.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.value, bar.value))
285+
.join(['foo', 'bar'], (foo, bar) => $.eq(foo.value, bar.value))
286286
.execute()
287287
).to.eventually.have.length(2)
288288
})
289289

290290
it('group', async () => {
291-
await expect(database.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.pid))
291+
await expect(database.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.pid))
292292
.groupBy('foo', { count: row => $.sum(row.bar.uid) })
293293
.orderBy(row => row.foo.id)
294294
.execute()).to.eventually.deep.equal([
@@ -330,7 +330,7 @@ namespace SelectionTests {
330330

331331
it('aggregate', async () => {
332332
await expect(database
333-
.join(['foo', 'bar'] as const)
333+
.join(['foo', 'bar'])
334334
.execute(row => $.count(row.bar.id))
335335
).to.eventually.equal(6)
336336
})
@@ -432,12 +432,12 @@ namespace SelectionTests {
432432
const one = database.select('bar').evaluate(row => $.subtract($.count(row.id), 5))
433433
const sel = x => database.select('bar').where(row => $.eq(x, row.uid)).evaluate(row => $.count(row.id))
434434
await expect(database
435-
.join(['foo', 'bar'] as const, (foo, bar) => $.gt(foo.value, one))
435+
.join(['foo', 'bar'], (foo, bar) => $.gt(foo.value, one))
436436
.execute()
437437
).to.eventually.have.length(12)
438438

439439
await expect(database
440-
.join(['foo', 'bar'] as const, (foo, bar) => $.lt(foo.value, sel(foo.id)))
440+
.join(['foo', 'bar'], (foo, bar) => $.lt(foo.value, sel(foo.id)))
441441
.execute()
442442
).to.eventually.have.length(6)
443443
})

0 commit comments

Comments
 (0)