river icon indicating copy to clipboard operation
river copied to clipboard

Is there a way to use transactions without pgx?

Open mrkaspa opened this issue 1 year ago • 10 comments

I have a project with bun sql and I would like to insert a job as part of a transaction, but I can only use pgx.Tx transactions. Also I can use sql.Tx but the driver does not support this

mrkaspa avatar Apr 15 '24 18:04 mrkaspa

Not currently — I have a branch where this almost works, but it's going to take a little more work still. I think I'll get this sooner than later.

brandur avatar Apr 16 '24 00:04 brandur

@brandur great to hear that, hope to use that feature soon

mrkaspa avatar Apr 16 '24 13:04 mrkaspa

We also use bun and would love to see support for bun.Tx and/or sql.Tx. Otherwise it seems impossible to integrate with existing transactions.

hypnoglow avatar Apr 18 '24 16:04 hypnoglow

Okay, good to know. Going to try and get to this pretty soon.

brandur avatar Apr 19 '24 00:04 brandur

I think with bun you can use the sql.Tx transactions since bun.Tx is a wrapper for sql.Tx, btw I am using bun as well

mrkaspa avatar Apr 19 '24 14:04 mrkaspa

Hey guys, could you tell me what underlying driver you're using to power database/sql in general? Do you use lib/pq or is it database/sql + Pgx, or something else like Bun's Postgres driver?

brandur avatar May 05 '24 07:05 brandur

Hey @brandur

Currently, we consider only pgx to be a viable driver. We switch old apps from lib/pq. And bun native driver has some problems that we don't have using pgx.

hypnoglow avatar May 05 '24 14:05 hypnoglow

Excellent, that's helpful. Thanks Igor.

brandur avatar May 05 '24 14:05 brandur

Chiming in here! We are currently using database/sql with github.com/jackc/pgx/v5/stdlib as the actual driver.

dhermes avatar May 06 '24 17:05 dhermes

Opened #351. We'll need some additional docs, but it make use of River with Bun possible.

brandur avatar May 12 '24 11:05 brandur

We use lib/pq with sqlc and would love to see River working with it. Happy to do some legwork

ewhauser avatar May 18 '24 19:05 ewhauser

Actually, ignore this request. Sounds like after some research it's better that we just migrate over to pgx anyways.

ewhauser avatar May 18 '24 20:05 ewhauser

This one's pretty close in that there's a working driver in #351, but yes, you should definitely switch to pgx anyway.

brandur avatar May 19 '24 06:05 brandur

If anybody out there is interested in giving this a try, database/sql functionality was merged in #351. We still haven't cut an official release with it (should come in v0.10.0) nor have we finished documentation on it, but the actual support has been merged.

bgentry avatar Jul 07 '24 22:07 bgentry

This was officially shipped last week: https://riverqueue.com/blog/database-sql

Please let us know if you run into any issues with it!

bgentry avatar Jul 26 '24 15:07 bgentry

Hey @bgentry

I found that docs about drivers are now outdated, without database/sql not mentioned. https://riverqueue.com/docs/database-drivers

hypnoglow avatar Sep 20 '24 09:09 hypnoglow