F
Filament10mo 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 Koch10mo ago
NumberConstraint is a custom filter? What is the code for that? Also please add code formatting as shown in #✅┊rules
Arjan
ArjanOP10mo 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 Koch10mo ago
Oh, sorry. That part is new to me. Haven’t used that one 😅🙈
awcodes
awcodes10mo ago
Make sure you are actually storing the value in the db as an integer or are applying the appropriate cast to it.
Arjan
ArjanOP10mo 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
awcodes10mo ago
Honestly, i'm not sure. never actually used Postgres
Arjan
ArjanOP10mo ago
Ok, hopefully, there is someone else who knows what is causing the issue?? Anyone?
Dennis Koch
Dennis Koch10mo ago
I'd say: Try debugging the DB queries and check what the actual query is. (Debugbar or tool of your choice)
Arjan
ArjanOP10mo ago
ok thanks, I will do that and try to see if there is something wrong.

Did you find this page helpful?