Skip to content

[FEAT] Filters Omnibus - #33

Merged
bbengfort merged 2 commits into
mainfrom
chrisokuda/filter_omnibus
Sep 3, 2026
Merged

[FEAT] Filters Omnibus#33
bbengfort merged 2 commits into
mainfrom
chrisokuda/filter_omnibus

Conversation

@chris-okuda

@chris-okuda chris-okuda commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Scope of changes

This PR improves filter composition and adds safer handling for list and quantified comparisons. It also adds trusted subquery support, stronger cloning and clearing behavior, and expanded documentation and tests.

Changes:

  • Make Filter.Where and WhereGroup.Where append conditions with AND.
  • Add ReplaceWhere, ClearWhere, and Clear.
  • Add NOT IN support and correct empty IN/NOT IN behavior.
  • Add Any(op) and All(op) comparisons.
  • Add trusted Subquery and Subselect support, including SELECT/WITH strings.
  • Ensure Clone creates an independent copy.
  • Add focused unit tests and PostgreSQL array integration coverage.
  • Update package documentation, public aliases, README.md, and test comments.
  • Remove deprecated public filter APIs and aliases.

Fixes SC-40490
Fixes SC-39883
Fixes SC-39711

Estimated PR Size:

  • Tiny
  • Small
  • Medium
  • Large
  • Huge

Acceptance criteria

NOTE: Most of this code is still "user beware" so the user must ensure their queries remain valid. For the filters, specifically, it is possible for the user to do things with WHERE, such as the new ANY and ALL op builder funcs, that can result in invalid SQL. In one instance, the builder just emits some invalid SQL when a user combines invalid operations. Unless we want to use a sum type which encapsulates a value and error at the same time there really isn't a good way to validate filter building, so it's simpler just to let the user deal with knowing/learning invalid combinations.

  • Filter WHERE conditions append safely.
  • Replacement and clearing behavior is explicit.
  • IN, NOT IN, ANY, and ALL render correctly.
  • Trusted subqueries are supported and documented along with a string fallback.
  • Cloning does not share filter state and is a "deep copy".
  • Unit tests pass.
  • PostgreSQL array support is covered by integration tests when configured.

Author checklist

  • I have manually tested the change and/or added automation in the form of unit tests or integration tests
  • I have updated the dependencies list
  • I have added new test fixtures as needed to support added tests
  • I have added or updated the documentation
  • I have run go generate to update generated code
  • Check this box if a reviewer can merge this pull request after approval

quantified comparisons. It also adds trusted subquery support, stronger
cloning and clearing behavior, and expanded documentation and tests.

Changes:
- Make Filter.Where and WhereGroup.Where append conditions with AND.
- Add ReplaceWhere, ClearWhere, and Clear.
- Add NOT IN support and correct empty IN/NOT IN behavior.
- Add Any(op) and All(op) comparisons.
- Add trusted Subquery and Subselect support, including SELECT/WITH
  strings.
- Ensure Clone creates an independent copy.
- Add focused unit tests and PostgreSQL array integration coverage.
- Update package documentation, public aliases, README.md, and test
  comments.
- Remove deprecated public filter APIs and aliases.
@chris-okuda chris-okuda self-assigned this Sep 1, 2026

@bbengfort bbengfort left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I read through this pretty well - everything looks very well implemented. These operators will certainly be very helpful and are going a long way to make tidal a more complete database helper tool!

Comment thread filter/builder/where.go
return fmt.Sprintf("%s %s %s", n.field, n.op, sym)
}
fallthrough
fallthrough // non-literal values render "field op value"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I really have to use fallthrough more -- I forgot that was a thing lol.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea! I liked it here but it's a bit of a niche tool

@bbengfort
bbengfort merged commit e152bd9 into main Sep 3, 2026
5 checks passed
@bbengfort
bbengfort deleted the chrisokuda/filter_omnibus branch September 3, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants