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
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
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
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
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











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: