Skip to content

Generate SQL for searching in explicit arrays - part 2/2 - Verify parsed queries and generated SQL works correctly #639

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

Conversation

ericpromislow
Copy link
Contributor

DO NOT MERGE

Depends on #626

Related to #49116

The idea in this PR is to set up a database (of foods, but there are tables for other rancher-like things that
will get used in a later PR), make URL-like queries on them, translate the queries into SQL, run the SQL through
sqlite, and verify that we get the expected results.

This happens when you look for a string in field X, and while X isn't indexed, X[1], X[2], etc. are.

Or we can treat the field X as a string of values "x1|x2|x3|x4" and see if it contains
the search string "x" in one of the or-bar parts (not supporting partial matches).
Since we have explicitly indexed array-like fields, run sql tests on them.
* When we're doing a < or > test on an array field, we have to verify that it's numeric.
  Otherwise SQL will do an alpha comparison, and that isn't what we want.

* Returning the errors from the parser as an aggregated error isn't very helpful.
  Convert to an error, so we can tell the user what actually happened.

* Note with the fixture tests that there are some food names in "_v1_Foods"
that aren't in "_v1_Foods_fields".  These won't show up in the results because
the join on the two tables will drop them, as they aren't in both tables.
This is by design.
@ericpromislow ericpromislow requested a review from a team as a code owner May 13, 2025 22:44
@ericpromislow ericpromislow marked this pull request as draft May 13, 2025 22:44
@ericpromislow
Copy link
Contributor Author

We're taking a different approach for array-based searching. Not doing metadata.fields. Different PR handles array-based searching for things like spec.containers.image where it's a single string field with |-separated substrings.

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.

1 participant