NyxCode / ormx

bringing orm-like features to sqlx
MIT License
287 stars 32 forks source link

use impl Executor in Insert::insert instead of &mut Connection #27

Closed Punie closed 2 years ago

Punie commented 2 years ago

This implements the solution discussed in https://github.com/NyxCode/ormx/issues/22#issuecomment-1010043291

⚠️ Please beware that this is a BREAKING CHANGE ⚠️

Essentially, it allows to use the same API db: impl Executor<...> in Insert::insert instead of the odd db: &mut Connection<...>. The reason for that special case was to fetch the newly created id for MySQL by reusing the connection.

This solution implements that by opening a transaction when generating Insert::insert for MySQL.

NyxCode commented 2 years ago

this was on my to-do list for a long time! thanks!