Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RETURNING support for MariaDB #847

Open
m4tx opened this issue Dec 15, 2024 · 0 comments
Open

RETURNING support for MariaDB #847

m4tx opened this issue Dec 15, 2024 · 0 comments

Comments

@m4tx
Copy link

m4tx commented Dec 15, 2024

Motivation

INSERT RETURNING SQL syntax is typically used when you need to insert records and have their auto incremented generated ids back to store somewhere for latter use, for instance to store them in some Foreign Keys in other tables.

Currently, SeaQuery supports RETURNING for Postgres and more recent versions of SQLite. It is not supported in MySQL, but MariaDB supports it. It would be nice to have a way to utilize it in SeaQuery using InsertStatement::returning_col and similar APIs.

Proposed Solutions

There are several ideas for the possible implementation that I could think of:

  1. Create a new backend in SeaQuery called MariadbQueryBuilder which would build up on MysqlQueryBuilder and support stuff like INSERT ... RETURNING.
  2. Add a feature flag to the crate that would enable RETURNING functionality in the already existing MySQL backend in a similar fashion to option-sqlite-exact-column-type or option-more-parentheses.
  3. Modify struct MysqlQueryBuilder so that it would contain some sort of Options struct that could be used to enable such functionality at runtime (probably not a viable solution since it would require changing a lot of user code, but listing it here for comparison purposes).
  4. Just implement the functionality without any conditional checks in a similar fashion to the SQLite backend which doesn't check the SQLite version either (hence possibly generating invalid queries if used on MySQL instead of MariaDB).

Which of these (if any) is a suitable solution is a matter for further discussion.

Additional Information

I would be interested in implementing this if it is agreed that this is a reasonable feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant