K2InformaticsGmbH / erloci

Erlang Oracle native driver - DEPRECATED, see https://github.com/K2InformaticsGmbH/oranif instead
Apache License 2.0
37 stars 11 forks source link

Problem with binding vars #21

Closed OpakAlex closed 8 years ago

OpakAlex commented 8 years ago

When i try insert some values to table, i have this error:

Assertion failed: ((*it).is_tuple() && (*it).length() == 3 && (*it)[0].is_binary() && (*it)[1].is_any_int() && (*it)[2].is_any_int()), function map_schema_to_bind_args, file c_src/erloci_drv/marshal.cpp, line 297.

My table: "CREATE TABLE \"schema_migrations\" (\"version\" NUMBER, \"inserted_at\" DATE)"

My insert:

"INSERT INTO \"schema_migrations\" (\"inserted_at\",\"version\") VALUES (:inserted_at, :version)"
[inserted_at: {{2016, 1, 6}, {14, 11, 39, 0}}, version: 0]
After mapping:
[{<<120, 116, 1, 6, 14, 11, 39>>, 0}]
OpakAlex commented 8 years ago

This happens when i send atoms not binary. This fixed. But i have another problem: {:error, {4280744, "Unsupported type in bind"}}

bind_args = [{":version", 'SQLT_INT'}, {":inserted_at", 'SQLT_DAT'}] args = [{<<120, 116, 1, 6, 15, 0, 12>>, 0}]

c-bik commented 8 years ago

Please try binaries as variable names.

Like:

bind_args = [{<<":version">>, 'SQLT_INT'}, {<<":inserted_at">>, 'SQLT_DAT'}]
args = [{0, <<120, 116, 1, 6, 15, 0, 12>>}]

Note: args also needs to match bind_args sequence

OpakAlex commented 8 years ago

Yes, i understand, also in elixir 'SQLT_INT' must be : SQLT_INT

c-bik commented 8 years ago

I have no elixir-fu :P. So, did it work?

I am curious. Is your plugin is in opensource already?

OpakAlex commented 8 years ago

we working on it. yes this bug fixed :) https://github.com/api-hogs/ecto-oracle