F
Filament8mo ago
Arjan

QueryBuilder is not filtering Numbers correctly

I am using Tablebuilder to display a season_number column from a metadata relationship:
TextColumn::make('metadata.season_number')
->numeric()
->label('Seasons')
TextColumn::make('metadata.season_number')
->numeric()
->label('Seasons')
When I am using QueryBuilder to create a filter for this column the filtering is not applied:
NumberConstraint::make('season_number')
->relationship(
name: 'metadata',
titleAttribute: 'season_number',
)
->integer()
->label("Seasons"),
NumberConstraint::make('season_number')
->relationship(
name: 'metadata',
titleAttribute: 'season_number',
)
->integer()
->label("Seasons"),
See attached screenshot. Please help! Thanks!
No description
9 Replies
Dennis Koch
Dennis Koch8mo ago
NumberConstraint is a custom filter? What is the code for that? Also please add code formatting as shown in #✅┊rules
Arjan
ArjanOP8mo ago
Hi Dennis, What do you mean by 'NumberContraint is a custom filter'? I am creating the constraint as described here: https://filamentphp.com/docs/3.x/tables/filters/query-builder
Dennis Koch
Dennis Koch8mo ago
Oh, sorry. That part is new to me. Haven’t used that one 😅🙈
awcodes
awcodes8mo ago
Make sure you are actually storing the value in the db as an integer or are applying the appropriate cast to it.
Arjan
ArjanOP8mo ago
We are doing that, storing the value as an int and cast it as an integer. We are using postgres, can this be causing the issue?
awcodes
awcodes8mo ago
Honestly, i'm not sure. never actually used Postgres
Arjan
ArjanOP8mo ago
Ok, hopefully, there is someone else who knows what is causing the issue?? Anyone?
Dennis Koch
Dennis Koch8mo ago
I'd say: Try debugging the DB queries and check what the actual query is. (Debugbar or tool of your choice)
Arjan
ArjanOP8mo ago
ok thanks, I will do that and try to see if there is something wrong.
Want results from more Discord servers?
Add your server