postgres-nio
postgres-nio copied to clipboard
Expose query `metadata`
Currently the functions that return PostgresRowSequence have no way of reporting back the metadata of the query.
This PR exposes the metadata.
Checklist
- [x] Add PostgresConnection tests for the new
queryandexecutefuncs - [x] Add PostgresClient funcs + tests
Codecov Report
Attention: Patch coverage is 35.21127% with 92 lines in your changes missing coverage. Please review.
Project coverage is 61.01%. Comparing base (
5d817be) to head (f388f5e).
Additional details and impacted files
@@ Coverage Diff @@
## main #504 +/- ##
==========================================
- Coverage 61.39% 61.01% -0.39%
==========================================
Files 125 125
Lines 10149 10291 +142
==========================================
+ Hits 6231 6279 +48
- Misses 3918 4012 +94
| Files with missing lines | Coverage Ξ | |
|---|---|---|
| Sources/PostgresNIO/New/PostgresRowSequence.swift | 90.38% <ΓΈ> (ΓΈ) |
|
| Sources/PostgresNIO/New/PSQLRowStream.swift | 87.53% <94.33%> (+1.17%) |
:arrow_up: |
| Sources/PostgresNIO/Pool/PostgresClient.swift | 0.00% <0.00%> (ΓΈ) |
|
| ...es/PostgresNIO/Connection/PostgresConnection.swift | 34.46% <0.00%> (-3.99%) |
:arrow_down: |
π New features to boost your workflow:
- β Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@fabianfett I've thought a bit more about this and possibly we might want to have another type that wraps PostgresRowSequence in the next major version at least? so we can expose more stuff in the response. Not only the metadata, but maybe even the connection properties? Or who knows what.
I don't have an immediate use-case for connection properties but it looks like some lost info. Maybe someone finds a value in them although they can also be individually queried.
I'd love this addition! I have queries that should update exactly 1 row. I'd like to check that the update was successful, but I can't check without the metadata. (These queries currently don't return the row itself.)
I'm not a fan of the proposed API changes: They either get everything into memory, or they force users to consume the rows synchronously. I consider both bad options.
I honestly don't think this is a problem. We're not really taking any options away.
However I do have an alternative in mind:
To be honest this looks better, at least at the first glance. So I'd be happy to move this way.
@MahdiBM what is the expected timeframe for this change to be included in a release ? Just wondering whether I should wait or fall back to using Connection.query in the interim ? I don't mind using a pre-release branch if there is one since we are in development still.
@duncangroenewald IIRC you found a solution for now using that PostgresDatabase function that has a onMetadata?
Anyway, I'm not sure about when this'll be released. I finished the PR now, @fabianfett will need to review and approve when he has time, then we'll see.
CodeCov report is not accurate about those funcs in the first 2 listed files not having tests. For some reason even Xcode can't correctly find the new funcs' symbols.
I've added both unit and integration tests.
@MahdiBM - OK well if there is any chance of creating a beta branch with this added let me know as I would rather use that than have to go back and simplify things later on.
@duncangroenewald I took a look and this branch is up to date with main, so you could temporarily depend on this branch (repo: https://github.com/MahdiBM/postgres-nio.git, branch: mmbm-row-seq-expose-metadata) if you want. Or did you mean a "beta release"?
thanks that branch of yours should be fine - just don't deleted it :)
I'll let you know how it goes.
@MahdiBM - any plan to include this in a release any time soon ? Thanks
@fabianfett can you have another look at this please? π