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

Multiple inequality support #7453

Merged
merged 43 commits into from
Sep 13, 2023
Merged

Multiple inequality support #7453

merged 43 commits into from
Sep 13, 2023

Conversation

milaGGL
Copy link
Contributor

@milaGGL milaGGL commented Jul 13, 2023

Multiple inequality support

Firestore is removing the following restrictions around inequality filters (<, >, <=, >=, !=, not-in):

  • All inequality filters must reference the same field.
  • The first ordering must be the same field as an inequality filter

But the limitation on != and not-in remains the same, which is, at most one != or NOT_IN filters allowed in a query.

Ordering:

Firestore SDK normalizes the orders in a query by following rules:

  • Explicit order by should be listed first and as is.
  • Any inequality fields not explicitly ordered should have implicitly ordered.
  • The implicit order by fields should matches the last explicit order by direction
  • The implicit order by fields should follow lexicographical order (document key field should ordered to the end)
  • Document key order by should always added to the last, unless explicitly ordered.

Note that if there's an explicit orderBy on document key, therefore it's not the last one in order, there will be an error from the backend. The SDK will not perform this validation.

Client side indexing

This PR doesn't update the client side indexing. So the limitations above (single inequality, first order by field match) remains in this matter. When there is multiple inequality, it simply skips client side indexing.

@changeset-bot
Copy link

changeset-bot bot commented Jul 13, 2023

⚠️ No Changeset found

Latest commit: 4c154aa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 13, 2023

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (98cfcbd)Merge (dce2494)Diff
    browser375 kB374 kB-1.25 kB (-0.3%)
    esm5360 kB359 kB-909 B (-0.3%)
    main577 kB575 kB-1.48 kB (-0.3%)
    module375 kB374 kB-1.25 kB (-0.3%)
    react-native376 kB374 kB-1.25 kB (-0.3%)
  • @firebase/firestore-lite

    TypeBase (98cfcbd)Merge (dce2494)Diff
    browser110 kB109 kB-1.42 kB (-1.3%)
    esm5107 kB106 kB-1.15 kB (-1.1%)
    main152 kB150 kB-1.86 kB (-1.2%)
    module110 kB109 kB-1.42 kB (-1.3%)
    react-native110 kB109 kB-1.42 kB (-1.3%)
  • bundle

    12 size changes

    TypeBase (98cfcbd)Merge (dce2494)Diff
    firestore (Persistence)302 kB302 kB-89 B (-0.0%)
    firestore (Query Cursors)239 kB238 kB-1.05 kB (-0.4%)
    firestore (Query)237 kB236 kB-1.05 kB (-0.4%)
    firestore (Read data once)224 kB224 kB-269 B (-0.1%)
    firestore (Realtime updates)226 kB226 kB-269 B (-0.1%)
    firestore (Transaction)204 kB204 kB-269 B (-0.1%)
    firestore (Write data)204 kB203 kB-269 B (-0.1%)
    firestore-lite (Query Cursors)83.1 kB88.8 kB+5.73 kB (+6.9%)
    firestore-lite (Query)79.3 kB85.0 kB+5.73 kB (+7.2%)
    firestore-lite (Read data once)61.3 kB61.3 kB-3 B (-0.0%)
    firestore-lite (Transaction)86.2 kB86.2 kB-3 B (-0.0%)
    firestore-lite (Write data)70.9 kB70.9 kB-3 B (-0.0%)

  • firebase

    TypeBase (98cfcbd)Merge (dce2494)Diff
    firebase-compat.js779 kB778 kB-846 B (-0.1%)
    firebase-firestore-compat.js341 kB340 kB-846 B (-0.2%)
    firebase-firestore-lite.js118 kB116 kB-1.42 kB (-1.2%)
    firebase-firestore.js435 kB434 kB-1.26 kB (-0.3%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/okR39BMq1y.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 13, 2023

Size Analysis Report 1

This report is too large (443,647 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/6Aj7N4LRyw.html

@milaGGL milaGGL marked this pull request as ready for review July 13, 2023 20:10
@milaGGL milaGGL requested review from a team as code owners July 13, 2023 20:10
@milaGGL milaGGL requested a review from ehsannas July 13, 2023 20:11
@ehsannas ehsannas self-assigned this Jul 19, 2023
packages/firestore/src/core/filter.ts Outdated Show resolved Hide resolved
packages/firestore/src/lite-api/query.ts Show resolved Hide resolved
packages/firestore/src/lite-api/query.ts Show resolved Hide resolved
packages/firestore/src/model/target_index_matcher.ts Outdated Show resolved Hide resolved
packages/firestore/src/model/target_index_matcher.ts Outdated Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
packages/firestore/test/unit/core/query.test.ts Outdated Show resolved Hide resolved
packages/firestore/test/integration/api/query.test.ts Outdated Show resolved Hide resolved
@ehsannas ehsannas assigned milaGGL and unassigned ehsannas Jul 19, 2023
@cherylEnkidu cherylEnkidu force-pushed the mila/Multiple-Inequality-support branch from b77a49c to 9d6ab9f Compare August 30, 2023 21:38
@dconeybe dconeybe assigned cherylEnkidu and unassigned dconeybe Aug 31, 2023
@dconeybe dconeybe removed their assignment Aug 31, 2023
@milaGGL milaGGL merged commit e5b96d7 into master Sep 13, 2023
40 of 41 checks passed
@milaGGL milaGGL deleted the mila/Multiple-Inequality-support branch September 13, 2023 15:07
@firebase firebase locked and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants