pgxmock
pgxmock copied to clipboard
Get value of arg to use in subsequent query
I have code that generates UUIDs that are passed into a second query. How would it be possible to get the value of the arg passed into ExpectQuery and re-use it in subsequent Expect.
Here's a quick example
// AnyArg is a generated UUID
mockDB.ExpectExec("insert into table").
WithArgs(AnyArg).
WillReturnResult(pgxmock.NewResult("INSERT", 1))
mockDB.ExpectQuery("^select (.+) from table (.+)").
// I'm trying to reuse the ID generated and passed into the
// previous query
WithArgs(ARG_FROM_PREVIOUS).
WillReturnRows(mockDB.NewRows(columns).
AddRow(ARG_FROM_PREVIOUS))
Thanks for your work on this package!