Skip to content

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