Cannot query new value within Echo.Multi transaction

Hey all! I just started using Ecto.Multi, and I’ve run into a snag that I was hoping someone could help me with.

Here’s what my transaction looks like:
|>, fn _ ->
|>, fn _ ->
|> Repo.transaction()

To give some context, the first Multi run statement creates records in the database within a nested transaction. The second Multi run statement then queries that user’s records which SHOULD include the new ones I just created. However, the newly created records are not coming back in that select.

Does anyone know what could be up? Am I just making incorrect assumptions that those inserts would be immediately available in the next stage of my Multi transaction?

Thanks so much!

It could be because the transaction hasn’t been completed yet, so the inserts haven’t been committed to the database at the time you try to fetch the records.

For this scenario I’m not sure you need a multi? Does it work without a multi and transaction?

Postgres supports this