Why I get ** (CaseClauseError) no case clause matching?

Although it seems straight forward, but I am missing something I need help with.
I am need to insert a record, my schema is:

defmodule ChatMessagePivot do
  use MyApp.Web, :model
  schema "chat_messages_pivot" do
    field :school_id, :integer
    field :parent_id, :integer
    field :class_room_id, :integer
    field :teacher_id, :integer
    field :message_id, :integer
    field :sender, :string
    field :date_time, Ecto.DateTime

then, if I try to insert into repo a new record as:

date_time= Ecto.DateTime.utc
chat_message_pivot= %ChatMessagePivot{sender: 1, class_room_id: 1, school_id: 1, parent_id: 1, teacher_id: 1, message_id: 1, date_time: date_time }

# now, if I try to insert record, I get error:
# no case clause matching: {{{2017, 9, 26}, {9, 55, 46, 0}}}

Any idea?

In those cases please post the full error message and stacktrace. Usually speaking, the more information you can give about the error, the easier it will be to provide guidance.

Thanks Jose, I’ve just discovered the error right after I posted the question, but I could not remove the question then.

Actually, that’s the full error I got, and stacktrace is mostly into my app.

The error was that the schema has date without time field, but I was trying to insert date with time.
I think Ecto error can be more meaningful in such case?

Please just post it anyway in the future, it’s more helpful than you seem to think.


Yea, will do, thank you.

1 Like