workers-rs icon indicating copy to clipboard operation
workers-rs copied to clipboard

Update` tokio-postgres` example to demonstrate Hyperdrive

Open kflansburg opened this issue 9 months ago • 2 comments

kflansburg avatar May 04 '24 13:05 kflansburg

@xortive, might need your help to get this working. I believe that using StartTLS is the right way to go based on node-postgres code. I'm pretty confident that this example will not use a prepared statement.

I get the following errors:

db error: FATAL: Internal error.
Error: Network connection lost.

cc @avsaase

kflansburg avatar May 04 '24 13:05 kflansburg

I've tried disabling TLS entirely, as well as constructing the Config object without the full connection string (just username, password, and database). Same error both times. Could be a bug in the workers-rs Socket Stream implementation, but difficult to narrow things down.

kflansburg avatar May 04 '24 13:05 kflansburg

I'm pretty confident that this example will not use a prepared statement.

simple_query won't use prepared statements but query will, I believe. The issue is that tokio-postgres doesn't support unnamed statements and Hyperdrive doesn't support prepared statements - so query won't work.

I had this issue in my blog about using tokio-postgres in workers-rs.

tokio-postgres does not currently support unnamed statements, which is required since connection poolers do not support prepared statements.

We will be using a fork by devsnek as the pull request has not been merged yet.

I didn't use Tls though, that's likely a separate issue, but I think you will run into issues using query regardless.

KianNH avatar May 07 '24 12:05 KianNH

simple_query won't use prepared statements but query will, I believe. The issue is that tokio-postgres doesn't support unnamed statements and Hyperdrive doesn't support prepared statements - so query won't work.

This fixed it, thanks!

kflansburg avatar May 07 '24 13:05 kflansburg