findmypast-oss / mssql_ecto

Ecto adapter for Mssqlex
Apache License 2.0
49 stars 20 forks source link

Column type not supported | ODBC_CODE | SQL_SERVER_CODE 0 using type uniqueidentifier #32

Closed ruben44bac closed 6 years ago

ruben44bac commented 6 years ago

In my database i have a table with column pruebauuid uniqueidentifier and in my schema used type :binary_id or :uuid or Ecto.UUID but always have same problem

Expected Behavior

Hi I have a problem to use type uniqueidentifier. In my database i have a table with column pruebauuid uniqueidentifier and in my schema used type :binary_id or :uuid or Ecto.UUID but always have same problem

Column type not supported | ODBC_CODE | SQL_SERVER_CODE 0

lib/ecto/adapters/sql.ex

431 case sql_call(repo, :prepare_execute, [name, prepared], params, mapper, opts) do
432 {:ok, query, %{num_rows: num, rows: rows}} ->
433 update.({id, query})
434 {num, rows}
435 {:error, err} ->
436 raise err
437 end
438 end
439
440 defp execute_or_reset(repo, id, reset, cached, params, mapper, opts) do
441 case sql_call(repo, :execute, [cached], params, mapper, opts) do

Steps to Reproduce (for bugs)

1.

mix.ex

def application do
    [
      mod: {PruebaBien.Application, []},
      extra_applications: [:logger, :runtime_tools, :mssqlex, :mssql_ecto]
    ]
  end
defp deps do
    [
      {:phoenix, "~> 1.3.0"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.2"},
      {:mssql_ecto, "~> 0.3.1"},
      {:mssqlex, "~> 0.8.0"},
      {:phoenix_html, "~> 2.10"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:cowboy, "~> 1.0"},
      {:ex_doc, "~> 0.12"},
      { :uuid, "~> 1.1" }
    ]
  end

2.

usuario.ex

defmodule Usuario do
    use Ecto.Schema
      import Ecto
      import Ecto.Changeset
      import Ecto.Query
    schema "usuario" do
        field :nombre, :string
        field :valor, :integer
        field :pruebauuid, Ecto.UUID
    end
    def changeset(struct, params) do
        struct
            |> cast(params, [:nombre, :valor])
            |> validate_required(:nombre)
    end
end

3.

table sql

create table usuario(
 id int auto_increment,
nombre varchar(50),
valor int,
pruebauuid uniqueidentifier,
primary key(id)
)
  1. mix phx.server

Context

All database tables have type uniqueidentifier how primary key or other attribute. I need use uniqueidentifier type

Your Environment

Extra information

file_system 0.2.2 connection 1.0.4 gettext 0.14.0 ranch 1.3.2 poolboy 1.5.1 decimal 1.4.1 poison 3.1.0 earmark 1.2.4 ex_doc 0.18.1 db_connection 1.1.2 ecto 2.1.6 phoenix_pubsub 1.0.2 cowlib 1.0.2 cowboy 1.1.2 uuid 1.1.8 mime 1.2.0 plug 1.4.3 phoenix_html 2.10.5 phoenix 1.3.0 phoenix_live_reload 1.1.3 mssqlex 0.8.0 mssql_ecto 0.3.1 phoenix_ecto 3.3.0

shdblowers commented 6 years ago

Hi @ruben44bac, thanks for taking the time to open an issue.

This issue is a duplicate of #20.

Please refer there for more information.