Skip to content

Add query metadata #95

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

Merged
merged 1 commit into from
Apr 3, 2020
Merged

Add query metadata #95

merged 1 commit into from
Apr 3, 2020

Conversation

tanner0101
Copy link
Member

@tanner0101 tanner0101 commented Apr 3, 2020

Adds new API for accessing query metadata via conn.query (fixes #93).

conn.query("...", onMetadata: { metadata in 
    print(metadata.rows) // Int?
}) { row in 
    print(row) // PostgresRow
}.wait()

This is a breaking change since conn.query now returns PostgresQueryResult instead of [PostgresRow]. However, PostgresQueryResult conforms to Collection so most code should be unaffected.

let result = try conn.query("...").wait()
for row in result {
    print(row) // PostgresRow
}
print(result.metadata) // PostgresQueryMetadata
print(result.rows) // [PostgresRow]

@tanner0101 tanner0101 added enhancement New feature or request semver-major labels Apr 3, 2020
@tanner0101 tanner0101 changed the title Add postgres query metadata Add query metadata Apr 3, 2020
@tanner0101 tanner0101 merged commit a528171 into master Apr 3, 2020
@tanner0101
Copy link
Member Author

These changes are now available in 1.0.0-rc.2

@duncangroenewald
Copy link

duncangroenewald commented Feb 25, 2025

@tanner0101
Any reason why this has not been included in the PostgresClient.query() API ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query metadata is not passed through for update/delete queries.
2 participants