How to use date_range filter in Cinder.Table

Hey @Rebecca Le first of all, great work with this project. Our custom hacky data table with pagination broke with some deps.update and i added this so quickly without any effort 🙌 Now i am trying to use the date time range filter but when picking any date it raises
** (Protocol.UndefinedError) protocol String.Chars not implemented for type Ash.Query (a struct)
** (Protocol.UndefinedError) protocol String.Chars not implemented for type Ash.Query (a struct)
But with the resource it works Idk if this is the right place to ask this, should i just create a github issue?
Solution:
can you try main again? have just pushed another fix (and include_time should work properly now as well)
Jump to solution
21 Replies
Ahrou
AhrouOP4mo ago
Also noticed that even with the include_time option it does not appear to have it in the URL
<:col
:let={row}
field="created_at"
sort
filter
filter={:date_range}
filter_options={[include_time: true]}
>
<:col
:let={row}
field="created_at"
sort
filter
filter={:date_range}
filter_options={[include_time: true]}
>
?created_at=2025-06-10%2C
?created_at=2025-06-10%2C
sevenseacat
sevenseacat4mo ago
Hello! What version are you using? I fixed a bug in that the other day Can you try 0.2.0?
Ahrou
AhrouOP4mo ago
i just installed it today, its 0.2.0 :x
"cinder": {:hex, :cinder, "0.2.0", "77d1ec89a25f364...
"cinder": {:hex, :cinder, "0.2.0", "77d1ec89a25f364...
sevenseacat
sevenseacat4mo ago
Ah poop I’ll have a look
Ahrou
AhrouOP4mo ago
thank you 🙏 btw should date range be the default filter for all date attributes? mine is a :naive_datetime and the default was a text input just wondering because the text input generated an ILIKE query and postgres doesnt like that
[42883] ERROR: operator does not exist: timestamp without time zone ~~* unknown
[42883] ERROR: operator does not exist: timestamp without time zone ~~* unknown
sevenseacat
sevenseacat4mo ago
thats a good point can you share the backtrace of the error?
Ahrou
AhrouOP4mo ago
yes give me a sec
sevenseacat
sevenseacat4mo ago
can you also try cinder from main? I've pushed a fix to stop the crashing, that should log a better error as to what's actually happening
Ahrou
AhrouOP4mo ago
17:49:08.926 [error] Task #PID<0.2040.0> started from #PID<0.2037.0> terminating
** (Protocol.UndefinedError) protocol String.Chars not implemented for type Ash.Query (a struct)

Got value:

#Ash.Query<resource: App.Core.TwilioNumber>

(elixir 1.18.4) lib/string/chars.ex:3: String.Chars.impl_for!/1
(elixir 1.18.4) lib/string/chars.ex:22: String.Chars.to_string/1
(cinder 0.2.0) lib/cinder/query_builder.ex:93: Cinder.QueryBuilder.build_and_execute/2
(phoenix_live_view 1.0.17) lib/phoenix_live_view/async.ex:213: Phoenix.LiveView.Async.do_async/5
(elixir 1.18.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
Function: #Function<7.103986370/0 in Phoenix.LiveView.Async.run_async_task/5>
Args: [] { }
17:49:08.926 [error] GenServer #PID<0.2037.0> terminating
** (Protocol.UndefinedError) protocol String.Chars not implemented for type Ash.Query (a struct)

Got value:

#Ash.Query<resource: App.Core.TwilioNumber>

(elixir 1.18.4) lib/string/chars.ex:3: String.Chars.impl_for!/1
(elixir 1.18.4) lib/string/chars.ex:22: String.Chars.to_string/1
(cinder 0.2.0) lib/cinder/table/live_component.ex:523: Cinder.Table.LiveComponent.handle_async/3
(phoenix_live_view 1.0.17) lib/phoenix_live_view/async.ex:270: Phoenix.LiveView.Async.handle_kind/5
(phoenix_live_view 1.0.17) lib/phoenix_live_view/channel.ex:272: anonymous fn/6 in Phoenix.LiveView.Channel.handle_info/2
(phoenix_live_view 1.0.17) lib/phoenix_live_view/diff.ex:209: Phoenix.LiveView.Diff.write_component/4
(phoenix_live_view 1.0.17) lib/phoenix_live_view/channel.ex:663: Phoenix.LiveView.Channel.component_handle/4
(stdlib 6.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
(stdlib 6.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
(stdlib 6.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
17:49:08.926 [error] Task #PID<0.2040.0> started from #PID<0.2037.0> terminating
** (Protocol.UndefinedError) protocol String.Chars not implemented for type Ash.Query (a struct)

Got value:

#Ash.Query<resource: App.Core.TwilioNumber>

(elixir 1.18.4) lib/string/chars.ex:3: String.Chars.impl_for!/1
(elixir 1.18.4) lib/string/chars.ex:22: String.Chars.to_string/1
(cinder 0.2.0) lib/cinder/query_builder.ex:93: Cinder.QueryBuilder.build_and_execute/2
(phoenix_live_view 1.0.17) lib/phoenix_live_view/async.ex:213: Phoenix.LiveView.Async.do_async/5
(elixir 1.18.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
Function: #Function<7.103986370/0 in Phoenix.LiveView.Async.run_async_task/5>
Args: [] { }
17:49:08.926 [error] GenServer #PID<0.2037.0> terminating
** (Protocol.UndefinedError) protocol String.Chars not implemented for type Ash.Query (a struct)

Got value:

#Ash.Query<resource: App.Core.TwilioNumber>

(elixir 1.18.4) lib/string/chars.ex:3: String.Chars.impl_for!/1
(elixir 1.18.4) lib/string/chars.ex:22: String.Chars.to_string/1
(cinder 0.2.0) lib/cinder/table/live_component.ex:523: Cinder.Table.LiveComponent.handle_async/3
(phoenix_live_view 1.0.17) lib/phoenix_live_view/async.ex:270: Phoenix.LiveView.Async.handle_kind/5
(phoenix_live_view 1.0.17) lib/phoenix_live_view/channel.ex:272: anonymous fn/6 in Phoenix.LiveView.Channel.handle_info/2
(phoenix_live_view 1.0.17) lib/phoenix_live_view/diff.ex:209: Phoenix.LiveView.Diff.write_component/4
(phoenix_live_view 1.0.17) lib/phoenix_live_view/channel.ex:663: Phoenix.LiveView.Channel.component_handle/4
(stdlib 6.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
(stdlib 6.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
(stdlib 6.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
the error from the date actually is not from Postgres
sevenseacat
sevenseacat4mo ago
right, that's the crashy I fixed - it's trying to log an error with the query but crashing when trying to log lol
Ahrou
AhrouOP4mo ago
17:51:54.036 [error] Cinder table query execution failed for #Ash.Query<resource: App.Core.TwilioNumber>: %Ash.Error.Unknown{bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], query: "#Query<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (Postgrex.Error) ERROR 42883 (undefined_function) operator does not exist: timestamp without time zone ~~* unknown\n\n query: SELECT p0.\"enabled\", p0.\"id\", p0.\"number\", p0.\"brand_id\", p0.\"locked\", p0.\"date_created\", p0.\"country\", p0.\"callee_status\", p0.\"sponsor_id\", p0.\"partner_id\", p0.\"team_id\", p0.\"campaign_id\", p0.\"disabled_date\", p0.\"external_reference\", p0.\"to_delete\", p0.\"date_deleted\", p0.\"account\", p0.\"status\" FROM \"phone_number\" AS p0 WHERE (p0.\"date_created\"::timestamp ILIKE $1) ORDER BY p0.\"id\" LIMIT $2\n\n hint: No operator matches the given name and argument types. You might need to add explicit type casts.", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]} { mfa=Cinder.QueryBuilder.build_and_execute/2 line=74 }
17:51:54.036 [error] Cinder table query execution failed for #Ash.Query<resource: App.Core.TwilioNumber>: %Ash.Error.Unknown{bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], query: "#Query<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (Postgrex.Error) ERROR 42883 (undefined_function) operator does not exist: timestamp without time zone ~~* unknown\n\n query: SELECT p0.\"enabled\", p0.\"id\", p0.\"number\", p0.\"brand_id\", p0.\"locked\", p0.\"date_created\", p0.\"country\", p0.\"callee_status\", p0.\"sponsor_id\", p0.\"partner_id\", p0.\"team_id\", p0.\"campaign_id\", p0.\"disabled_date\", p0.\"external_reference\", p0.\"to_delete\", p0.\"date_deleted\", p0.\"account\", p0.\"status\" FROM \"phone_number\" AS p0 WHERE (p0.\"date_created\"::timestamp ILIKE $1) ORDER BY p0.\"id\" LIMIT $2\n\n hint: No operator matches the given name and argument types. You might need to add explicit type casts.", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]} { mfa=Cinder.QueryBuilder.build_and_execute/2 line=74 }
that error appeared twice, and then this one
17:51:54.037 [error] Cinder table query failed for #Ash.Query<resource: App.Core.TwilioNumber>: %Ash.Error.Unknown{bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], query: "#Query<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (Postgrex.Error) ERROR 42883 (undefined_function) operator does not exist: timestamp without time zone ~~* unknown\n\n query: SELECT p0.\"enabled\", p0.\"id\", p0.\"number\", p0.\"brand_id\", p0.\"locked\", p0.\"date_created\", p0.\"country\", p0.\"callee_status\", p0.\"sponsor_id\", p0.\"partner_id\", p0.\"team_id\", p0.\"campaign_id\", p0.\"disabled_date\", p0.\"external_reference\", p0.\"to_delete\", p0.\"date_deleted\", p0.\"account\", p0.\"status\" FROM \"phone_number\" AS p0 WHERE (p0.\"date_created\"::timestamp ILIKE $1) ORDER BY p0.\"id\" LIMIT $2\n\n hint: No operator matches the given name and argument types. You might need to add explicit type casts.", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]} { mfa=Cinder.Table.LiveComponent.handle_async/3 line=499 }
17:51:54.037 [error] Cinder table query failed for #Ash.Query<resource: App.Core.TwilioNumber>: %Ash.Error.Unknown{bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], query: "#Query<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (Postgrex.Error) ERROR 42883 (undefined_function) operator does not exist: timestamp without time zone ~~* unknown\n\n query: SELECT p0.\"enabled\", p0.\"id\", p0.\"number\", p0.\"brand_id\", p0.\"locked\", p0.\"date_created\", p0.\"country\", p0.\"callee_status\", p0.\"sponsor_id\", p0.\"partner_id\", p0.\"team_id\", p0.\"campaign_id\", p0.\"disabled_date\", p0.\"external_reference\", p0.\"to_delete\", p0.\"date_deleted\", p0.\"account\", p0.\"status\" FROM \"phone_number\" AS p0 WHERE (p0.\"date_created\"::timestamp ILIKE $1) ORDER BY p0.\"id\" LIMIT $2\n\n hint: No operator matches the given name and argument types. You might need to add explicit type casts.", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]} { mfa=Cinder.Table.LiveComponent.handle_async/3 line=499 }
so yeah the same as PG
sevenseacat
sevenseacat4mo ago
okay timestamps are definetly not ilike-able this is with a date range field?
Ahrou
AhrouOP4mo ago
no it was the text input, with the date range im getting this
17:55:17.454 [error] Cinder table query execution failed for #Ash.Query<resource: App.Core.TwilioNumber>: %Ash.Error.Invalid{bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], query: "#Query<>", errors: [%Ash.Error.Query.InvalidFilterValue{message: nil, value: "2024-10-09", context: #Ecto.Query<from t0 in App.Core.TwilioNumber, as: 0, where: type(as(0).created_at, {:parameterized, {Ash.Type.NaiveDatetime.EctoType, []}}) >=
type(^"2024-10-09", {:parameterized, {Ash.Type.NaiveDatetime.EctoType, []}}), where: type(as(0).created_at, {:parameterized, {Ash.Type.NaiveDatetime.EctoType, []}}) <=
type(^"2025-06-24", {:parameterized, {Ash.Type.NaiveDatetime.EctoType, []}}), order_by: [asc: as(0).id], limit: ^26, select: struct(t0, [
:enabled,
:id,
:number,
:locked,
:team_id,
:twilio_id,
:twilio_account,
:date_deleted,
:to_delete,
:disabled_date,
:callee_status,
:twilio_status,
:created_at,
:organization_id,
:project_id,
:site_id,
:campaign_id,
:country
])>, splode: Ash.Error, bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :invalid}]} { mfa=Cinder.QueryBuilder.build_and_execute/2 line=74 }
17:55:17.454 [error] Cinder table query execution failed for #Ash.Query<resource: App.Core.TwilioNumber>: %Ash.Error.Invalid{bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], query: "#Query<>", errors: [%Ash.Error.Query.InvalidFilterValue{message: nil, value: "2024-10-09", context: #Ecto.Query<from t0 in App.Core.TwilioNumber, as: 0, where: type(as(0).created_at, {:parameterized, {Ash.Type.NaiveDatetime.EctoType, []}}) >=
type(^"2024-10-09", {:parameterized, {Ash.Type.NaiveDatetime.EctoType, []}}), where: type(as(0).created_at, {:parameterized, {Ash.Type.NaiveDatetime.EctoType, []}}) <=
type(^"2025-06-24", {:parameterized, {Ash.Type.NaiveDatetime.EctoType, []}}), order_by: [asc: as(0).id], limit: ^26, select: struct(t0, [
:enabled,
:id,
:number,
:locked,
:team_id,
:twilio_id,
:twilio_account,
:date_deleted,
:to_delete,
:disabled_date,
:callee_status,
:twilio_status,
:created_at,
:organization_id,
:project_id,
:site_id,
:campaign_id,
:country
])>, splode: Ash.Error, bread_crumbs: ["Error returned from: App.Core.TwilioNumber.read"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :invalid}]} { mfa=Cinder.QueryBuilder.build_and_execute/2 line=74 }
maybe because it is missing the time? i have this option but still doesnt show up
filter_options={[include_time: true]}
filter_options={[include_time: true]}
sevenseacat
sevenseacat4mo ago
😦 ah there we go, it's because it's a naive datetime field fixing 🙂
Solution
sevenseacat
sevenseacat4mo ago
can you try main again? have just pushed another fix (and include_time should work properly now as well)
Ahrou
AhrouOP4mo ago
works great now 🙌
sevenseacat
sevenseacat4mo ago
huzzah! thank you for reporting that and verifying the fix 🙂 I'll release those fixes in a proper version
Ahrou
AhrouOP4mo ago
np thanks for the support 😁 the default filter type for the dates was unchanged right?
sevenseacat
sevenseacat4mo ago
I did change it while I was in there because text fields aren't good for date-like attributes ...at least, I thought I did 🤔
Ahrou
AhrouOP4mo ago
i even tried changing my type to datetime instead of naive but still it was a text input 🤔
sevenseacat
sevenseacat4mo ago
i'll fix that too, for now filter={:date_range} will be fine

Did you find this page helpful?