Replies: 2 comments 6 replies
-
Generally speaking I'm open to such an addition as long as it contains documentation and tests and the API is somewhat clear. It's an interesting question how such a API should look like. I given the provided documentation it looks like that this field is returned as part of the query response. It's not clear for me if it's always set (for example on select queries) or not (only on insert statements?). I do not have a specific proposal how such an API should look like, but I'm open to suggestions. API wise it might be simpler to include the |
Beta Was this translation helpful? Give feedback.
-
The issues with using Looking at what other crates do, I think what I would propose is
This is, obviously, a breaking change, though. Is there anything you'd recommend to to make it non-breaking? [1] https://docs.rs/mysql/23.0.1/mysql/struct.QueryResult.html#method.last_insert_id |
Beta Was this translation helpful? Give feedback.
-
I haven't dug in to figure out when exactly it was added to the protocol, but MySQL's (and MariaDB's) OK packet includes last_insert_id[1][2], and it's supported by
mysql_common
[3] going back as far as the repo's first commit[4]I was also able to confirm that it does provide the correct value, at least with MariaDB 10.10.2 on my dev machine:
I did find #1011 and #1627 and the workaround (just calling MySQL's
LAST_INSERT_ID()
function) should work fine for my purpose, but wanted to also make a formal request to add support now that MySQL provides that value in the response :)I'm not sure what you want as far as API for this, but with some guidance would be happy to take a whack at implementing and make a PR
[1] https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_ok_packet.html
[2] https://mariadb.com/kb/en/ok_packet/
[3] https://docs.rs/mysql_common/0.30.3/mysql_common/packets/struct.OkPacket.html#method.last_insert_id
[4] https://github.com/blackbeam/rust_mysql_common/blob/5c53f9ff25285e9f573b4c17ff4832ca7c672173/src/packets.rs#L348
Beta Was this translation helpful? Give feedback.
All reactions