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

SQLite affected row count and last_insert_rowid #3095

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

itowlson
Copy link
Collaborator

@itowlson itowlson commented Apr 8, 2025

Fixes #3092.

WIP for now

This adds two functions to the SQLite connection resource:

  • changes() - the number of rows affected by the last insert/delete/update
  • last_insert_rowid() - the rowid of the last inserted row

The names are taken from the SQLite API, and I'm in favour of sticking with that standard rather than giving them names that might be more self-documenting (stop shuffling your feet at the back, changes).

WIPness: the new functions appear to work but:

  • It needs tests Added to the existing SQLite test
  • It needs trying with libSQL
  • It needs a world update (for dev purposes I shoved it into the 3.0 world but that's not appropriate for shipping) Done - see separate comment below
  • I want to try to remove the v2/v3 duplication Done (hopefully satisfactorily)

I'm putting it into PR now so that 1. the integration tests pick up any regressions and 2. if folks have other things they want to put in then we can consider rolling them into a single rev.

The new interface is backward compatible and I did consider doing one of those "since" things to make it a minor version rev, which would eliminate all the duplication, but I provisionally went for a new interface because we are trying to shift from the fermyon: namespace to a spin: namespace. Happy to receive feedback on this!

@itowlson itowlson force-pushed the sqlite-row-count-row-id branch from 06e392a to 2b13d88 Compare April 9, 2025 01:13
@itowlson
Copy link
Collaborator Author

itowlson commented Apr 9, 2025

I've tentatively created a spin:[email protected] package to contain this. The alternative to to retain fermyon:spin@3, bump it to 3.1 and use an @since. This is more parsimonious and better expresses the compatibility guarantees, but doesn't contribute to moving us off the fermyon namespace.

I've done this as a separate commit do we can easily change or revert it independently of the functional work. Howl at me if you have something different in mind!

@itowlson itowlson marked this pull request as ready for review April 9, 2025 04:34
@itowlson itowlson marked this pull request as draft April 9, 2025 04:34
@itowlson itowlson force-pushed the sqlite-row-count-row-id branch from e266277 to 7de7a8c Compare April 9, 2025 04:37
@itowlson itowlson force-pushed the sqlite-row-count-row-id branch from 7de7a8c to dcebfcf Compare April 10, 2025 01:50
@itowlson itowlson force-pushed the sqlite-row-count-row-id branch from dcebfcf to b4df1bc Compare April 10, 2025 01:59
@itowlson itowlson marked this pull request as ready for review April 10, 2025 02:53
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

Successfully merging this pull request may close these issues.

Can we have affected_row_count and last_insert_rowid in QueryResult?
2 participants