Repository navigation
libsql: fix cursor step_end deserialization, honor last_insert_rowid - #2304
Open
freedom-winds wants to merge 1 commit into
Open
freedom-winds wants to merge 1 commit into
freedom-winds wants to merge 1 commit into
Conversation
The client's StepEndEntry expected a field named last_inserted_rowid, but both the Hrana 3 spec and sqld's serializer use last_insert_rowid. Serde silently ignored the unknown key, so the cursor never surfaced a rowid: into_batch_result() always reported None and the query path never updated the stream, leaving Connection::last_insert_rowid() stale after query(). Rename the field to last_insert_rowid and deserialize it as Option<i64>, accepting both the JSON number sqld emits and the string form the spec defines. Propagate the value to the stream when the cursor step ends, matching what the non-cursor execute path already does.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While debugging why
Connection::last_insert_rowid()kept returning 0 after anINSERTexecuted throughquery()on a remote connection, I found that the hrana cursor path never receives the rowid at all.The client's
StepEndEntrydeclares a field namedlast_inserted_rowid, but both the Hrana 3 spec ("last_insert_rowid": string | null) and sqld's serializer uselast_insert_rowid. Serde silently ignores the unknown key, soCursorStepStatenever sees a rowid:into_batch_result()always reportsNone, andHranaRows::next()— which already propagatesaffected_row_countback to the stream when a step ends — never propagates the rowid either, leavingConnection::last_insert_rowid()stale afterquery().This renames the field to
last_insert_rowid, deserializes it asOption<i64>accepting both the JSON number form sqld emits and the string form the spec defines, propagates the value to the stream like the non-cursor execute path already does, and adds a test covering both encodings.