Support complex & array types in native query creation cli utility#742
Open
BenoitRanque wants to merge 5 commits intomainfrom
Open
Support complex & array types in native query creation cli utility#742BenoitRanque wants to merge 5 commits intomainfrom
BenoitRanque wants to merge 5 commits intomainfrom
Conversation
Contributor
|
Can we add tests for this functionality? |
…al to single dimensional arrays
Fix redundant continue statements to make compiler happy
BenoitRanque
commented
May 8, 2025
| } | ||
| } | ||
|
|
||
| for (composite_type_name, info) in &configuration.metadata.composite_types.0 { |
Contributor
Author
There was a problem hiding this comment.
This section was missing, and since v4 does have composite types I think this was a mistake
BenoitRanque
commented
May 8, 2025
Contributor
Author
There was a problem hiding this comment.
This continue statement did nothing.
There's a couple options for intent:
- either this was meant to be a
break, to exit the inner loop on first match - or, the intent was to proceed to the next iteration of the outer loop
I think the intent was the latter, so
- added label to loop
- continue using label so the right loop is continued
- removed
foundsince that becomes redundant
We could, alternatively, use break, and keep found if we think that's more readable?
Contributor
Author
There was a problem hiding this comment.
Note that using break would mean we'd iterate over composite types always, even if we did find our type as a scalar
Using continue 'rows I think better matches the intent here:
- iterate over rows
- for each row, try to find a matching scalar type and insert that to the map
- if no scalar found, try to find a matching composite
- if neither found, use type name as is
| "name": "characters", | ||
| "type": { | ||
| "scalarType": "characters" | ||
| "compositeType": "characters" |
Contributor
There was a problem hiding this comment.
Do we know why this changed?
danieljharvey
approved these changes
May 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The cli native query creation utility tries to figure out the argument & column types for the native query.
It currently assumes all columns & arguments are scalars, while the configuration supports array types & composite types.
This PR changes the utility to support composite types & array types.
How
We build on the existing system that uses sqlx utilities to describe a query. We get type info, then use the oid from that info to get a type name from the database.
We add an extra step, to check for arrays in the types, and if so get the underlying type before fetching an OID for that type.
We also add mapping to consider the type kind whether composite, scalar, or array, as we write the configuration.
We assume types are scalar if they're not composite nor array types. This matches previous behavior.
We also update a snapshot, which it turns out was wrong until this fix.