Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue where queryConstraint.type was undefined #7973

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cyan-apes-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/database": patch
---

Fixed issue where queryConstraint.type was undefined
22 changes: 11 additions & 11 deletions packages/database/src/api/Reference_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ export abstract class QueryConstraint {
}

class QueryEndAtConstraint extends QueryConstraint {
readonly type: 'endAt';
readonly type = 'endAt';

constructor(
private readonly _value: number | string | boolean | null,
Expand Down Expand Up @@ -1748,7 +1748,7 @@ export function endAt(
}

class QueryEndBeforeConstraint extends QueryConstraint {
readonly type: 'endBefore';
readonly type = 'endBefore';

constructor(
private readonly _value: number | string | boolean | null,
Expand Down Expand Up @@ -1809,7 +1809,7 @@ export function endBefore(
}

class QueryStartAtConstraint extends QueryConstraint {
readonly type: 'startAt';
readonly type = 'startAt';

constructor(
private readonly _value: number | string | boolean | null,
Expand Down Expand Up @@ -1873,7 +1873,7 @@ export function startAt(
}

class QueryStartAfterConstraint extends QueryConstraint {
readonly type: 'startAfter';
readonly type = 'startAfter';

constructor(
private readonly _value: number | string | boolean | null,
Expand Down Expand Up @@ -1933,7 +1933,7 @@ export function startAfter(
}

class QueryLimitToFirstConstraint extends QueryConstraint {
readonly type: 'limitToFirst';
readonly type = 'limitToFirst';

constructor(private readonly _limit: number) {
super();
Expand Down Expand Up @@ -1981,7 +1981,7 @@ export function limitToFirst(limit: number): QueryConstraint {
}

class QueryLimitToLastConstraint extends QueryConstraint {
readonly type: 'limitToLast';
readonly type = 'limitToLast';

constructor(private readonly _limit: number) {
super();
Expand Down Expand Up @@ -2030,7 +2030,7 @@ export function limitToLast(limit: number): QueryConstraint {
}

class QueryOrderByChildConstraint extends QueryConstraint {
readonly type: 'orderByChild';
readonly type = 'orderByChild';

constructor(private readonly _path: string) {
super();
Expand Down Expand Up @@ -2093,7 +2093,7 @@ export function orderByChild(path: string): QueryConstraint {
}

class QueryOrderByKeyConstraint extends QueryConstraint {
readonly type: 'orderByKey';
readonly type = 'orderByKey';

_apply<T>(query: QueryImpl): QueryImpl {
validateNoPreviousOrderByCall(query, 'orderByKey');
Expand Down Expand Up @@ -2121,7 +2121,7 @@ export function orderByKey(): QueryConstraint {
}

class QueryOrderByPriorityConstraint extends QueryConstraint {
readonly type: 'orderByPriority';
readonly type = 'orderByPriority';

_apply<T>(query: QueryImpl): QueryImpl {
validateNoPreviousOrderByCall(query, 'orderByPriority');
Expand Down Expand Up @@ -2149,7 +2149,7 @@ export function orderByPriority(): QueryConstraint {
}

class QueryOrderByValueConstraint extends QueryConstraint {
readonly type: 'orderByValue';
readonly type = 'orderByValue';

_apply<T>(query: QueryImpl): QueryImpl {
validateNoPreviousOrderByCall(query, 'orderByValue');
Expand Down Expand Up @@ -2178,7 +2178,7 @@ export function orderByValue(): QueryConstraint {
}

class QueryEqualToValueConstraint extends QueryConstraint {
readonly type: 'equalTo';
readonly type = 'equalTo';

constructor(
private readonly _value: number | string | boolean | null,
Expand Down
60 changes: 60 additions & 0 deletions packages/database/test/queryconstraint.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { expect } from 'chai';

import {
endAt,
endBefore,
equalTo,
limitToFirst,
limitToLast,
orderByChild,
orderByKey,
orderByPriority,
orderByValue,
startAfter,
startAt
} from '../src';

import { createTestApp } from './exp/integration.test';

describe('Query Constraints', () => {
let defaultApp;

beforeEach(() => {
defaultApp = createTestApp();
});
it('query constraint types are exposed', () => {
const queryConstraintTypes = [
{ qc: endAt(0), name: 'endAt' },
{ qc: endBefore(0), name: 'endBefore' },
{ qc: startAt(0), name: 'startAt' },
{ qc: startAfter(0), name: 'startAfter' },
{ qc: limitToFirst(1), name: 'limitToFirst' },
{ qc: limitToLast(1), name: 'limitToLast' },
{ qc: orderByChild('a'), name: 'orderByChild' },
{ qc: orderByKey(), name: 'orderByKey' },
{ qc: orderByPriority(), name: 'orderByPriority' },
{ qc: orderByValue(), name: 'orderByValue' },
{ qc: equalTo(''), name: 'equalTo' }
];
queryConstraintTypes.forEach(({ qc, name }) => {
expect(qc.type).to.equal(name);
});
});
});
Loading