-
Notifications
You must be signed in to change notification settings - Fork 690
Add transaction method stubs to IndexedDB engine #2399
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
Conversation
Co-authored-by: mathiasrw <[email protected]>
Co-authored-by: mathiasrw <[email protected]>
Should we forward the transaction request to the underlying engine? |
The current implementation provides API compatibility to prevent the error, but doesn't implement true transaction semantics. IndexedDB's native transactions are synchronous and scope-based (auto-commit when execution context ends), which differs from AlaSQL's multi-step async pattern (BEGIN -> operations -> COMMIT/ROLLBACK). To properly forward to IndexedDB, we'd need to implement transaction state management similar to LOCALSTORAGE:
Should I implement proper transaction support with this behavior? This would be a more significant change but would provide true transactional guarantees. |
|
Yes, please provide transaction state management similar to LOCALSTORAGE. See if you can reuse across the two engines. |
- Added storeTable and restoreTable helper functions - Modified intoTable and fromTable to work with in-memory data when autocommit is OFF - Implemented begin, commit, and rollback with proper state management - Updated attachDatabase to load data into memory when autocommit is OFF - Added comprehensive tests for transaction behavior with COMMIT and ROLLBACK Co-authored-by: mathiasrw <[email protected]>
Implemented transaction state management similar to LOCALSTORAGE in commit 1ae1356: Added helper functions:
Transaction behavior:
Shared pattern: |
Co-authored-by: mathiasrw <[email protected]>
Replaced complex 330+ line implementation with simple 29-line solution: - IDB.commit() - Simple no-op returning success (IndexedDB auto-commits) - IDB.begin - Alias to commit (same pattern as LOCALSTORAGE) - IDB.rollback() - No-op with note that operations cannot be undone - Removed complex storeTable/restoreTable helpers - Removed conditional logic in intoTable/fromTable - Reverted test to simpler version without autocommit OFF tests This provides API compatibility to fix the original error while being much more elegant and maintainable. Co-authored-by: mathiasrw <[email protected]>
IndexedDB engine was missing
begin,commit, androllbackmethods, causingengines[...].begin is not a functionerrors when using transaction statements.Changes
IDB.begin(),IDB.commit(), andIDB.rollback()methods (29 lines)IDB.commit()- Simple no-op returning success (IndexedDB auto-commits per operation)IDB.begin- Alias tocommit(follows LOCALSTORAGE pattern)IDB.rollback()- No-op with documentation that operations cannot be undoneImplementation
Methods implemented as no-ops because IndexedDB manages transactions internally per operation. Each operation (insert, select, update, delete) automatically commits when complete.
This provides API compatibility so user code works without errors, while respecting IndexedDB's native auto-commit behavior.
Follows the same pattern as LOCALSTORAGE where
beginis an alias tocommit.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.