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.


  • 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]

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?

1 Like

Ah, sorry my bad, I had a use OtherMod which would import Ecto.Query, only: [ 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…

1 Like