maz
I’m getting this error:
## ** (Ecto.Query.CompileError) Tuples can only be used in comparisons with literal tuples of the same size
from this line in an Ecto query:
dynamic([mi], where: mi.updated_at >= ^datetime or ^conditions)
mi.updated_at is defined as: timestamps(type: :utc_datetime)
The incoming published_after is a unix epoch value which I convert to a DateTime with from_unix()
Pretty new to dates in Elixir in general, so I’m not sure what is going on. Any help?
Michael
conditions =
if published_after do
{:ok, datetime} = DateTime.from_unix(published_after, :second)
Logger.info("published_after: #{published_after}")
Logger.info("datetime: #{datetime}")
## log output:
## [info] published_after: 1546312169
## [info] datetime: 2019-01-01 03:09:29Z
## ** (Ecto.Query.CompileError) Tuples can only be used in comparisons with literal tuples of the same size
dynamic([mi], where: mi.updated_at >= ^datetime or ^conditions)
# updated_at defined as:- timestamps(type: :utc_datetime)
else
conditions
end
Trending in Chat/Questions
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Try converting the UNIX seconds variable to Erlang tuple?
maz
I tried this:
but same error. I think it has something to do with the fact that I use
dynamic()because this chunk below compiles and runs(but returns inaccurate search results). I would like to use dynamic() because it makes it a lot easier to apply optional search parameters to a query.compiles but returns incorrect results:
Compiles but runtime error:
josevalim
Ecto 3 does not allow erl_datetime anymore, since we have proper calendar types. You have to pass the naive_datetime or the datetime directly instead.
maz
Thanks, confirmed and working. I had a confluence of two bugs: using the wrong time format and incorrect syntax in the dynamic() macro.
For future readers(I ANDed the conditions, YMMV):
More info: