Skip to content

Commit 400efa0

Browse files
authored
Merge 1f4a374 into 9ea0e3b
2 parents 9ea0e3b + 1f4a374 commit 400efa0

File tree

3 files changed

+76
-11
lines changed

3 files changed

+76
-11
lines changed

.changeset/cyan-apes-listen.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/database": patch
3+
---
4+
5+
Fixed issue where queryConstraint.type was undefined

packages/database/src/api/Reference_impl.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ export abstract class QueryConstraint {
16831683
}
16841684

16851685
class QueryEndAtConstraint extends QueryConstraint {
1686-
readonly type: 'endAt';
1686+
readonly type = 'endAt';
16871687

16881688
constructor(
16891689
private readonly _value: number | string | boolean | null,
@@ -1748,7 +1748,7 @@ export function endAt(
17481748
}
17491749

17501750
class QueryEndBeforeConstraint extends QueryConstraint {
1751-
readonly type: 'endBefore';
1751+
readonly type = 'endBefore';
17521752

17531753
constructor(
17541754
private readonly _value: number | string | boolean | null,
@@ -1809,7 +1809,7 @@ export function endBefore(
18091809
}
18101810

18111811
class QueryStartAtConstraint extends QueryConstraint {
1812-
readonly type: 'startAt';
1812+
readonly type = 'startAt';
18131813

18141814
constructor(
18151815
private readonly _value: number | string | boolean | null,
@@ -1873,7 +1873,7 @@ export function startAt(
18731873
}
18741874

18751875
class QueryStartAfterConstraint extends QueryConstraint {
1876-
readonly type: 'startAfter';
1876+
readonly type = 'startAfter';
18771877

18781878
constructor(
18791879
private readonly _value: number | string | boolean | null,
@@ -1933,7 +1933,7 @@ export function startAfter(
19331933
}
19341934

19351935
class QueryLimitToFirstConstraint extends QueryConstraint {
1936-
readonly type: 'limitToFirst';
1936+
readonly type = 'limitToFirst';
19371937

19381938
constructor(private readonly _limit: number) {
19391939
super();
@@ -1981,7 +1981,7 @@ export function limitToFirst(limit: number): QueryConstraint {
19811981
}
19821982

19831983
class QueryLimitToLastConstraint extends QueryConstraint {
1984-
readonly type: 'limitToLast';
1984+
readonly type = 'limitToLast';
19851985

19861986
constructor(private readonly _limit: number) {
19871987
super();
@@ -2030,7 +2030,7 @@ export function limitToLast(limit: number): QueryConstraint {
20302030
}
20312031

20322032
class QueryOrderByChildConstraint extends QueryConstraint {
2033-
readonly type: 'orderByChild';
2033+
readonly type = 'orderByChild';
20342034

20352035
constructor(private readonly _path: string) {
20362036
super();
@@ -2093,7 +2093,7 @@ export function orderByChild(path: string): QueryConstraint {
20932093
}
20942094

20952095
class QueryOrderByKeyConstraint extends QueryConstraint {
2096-
readonly type: 'orderByKey';
2096+
readonly type = 'orderByKey';
20972097

20982098
_apply<T>(query: QueryImpl): QueryImpl {
20992099
validateNoPreviousOrderByCall(query, 'orderByKey');
@@ -2121,7 +2121,7 @@ export function orderByKey(): QueryConstraint {
21212121
}
21222122

21232123
class QueryOrderByPriorityConstraint extends QueryConstraint {
2124-
readonly type: 'orderByPriority';
2124+
readonly type = 'orderByPriority';
21252125

21262126
_apply<T>(query: QueryImpl): QueryImpl {
21272127
validateNoPreviousOrderByCall(query, 'orderByPriority');
@@ -2149,7 +2149,7 @@ export function orderByPriority(): QueryConstraint {
21492149
}
21502150

21512151
class QueryOrderByValueConstraint extends QueryConstraint {
2152-
readonly type: 'orderByValue';
2152+
readonly type = 'orderByValue';
21532153

21542154
_apply<T>(query: QueryImpl): QueryImpl {
21552155
validateNoPreviousOrderByCall(query, 'orderByValue');
@@ -2178,7 +2178,7 @@ export function orderByValue(): QueryConstraint {
21782178
}
21792179

21802180
class QueryEqualToValueConstraint extends QueryConstraint {
2181-
readonly type: 'equalTo';
2181+
readonly type = 'equalTo';
21822182

21832183
constructor(
21842184
private readonly _value: number | string | boolean | null,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* @license
3+
* Copyright 2024 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { expect } from 'chai';
19+
20+
import {
21+
endAt,
22+
endBefore,
23+
equalTo,
24+
limitToFirst,
25+
limitToLast,
26+
orderByChild,
27+
orderByKey,
28+
orderByPriority,
29+
orderByValue,
30+
startAfter,
31+
startAt
32+
} from '../src';
33+
34+
import { createTestApp } from './exp/integration.test';
35+
36+
describe('Query Constraints', () => {
37+
let defaultApp;
38+
39+
beforeEach(() => {
40+
defaultApp = createTestApp();
41+
});
42+
it('query constraint types are exposed', () => {
43+
const queryConstraintTypes = [
44+
{ qc: endAt(0), name: 'endAt' },
45+
{ qc: endBefore(0), name: 'endBefore' },
46+
{ qc: startAt(0), name: 'startAt' },
47+
{ qc: startAfter(0), name: 'startAfter' },
48+
{ qc: limitToFirst(1), name: 'limitToFirst' },
49+
{ qc: limitToLast(1), name: 'limitToLast' },
50+
{ qc: orderByChild('a'), name: 'orderByChild' },
51+
{ qc: orderByKey(), name: 'orderByKey' },
52+
{ qc: orderByPriority(), name: 'orderByPriority' },
53+
{ qc: orderByValue(), name: 'orderByValue' },
54+
{ qc: equalTo(''), name: 'equalTo' }
55+
];
56+
queryConstraintTypes.forEach(({ qc, name }) => {
57+
expect(qc.type).to.equal(name);
58+
});
59+
});
60+
});

0 commit comments

Comments
 (0)