Skip to content

Conversation

@balegas
Copy link
Contributor

@balegas balegas commented Jan 6, 2026

Closes #3672

claude added 3 commits January 5, 2026 17:13
This plan outlines the changes needed to add subquery move support:

- Phase 1: Create TagIndex and MoveState modules for tag tracking
- Phase 2: Update message types (EventMessage, tags in Headers)
- Phase 3: Update stream processing to handle move-outs
- Phase 4: Add comprehensive tests
- Phase 5: Documentation updates

The implementation follows the same algorithm as TanStack DB client,
using a positional tag index for efficient pattern matching.
Formatted issue with:
- Background and wire protocol examples
- Phased implementation plan with code snippets
- File change summary
- Acceptance criteria checklist
- Design decisions documentation
This adds support for tagged rows and move-out events, enabling proper
handling of shapes with subqueries in their WHERE clauses.

New modules:
- TagIndex: Positional index for efficient move-out pattern matching
- MoveState: Tracks tags per row and handles move-out processing

Message changes:
- Headers: Added tags and removed_tags fields
- EventMessage: New struct for move-out events
- ControlMessage: Added xmin/xmax/xip_list for snapshot-end visibility

Stream changes:
- Track move_state for tag management
- Buffer move-out events during initial sync
- Process buffered move-outs on up-to-date
- Generate synthetic delete messages for rows with empty tag sets

The implementation follows the same algorithm as TanStack DB client,
ensuring consistent behavior across all Electric client implementations.
@netlify
Copy link

netlify bot commented Jan 6, 2026

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 1beec63
🔍 Latest deploy log https://app.netlify.com/projects/electric-next/deploys/695ceadff940cb000815dc6e
😎 Deploy Preview https://deploy-preview-3674--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Jan 6, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
601 1 600 0
View the top 1 failed test(s) by shortest run time
test/integration.test.ts > HTTP Sync > should chunk a large log with reasonably sized chunks
Stack Traces | 0.0414s run time
AssertionError: expected 1 to be at least 2

- Expected
+ Received

- 2
+ 1

 ❯ test/integration.test.ts:912:25

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@blacksmith-sh

This comment has been minimized.

claude added 2 commits January 6, 2026 10:58
Wildcards in tags are not indexed for efficiency (consistent with
TanStack DB implementation). Updated test to document this expected
behavior:
- Pattern lookups at wildcard positions don't find rows
- Pattern lookups at non-wildcard positions still work correctly
@balegas balegas marked this pull request as ready for review January 6, 2026 12:36
claude added 3 commits January 6, 2026 13:16
Tests cover:
- Change messages with tags (insert, update, delete)
- Move-out events generating synthetic deletes
- Rows with remaining tags not being deleted
- Multiple rows matching move-out patterns
- Buffering move-outs during initial sync
- Message parsing for events, tags, and snapshot-end
- Stream state reset on must-refetch
@blacksmith-sh

This comment has been minimized.

@balegas balegas requested a review from icehaunter January 6, 2026 18:49
@balegas balegas changed the title Implement move-in/out algorithm for subqueries Implement move-in/out algorithm in Elixir Client Jan 6, 2026
Tests use real Postgres and Electric server to verify:
- Shapes with subquery WHERE clauses receive tagged rows
- Move-out events triggered when parent rows no longer match
- Move-in events when parent rows start matching
- Synthetic deletes generated for rows with emptied tag sets
- Multiple children affected by single parent move-out

Test scenarios mirror sync-service router tests for subqueries.
@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Jan 6, 2026

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
test/integration.test.ts/HTTP Sync >
should chunk a large log with reasonably sized chunks
View Logs

Fix in Cursor

balegas and others added 2 commits January 7, 2026 00:43
- Use local path dependency for electric to ensure feature_flags flow
  correctly from runtime.exs through StackSupervisor to StackConfig
- Enable allow_subqueries and tagged_subqueries feature flags for tests
- Update tests to expect synthetic DELETE messages instead of raw
  EventMessage (Stream module processes move-out events internally)
- Remove debug code and unused functions from test file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Add Move-In/Out Support for Subqueries in Elixir Client

3 participants