Conversation
test: rename _fork_enabled to _fork_table_enabled
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds server-gated DIFF and MERGE table operations: BaseClient internal support, Collection public APIs (.diff, .merge_into), integration tests for diff/merge behaviors, and a small test helper rename to probe fork-table capability. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Collection
participant BaseClient
participant Server
Client->>BaseClient: diff(incoming, current)
activate BaseClient
BaseClient->>BaseClient: _diff_merge_enabled()
Note over BaseClient: check db_type == "seekdb" and version >= 1.2.0.0
BaseClient->>BaseClient: _get_collection_table_name(incoming)\n_get_collection_table_name(current)
BaseClient->>Server: DIFF TABLE <incoming_table> AGAINST <current_table>
Server-->>BaseClient: diff rows
deactivate BaseClient
BaseClient-->>Client: list of diff entries
sequenceDiagram
participant Client as Collection
participant BaseClient
participant Server
Client->>BaseClient: merge_into(incoming, target, strategy)
activate BaseClient
BaseClient->>BaseClient: _diff_merge_enabled()
Note over BaseClient: check db_type == "seekdb" and version >= 1.2.0.0
BaseClient->>BaseClient: validate strategy in _VALID_MERGE_STRATEGIES
BaseClient->>BaseClient: _get_collection_table_name(incoming)\n_get_collection_table_name(target)
BaseClient->>Server: MERGE TABLE <incoming_table> INTO <target_table> STRATEGY <STRATEGY>
Server-->>BaseClient: execution result / error
deactivate BaseClient
BaseClient-->>Client: None (raises on error)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/pyseekdb/client/client_base.py`:
- Around line 1577-1584: The diff/merge currently builds table names from
incoming/current but always runs SQL on self, allowing cross-client operations;
add a guard at the start of the diff/merge helpers (before calling
_get_collection_table_name or _execute) that verifies both incoming and current
belong to this client/context (e.g., compare their client attribute or
underlying connection/DB identifier to self) and raise a ValueError if they
differ; apply the same check to the analogous block around the 1600-1613 region
so operations cannot run against a different client/schema.
- Around line 1566-1589: _collection_diff returns the raw payload from _execute
which can be tuples on some backends, but Collection.diff is documented to
return list[dict[str, Any]]; update _collection_diff to normalize the rows into
dicts before returning (like other BaseClient paths do): after calling
self._execute(diff_sql) convert each row to a mapping using the collection
schema/column names from _get_collection_table_name/incoming/current (or
existing helper used elsewhere) so the method (_collection_diff) always returns
a list of dicts when _diff_merge_enabled() is true.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 124ce44a-b7b2-426b-9d05-f80c2d5b2a72
📒 Files selected for processing (5)
src/pyseekdb/client/client_base.pysrc/pyseekdb/client/collection.pytests/integration_tests/test_collection_diff.pytests/integration_tests/test_collection_fork.pytests/integration_tests/test_collection_merge.py
hnwyllmm
left a comment
There was a problem hiding this comment.
Thanks for your contribution. I left some comments.
Please add some samples for database fork/diff/merge and test the functions both in server and embedded mode.
| with contextlib.suppress(Exception): | ||
| self._execute(client, f"DROP TABLE IF EXISTS `{name}`") | ||
|
|
||
| def test_diff_identical_tables(self, db_client): |
There was a problem hiding this comment.
Could you please test with collections but not common tables?
| with contextlib.suppress(Exception): | ||
| self._execute(client, f"DROP TABLE IF EXISTS `{name}`") | ||
|
|
||
| def test_merge_no_conflict(self, db_client): |
There was a problem hiding this comment.
Please test the cases with collections but not common tables.
|
The related functions are not available for collections, so let's hold this feature for a while. |
Fixes #187
Summary by CodeRabbit
New Features
Tests