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
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:
Create a new backend in SeaQuery called MariadbQueryBuilder which would build up on MysqlQueryBuilder and support stuff like INSERT ... RETURNING.
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.
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).
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.
The text was updated successfully, but these errors were encountered:
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 usingInsertStatement::returning_col
and similar APIs.Proposed Solutions
There are several ideas for the possible implementation that I could think of:
MariadbQueryBuilder
which would build up onMysqlQueryBuilder
and support stuff likeINSERT ... RETURNING
.RETURNING
functionality in the already existing MySQL backend in a similar fashion tooption-sqlite-exact-column-type
oroption-more-parentheses
.struct MysqlQueryBuilder
so that it would contain some sort ofOptions
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).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.
The text was updated successfully, but these errors were encountered: