tduccuong
Function overriding causes warning
Hi, I have a “base” module with this
defmodule DbModel do
@callback schema() :: Map.t
defmacro __using__(_opts) do
quote do
@behaviour DbModel
...boiler plates with actual implementation...
def schema(), do: %{}
defoverridable schema: 0
end
end
...stuffs implemented for this base module...
end
Then I have a module
defmodule CustomerM do
defstruct id: nil,
...other props...
use ExConstructor
@impl DbModel
def schema(), do: %{
...specific schema validation and conversion...
}
use DbModel
end
It works well for my application, but one thing bugs me is this:
warning: this clause cannot match because a previous clause at line xx always matches
lib/db/model/customer_m.ex:31
Yes, I know about Ecto etc, but I choose this way of handling db model for a reason.
My question is more general: What is the correct way to achieve this kind of function overriding?
Thanks a lot!
Marked As Solved
tduccuong
Popular in Questions
Hello, how can I check the Phoenix version ?
Thanks !
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Other popular topics
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









