db.pg: Support returning Result type with column names#25737
Merged
Conversation
Contributor
|
https://github.com/vlang/v/actions/runs/19352895759/job/55368240782?pr=25737 shows that the PR needs the new |
Contributor
Author
|
Added function documentation. |
Collaborator
|
None of those "Unhandled Exception" codes are valid codes. |
Contributor
Author
|
Sorry, not sure what you mean by "Unhandled Exception" codes. |
Collaborator
|
Not you - in the CI failure logs. |
Contributor
|
The CI is a bit flaky unfortunately in the last few days :-| . |
Collaborator
|
Merge master again. Should take care of the Windows failures, at least. |
* master: cgen: fix dump(ptr_to_fixed_array_value) - it now returns the argument directly (thanks @tankf33der) (vlang#25764) type_resolver: clear option flag if present in comptime $for (fix vlang#25761) (vlang#25763) db.sqlite: update windows version to https://sqlite.org/2025/sqlite-amalgamation-3510000.zip (vlang#25766) builder,pref: add `-file-list` support (implement feature vlang#25707) (vlang#25749)
Contributor
|
Thank you @omerrob 🙇🏻 . |
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.
Currently,
db.pgqueries return[]Row, which is justThen the developer needs to map the values based on ordinal places.
I understand that this was built with the ORM in mind, and the ORM maintains a mapping of the ordinal places with the struct members.
Sometimes we don't want to use the ORM or can't because we use a lot of
joins and CTEs (WITH clauses). In that case, it is convenient to have the column names in order to map the query.This PR adds the
Resultstruct:and adds matching
fn *_result()functions to the currently implemented functions.It also adds a quality-of-life mapping method to
Result:that accepts a mapper function to return a typed
struct.