feat: implement automated database replication and fix RLS subquery & test issues#276
Open
mono-xyxy wants to merge 2 commits into
Open
feat: implement automated database replication and fix RLS subquery & test issues#276mono-xyxy wants to merge 2 commits into
mono-xyxy wants to merge 2 commits into
Conversation
Author
ezgif-252daf1324b4047c.mp4 |
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.
Walkthrough - Automated Database Replication Plugin
We have successfully implemented and verified the Automated Database Replication Plugin for StarbaseDB. We also identified and fixed pre-existing state pollution and subquery parsing bugs in the Row Level Security (RLS) test suite and code.
🚀 Changes Made
1. Database Replication Plugin
ReplicationPlugin.updated_attimestamps. Ifupdated_atis available, we use a robust composite tie-breaker sorting query (WHERE updated_at > ? OR (updated_at = ? AND id > ?) ORDER BY updated_at ASC, id ASC) to prevent paging skips on duplicate timestamps.tmp_replication_statewithlast_synced_idstored asTEXTto natively support UUID/string primary keys alongside auto-incrementing integers.ALTER TABLE ADD COLUMN.syncDeletions) that compares source primary keys to local SQLite primary keys and deletes any rows that were hard deleted in the external source.ReplicationPluginin index.ts and configured the environment variables in wrangler.toml and README.md.2. RLS Bug Fixes
mockConfig.roleto'client'in abeforeEachblock, preventing test pollution and ensuring that other test suites do not bypass RLS.expr.astwhen recursively traversing subqueries in the AST. Previously, subqueries insideFROMandJOINclauses were skipped.applyRLSToAstto correctly handle*wildcard policy permissions duringINSERTchecks.🧪 Validation Results
Automated Unit Tests
We wrote a comprehensive unit test suite in index.test.ts testing:
All 161 tests in the repository pass green: