8000 varbinary to datetime2 conversion failure on non-required field · Issue #168 · elixir-ecto/tds · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
varbinary to datetime2 conversion failure on non-required field #168
Open
@jaybarra

Description

@jaybarra

#124 may be the same issue or related. I am getting an error trying to insert when a datetime2 field which has an explicit nil.

defmodule MinimalProof do

  alias MyRecord

  def proof_of_issue() do
    bulk_inserts = [
      %{
        my_date: nil # utc_datetime, optional in the schema
      }
    ]

    try do
      Repo.inse
5C07
rt_all(MyRecord, bulk_inserts)
    rescue
      err -> IO.puts("it fails in here because of #{inspect(err)}")
    end
  end
end
it fails in here because of %Tds.Error{message: nil, mssql: %{state: 3, number: 257, server_name: ".\\SQLEXPRESS", class: 16, msg_text: "Implicit conversion from data type varbinary to datetime2 is not allowed. Use the CONVERT function to run this query.", line_number: 1, proc_name: ""}}

I have a workaround now of dropping nil date fields from the inserts.

Environment and library versions

SQL Server 16
phoenix_ecto 4.6
ecto_sql 3.12
tds 2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0