fix(forms): gate value_indexed population on is_filterable
FormValueObserver: value_indexed is filter-driven per ARCH §4.4, not hint-driven. Populating it for every string-hint field produced dead weight in the partial index and made FilterQueryBuilder logic murkier. Behaviour after fix: hint=string, is_filterable=true → populate value_indexed hint=string, is_filterable=false → leave null hint=number/date/bool, any filterable → populate typed column (unchanged) hint=json, any filterable → leave typed columns null (unchanged) value_number / value_date / value_bool remain hint-driven — they serve display and sorting beyond filtering. Only value_indexed is gated. VerifyFormsDataIntegrity: "value_indexed set on non-filterable field" is now a FAIL (was WARN) — it means the observer didn't run correctly, which is a real integrity issue. Observer tests: split the old "string hint populates value_indexed" case into filterable/non-filterable pair. Full suite 911/911. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,11 +32,12 @@ final class FormValueObserverTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_string_hint_populates_value_indexed(): void
|
||||
public function test_string_hint_populates_value_indexed_when_filterable(): void
|
||||
{
|
||||
$field = FormField::factory()->for($this->schema, 'schema')->create([
|
||||
'field_type' => FormFieldType::TEXT->value,
|
||||
'value_storage_hint' => FormValueStorageHint::STRING,
|
||||
'is_filterable' => true,
|
||||
]);
|
||||
|
||||
$value = FormValue::create([
|
||||
@@ -51,6 +52,23 @@ final class FormValueObserverTest extends TestCase
|
||||
$this->assertNull($value->value_bool);
|
||||
}
|
||||
|
||||
public function test_string_hint_leaves_value_indexed_null_when_not_filterable(): void
|
||||
{
|
||||
$field = FormField::factory()->for($this->schema, 'schema')->create([
|
||||
'field_type' => FormFieldType::TEXT->value,
|
||||
'value_storage_hint' => FormValueStorageHint::STRING,
|
||||
'is_filterable' => false,
|
||||
]);
|
||||
|
||||
$value = FormValue::create([
|
||||
'form_submission_id' => $this->submission->id,
|
||||
'form_field_id' => $field->id,
|
||||
'value' => ['value' => 'Niet-filterable tekst'],
|
||||
]);
|
||||
|
||||
$this->assertNull($value->fresh()->value_indexed);
|
||||
}
|
||||
|
||||
public function test_number_hint_populates_value_number(): void
|
||||
{
|
||||
$field = FormField::factory()->for($this->schema, 'schema')->create([
|
||||
|
||||
Reference in New Issue
Block a user