Skip to content

Instantly share code, notes, and snippets.

@aleandros
Created March 22, 2017 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleandros/d28eeed04f5655a6c94822ffc6234ee9 to your computer and use it in GitHub Desktop.
Save aleandros/d28eeed04f5655a6c94822ffc6234ee9 to your computer and use it in GitHub Desktop.
Ecto model access with CamelCase column names
[bank|_] = Repo.all(Bank)
# bank is a struct. Structs are maps.
%{BankId: id} = bank # this works
Map.get(bank, :BankId) # this works too
bank.BankId # This does not compile.
# Ecto queries would break as well
query = from b in Bank, where: b.BankName == "Bank Inc."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment