fix(sqlite): handle dots in prefix for extractParentChain (GH#664)

extractParentChain was using strings.Split(id, ".") which incorrectly
parsed prefixes containing dots (like "alicealexandra.com"). This caused
--parent to fail with "parent does not exist" even when the parent was
present in the database.

The fix uses IsHierarchicalID to walk up the hierarchy correctly, only
splitting on dots followed by numeric suffixes (the actual hierarchy
delimiter).

Example:
- "test.example-abc.1" now correctly returns ["test.example-abc"]
- Previously it incorrectly returned ["test", "test.example-abc"]

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-24 14:39:04 -08:00
parent 25402184a6
commit c28defb710
2 changed files with 38 additions and 10 deletions

View File

@@ -446,6 +446,27 @@ func TestExtractParentChain(t *testing.T) {
id: "test-abc.1.2.3",
expected: []string{"test-abc", "test-abc.1", "test-abc.1.2"},
},
// GH#664: Prefixes with dots should be handled correctly
{
name: "prefix with dot - top-level",
id: "test.example-abc",
expected: nil, // No numeric suffix, not hierarchical
},
{
name: "prefix with dot - one level deep",
id: "test.example-abc.1",
expected: []string{"test.example-abc"},
},
{
name: "prefix with dot - two levels deep",
id: "test.example-abc.1.2",
expected: []string{"test.example-abc", "test.example-abc.1"},
},
{
name: "prefix with multiple dots - one level deep",
id: "my.company.project-xyz.1",
expected: []string{"my.company.project-xyz"},
},
}
for _, tt := range tests {