You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add guard clauses to obtain better error messages.
For example, get_with_assocs passing the struct instead of ID gives
** (Ecto.Query.CastError) deps/ecto/lib/ecto/repo/queryable.ex:373: value `%Sppyns.Transactions.FundTransaction{__meta__: #Ecto.Schema.Metadata<:loaded, "fund_transactions">, amount: #Decimal<1>, fee: #Decimal<0.01>, fund: #Ecto.Association.NotLoaded<association :fund is not loaded>, fund_id: 3009, id: 1965, inserted_at: #DateTime<2019-06-28 18:10:26Z>, number_of_tokens: #Decimal<0.99>, operations: #Ecto.Association.NotLoaded<association :operations is not loaded>, transferred: nil, type: :invest, updated_at: #DateTime<2019-06-28 18:10:26Z>, user: #Ecto.Association.NotLoaded<association :user is not loaded>, user_id: 5457, valuations: #Ecto.Association.NotLoaded<association :valuations is not loaded>}` in `where` cannot be cast to type :id in query:
The text was updated successfully, but these errors were encountered:
@primary_key - configures the schema primary key. It expects a tuple {field_name, type, options} with the primary key field name, type (typically :id or :binary_id, but can be any type) and options. It also accepts false to disable the generation of a primary key field. Defaults to {:id, :id, autogenerate: true}.
So if anything can be a PK, I don't think it's possible to add any validation here
Add guard clauses to obtain better error messages.
For example,
get_with_assocs
passing the struct instead of ID givesThe text was updated successfully, but these errors were encountered: