livehelpnow / tds_ecto

TDS Adapter for Ecto
57 stars 34 forks source link

Tds is unable to conver struct into supported MSSQL types #57

Closed gac closed 6 years ago

gac commented 6 years ago

hi, i have the next issue with SQL Server 2008 R2 and tds_ecto

In the database

CREATE TABLE [dbo].[table_test](

[total] [decimal](20, 6) NULL,

) ON [PRIMARY]

In the schema

defmodule MyApp.TableTest do use Ecto.Schema import Ecto.Query

@primary_key {:table_test_id, :id, autogenerate: true} schema "table_test" do field :total, :decimal end

end

When i execute

MyApp.Repo.insert(%MyApp.TableTest{total: 1})

or

MyApp.Repo.insert(%MyApp.TableTest{total: Decimal.new(1)})

I get the following error

** (Tds.Error) Tds is unable to conver struct into supported MSSQL types (tds_ecto) lib/tds_ecto/connection.ex:112: Tds.Ecto.Connection.prepare_param/1 (tds_ecto) lib/tds_ecto/connection.ex:41: anonymous fn/2 in Tds.Ecto.Connection.execute/4 (elixir) lib/enum.ex:1325: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3 (tds_ecto) lib/tds_ecto/connection.ex:40: Tds.Ecto.Connection.execute/4 (ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6 (ecto) lib/ecto/adapters/sql.ex:542: Ecto.Adapters.SQL.struct/8 (ecto) lib/ecto/repo/schema.ex:547: Ecto.Repo.Schema.apply/4 (ecto) lib/ecto/repo/schema.ex:213: anonymous fn/14 in Ecto.Repo.Schema.do_insert/4

The dependencies are:

connection 1.0.4 db_connection 1.1.3 decimal 1.4.1 ecto 2.2.8 poison 2.2.0 poolboy 1.5.1 postgrex 0.13.3 tds 1.0.11 tds_ecto 2.0.6

thank you very much for your time

mjaric commented 6 years ago

fixed in 2.0.7.

Thank you!