marcin
Import except: [fun: arity] does not import macros
Hello, I would like to import Ecto.Query but without importing the update: 2 to the namespace.
I can use only to specify what i want to import:
import Ecto.Query, only: [from: 2, join: 4, where: 3, preload: 2, distinct: 2]
but using except would be shorter (and I would not have to learn arities by heart):
import Ecto.Query, except: [update: 2]
However, this seems to not import macros (for example, where was not imported.
i need to do:
import Ecto.Query, only: :macros
import Ecto.Query, except: [update: 2]
Is this the expected way import works? From the doc, it seemed to me only: and except: are complimentary.
Using:
- Elixir 1.12.0 (compiled with Erlang/OTP 23)
- Erlang/OTP 24 [erts-12.0.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]
Most Liked
josevalim
The above, by itself, should import everything except update/2. I have tried it locally and I could observe this is correct and where was also imported. So double check your code and if the issue persists, can you please provide a file that reproduces the problem?
marcin
Ah, sorry my bad, I had a use OtherMod which would import Ecto.Query, only: [...fun list...], in which case my import Ecto.Query, except would exclude from that list (fun list imported in OtherMod) and not full Ecto Query list…
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










