Open MahdiBM opened 1 month ago
I think the simpleQuery
method is named as such in a casual manner: it's "simple" simply because a String goes in and rows come out. That's unrelated to the wire message the doc page is about, and is actually implemented as a prepared statement behind the scenes...
That's what I figured ... Looks to me, too big of a coincidence that they have the same name, but I guess the best solution right now is to just add a new function supporting the definition in Postgres' wire protocol.
Or it's possible we can just change the implementation of the current function without any breaking behavior changes.
simpleQuery
used to allow multiple commands, before the big internals rewrite, that landed in 1.5.0
. simpleQuery
are not so simple if you think about them more.
simpleQuery
s can have multiple selects in a single statement. How do you want to hand the rows to the user now? It would need to be an AsyncSequence of AsyncSequence of Rows... But you can only iterate the outer AsyncSequence if you have emptied the inner AsyncSequence and so forth and so forth.
@MahdiBM Do you want to drive an API design for this? Once we have an API design, we can look into implementing the Simple Statement flow and fix this API short-comming.
Alternative for now: Deprecate simpleQuery
. Wdyt?
cc @gwynne
Describe the issue
Unable to send multiple SQL commands in one
simpleQuery
.Vapor version
1.21.5
Operating system and version
macOS 15
Swift version
swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10) Target: arm64-apple-macosx15.0
Steps to reproduce
Outcome
Additional notes
Postgres documentation mentions that multiple SQL commands in one simple query is allowed: