Skip to content

add support for Where().isIn query#602

Merged
tshedor merged 29 commits intoGetDutchie:mainfrom
richard457:main
Sep 19, 2025
Merged

add support for Where().isIn query#602
tshedor merged 29 commits intoGetDutchie:mainfrom
richard457:main

Conversation

@richard457
Copy link
Contributor

Pull Request Summary

Feature: Add isIn Query Operator to Where

Overview

This PR introduces a new isIn operator to the Brick query system, allowing users to easily query for values that exist within a list (e.g., SQL IN clause). This is useful for filtering records where a field matches any value in a provided list.

Key Changes

  • Compare Enum:

    • Added a new value: inList to represent the "IN" comparison.
  • Where Class:

    • Added a new convenience method:
      Where isIn(List<dynamic> values)
      This allows queries like:
      Query(where: [Where('name').isIn(['Alice', 'Bob', 'Charlie'])])
  • Unit Tests:

    • Added tests to where_test.dart to verify:
      • isIn works for integers:
        Where('id').isIn([1, 2, 3])
      • isIn works for strings:
        Where('name').isIn(['Alice', 'Bob'])

Usage Example

final query = Query(where: [Where('status').isIn(['pending', 'approved'])]);

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@tshedor
Copy link
Collaborator

tshedor commented Jun 20, 2025

@richard457 there's a lot of added code here that isn't relevant to the PR. Can you please remove your changes to supabase_example?

@richard457
Copy link
Contributor Author

richard457 commented Jun 20, 2025

@tshedor yes Done.

cursor[bot]

This comment was marked as outdated.

Copy link
Collaborator

@tshedor tshedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richard457 thank you for submitting this PR. It's a huge help for me.

This feature would be useful and I'd like to get it into Brick. I've got some small pieces of feedback inline. More broadly, could you please add unit tests for query_sql_transformer and query_supabase_transformer?

@richard457
Copy link
Contributor Author

Thanks for the feedback @tshedor allow me to work on this on my earliest time.

richard457 and others added 2 commits July 1, 2025 11:39
is used in the _generateInList() method when the value for an IN query is either not an iterable or is an empty iterable.
In SQL, an IN clause with an empty list is invalid syntax. For example, WHERE id IN () will cause an error.
Logically, if you ask for "all rows where id is in []", you should get no results.
To safely represent this in SQL, we use a condition that is always false: 1=0.
By returning ' $matcher 1=0', the generated SQL will look like ... WHERE ... AND 1=0, which will always be false and thus return no rows

Co-authored-by: Tim Shedor <tshedor@gmail.com>
@wwcom227
Copy link

wwcom227 commented Jul 7, 2025

@tshedor @richard457 Is there any new progress on this PR? This feature is really needed.

@richard457
Copy link
Contributor Author

Sorry, I got a lot, I am working on to address your comment, allow me today to send a patch. @tshedor

@richard457
Copy link
Contributor Author

@tshedor I uploaded changes, your review is highly needed, let me know if anything else I need to address will address it right way.

Copy link
Collaborator

@tshedor tshedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richard457 very close now

@richard457
Copy link
Contributor Author

@tshedor I was wrong the error I was experiencing might not related, I took your suggestion thanks and sorry to take long.

@richard457
Copy link
Contributor Author

@tshedor Please let me know if there is anything for me to address.

@richard457
Copy link
Contributor Author

Committed change @tshedor ://

@tshedor
Copy link
Collaborator

tshedor commented Aug 15, 2025

@richard457 looks like there's just one failing test on supabase_provider_test and then this is good to go

@richard457
Copy link
Contributor Author

cc @tshedor ://

@richard457 richard457 requested a review from tshedor September 5, 2025 15:17
@tshedor tshedor merged commit 01a6d98 into GetDutchie:main Sep 19, 2025
6 checks passed
@KiddoV
Copy link

KiddoV commented Oct 10, 2025

Can we have new version for those updated packages in this commit?
Currently I have to use:

dependencies:
  brick_core: ^2.0.0 # <- Need new version
  brick_sqlite: ^4.1.0 # <- Need new version
  brick_supabase: ^2.0.0 # <- Need new version
  brick_offline_first: ^4.0.1
  brick_offline_first_with_supabase: ^2.1.0 # <- This one included the updated code, but other packages are not compatible 
  
dependency_overrides:
    brick_core:
    git:
      url: https://github.com/GetDutchie/brick.git
      ref: 01a6d98463c2be5a978259b2f3302db69664cada
      path: packages/brick_core
  brick_sqlite:
    git:
      url: https://github.com/GetDutchie/brick.git
      ref: 01a6d98463c2be5a978259b2f3302db69664cada
      path: packages/brick_sqlite
  brick_supabase:
    git:
      url: https://github.com/GetDutchie/brick.git
      ref: 01a6d98463c2be5a978259b2f3302db69664cada
      path: packages/brick_supabase

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants