Skip to content

Commit 47e60b1

Browse files
abnegateclaude
andcommitted
fix(sqlite): drop tenant from FTS5 table names
FTS5 tables were named {namespace}_{tenant}_{collection}_{attrs}_fts at creation (when tenant was empty) but findFulltextTableForAttribute re-derived the prefix at query time when tenant has been populated to the current project's id, so the LIKE prefix never matched. Regular SQL tables under shared mode use {namespace}_{collection} — tenant is a discriminator column, not a name suffix — and the FTS5 layer tracks the parent collection 1:1, so the same convention applies. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3e27ef1 commit 47e60b1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Database/Adapter/SQLite.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public function getSizeOfCollection(string $collection): int
352352
$namespace = $this->getNamespace();
353353
$name = $namespace . '_' . $collection;
354354
$permissions = $namespace . '_' . $collection . '_perms';
355-
$ftsPrefix = "{$namespace}_{$this->tenant}_{$collection}_";
355+
$ftsPrefix = "{$namespace}_{$collection}_";
356356

357357
// FTS5 virtual tables don't show up in dbstat themselves — their
358358
// storage is backed by shadow tables named `<vtable>_data`,
@@ -736,11 +736,14 @@ protected function getFulltextTableName(string $collection, array|string $attrib
736736

737737
/**
738738
* Common prefix for every FTS5 table belonging to `$collection`. Used by
739-
* lookup helpers that scan sqlite_master with a LIKE pattern.
739+
* lookup helpers that scan sqlite_master with a LIKE pattern. Mirrors
740+
* getSQLTable's naming — namespace + collection only, no tenant. Under
741+
* shared tables the tenant is a column, not a name suffix, and the FTS5
742+
* table tracks the underlying collection 1:1.
740743
*/
741744
protected function getFulltextTablePrefix(string $collection): string
742745
{
743-
return "{$this->getNamespace()}_{$this->tenant}_{$this->filter($collection)}_";
746+
return "{$this->getNamespace()}_{$this->filter($collection)}_";
744747
}
745748

746749
/**

0 commit comments

Comments
 (0)