insert_allがcreated_datesを自動的に追加しないため、日時を入力しようとしていますが、何が間違っているのか分かりません。挿入時のEcto日時エラー
currentTime = DateTime.utc_now
query = from rm in ChatApp.Roles.RoleMasters,
join: srp in ChatApp.Servers.ServerTypeParameters,
where: srp.parameter_role_capable_flag == "Y",
select: %{role_master_id: rm.id, server_type_code: srp.server_type_code, parameter_namespace: srp.parameter_namespace,
parameter: srp.parameter, parameter_value: srp.parameter_default_value,
user_changeable_flag: "Y", description: srp.description,
active_flag: "Y", created_date: ^currentTime}
roleMasterRows = ChatApp.Repo.all(query)
ChatApp.Repo.insert_all(ChatApp.Roles.RoleMasterParameters, roleMasterRows)
私のエラーメッセージは次のようになります。insert_all
に ChatApp.Roles.RoleMasterParameters.created_date
ため
値
{{2017, 5, 10}, {20, 28, 42, 0}}
は、型が一致しません:ecto.schemaでutc_datetime
はそれがに日時を回しますタプルズ、しかし私はなぜそれが私の好きではないとして失われています。
私はEcto.Schemaコードを通過し、タプルが必要なように見えますが、明らかに何かがありがとう!ありがとう!
デフォルトのタイムスタンプは、()UTCでない移行とスキーマファイルで呼び出します。両方が同じであることを確認してください。マイグレーションファイルとスキーマファイルの 'timestamps(type::utc_datetime)' –
私はコメントを感謝しますが、私はすでにそれを修正しました!私はすでにEcto.Schemaクラスを使用していません。すでにタイプを変更するためにtimestamps_optsを変更するマクロを書きました。 –