Commit 1bc4934
feat: Complete merge operations with comprehensive tests and benchmarks
Implemented Cypher-style MERGE operations for nodes and edges with full TDD workflow.
## Features
- **mergeNode()**: Create or match nodes with onCreate/onMatch semantics
- **mergeEdge()**: Create or match edges with property merging
- **Index Management**: createPropertyIndex(), dropIndex(), listIndexes()
- **Conflict Detection**: MergeConflictError for ambiguous matches
- **Performance Warnings**: Alert when merging without indexes
## Tests (33 new tests, 234 total)
- Node creation with onCreate properties
- Node matching with onMatch properties
- Multiple match criteria (AND logic)
- Conflict detection for multiple matches
- Edge creation and matching
- Property merging (not replacement)
- Index management (create, drop, list, idempotent)
- Nested properties support
## Performance Benchmarks
- mergeEdge (match): 37,337 ops/sec
- mergeEdge (create): 36,485 ops/sec
- mergeNode (indexed): 29,974 ops/sec
- mergeNode (create): 6,565 ops/sec
- **7.11x speedup with indexes** (29,844 vs 4,196 ops/sec)
## Bug Fixes
- Fixed JSON.stringify issue in mergeNode matching (line 658)
- Fixed SQLite parameterized WHERE clause in index creation
- Added conflict detection to mergeEdge
- Fixed edge property merging to include baseProperties
## Files Changed
- src/core/Database.ts: Implemented merge operations
- src/types/merge.ts: Type definitions and error classes
- tests/unit/Database-merge.test.ts: 33 comprehensive tests
- benchmarks/merge-operations.ts: 10 benchmark scenarios
- README.md: Updated with Phase 3 completion and benchmarks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 11c80fa commit 1bc4934
File tree
10 files changed
+2885
-9
lines changed- benchmarks
- results
- docs
- src
- core
- types
- tests
- unit
10 files changed
+2885
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | | - | |
160 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
186 | | - | |
| 187 | + | |
187 | 188 | | |
188 | | - | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
193 | 201 | | |
194 | 202 | | |
195 | 203 | | |
| |||
224 | 232 | | |
225 | 233 | | |
226 | 234 | | |
227 | | - | |
228 | | - | |
229 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
230 | 238 | | |
231 | 239 | | |
232 | 240 | | |
233 | 241 | | |
234 | | - | |
| 242 | + | |
| 243 | + | |
235 | 244 | | |
0 commit comments