You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
not sure if this is intentional, but when inserting jobs using InsertManyTx it seems that the scheduled_at column is set to 0001-01-01 00:00:00.000000 +00:00. It's not a big deal, I think, but makes for somewhat awkward views in the UI:
I'm guessing I could explicitly set those with the InsertOpts, but thought it might be easier to have the same default behavior that I get when just inserting a single job.
@ligustah actually, I'm not able to reproduce this. I wrote a test which passes nilInsertOpts to InsertManyTx, and one which passes an empty &InsertOpts{}—both of them correctly write a default timestamp of now() to the database.
Do you have any code you can share to help understand how this is being used? Also, are you using the pgxv5 driver or database/sql?
Interesting. I'm using the database/sql driver to insert the jobs and the pgx for the workers. Let me see if I can create a minimal reproduction. Will report back.
Activity
bgentry commentedon Aug 5, 2024
Thanks for reporting. This is likely a bug, the behavior should be the same here for
InsertTx+InsertManyTx.bgentry commentedon Aug 5, 2024
@ligustah actually, I'm not able to reproduce this. I wrote a test which passes
nilInsertOptstoInsertManyTx, and one which passes an empty&InsertOpts{}—both of them correctly write a default timestamp ofnow()to the database.Do you have any code you can share to help understand how this is being used? Also, are you using the pgxv5 driver or database/sql?
ligustah commentedon Aug 5, 2024
Interesting. I'm using the database/sql driver to insert the jobs and the pgx for the workers. Let me see if I can create a minimal reproduction. Will report back.
bgentry commentedon Aug 5, 2024
@ligustah I think this is specific to database/sql and is a gap in the driver test suite. Compare the
dbsqlimplementation to the pgx one.Should be able to get a fix up later today. As a quick workaround, you can set
time.Now()explicitly, but we'll have this fixed soon.database/sql: fix InsertManyTx default scheduled_at
database/sql: fix InsertManyTx default scheduled_at
database/sql: fix InsertManyTx default scheduled_at
database/sql: fix InsertManyTx default scheduled_at
bgentry commentedon Aug 5, 2024
Should be fixed in #504 and the next release ✌️
ligustah commentedon Aug 5, 2024
Amazing, thanks for the quick fix 🙏
brandur commentedon Aug 6, 2024
Fix released in v0.11.1.
database/sql: default to current time if scheduled_at unspecified (ri…