From 30eb86ea72c8a884ed9c972bb304554bd2802bb8 Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Mon, 13 Dec 2021 15:39:50 +0200 Subject: [PATCH 1/9] lob locator unimplemented yet --- src/jamdb_oracle_tns_decoder.erl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/jamdb_oracle_tns_decoder.erl b/src/jamdb_oracle_tns_decoder.erl index 06ad60c..d867ef8 100644 --- a/src/jamdb_oracle_tns_decoder.erl +++ b/src/jamdb_oracle_tns_decoder.erl @@ -663,6 +663,13 @@ lid(N,I,Acc) -> lid(N bsr 6 band 67108863,I-1,[H|Acc]). decode_clob(Data) -> + A = decode_next(ub4,Data), + case decode_ub1(A) of + 114 -> {[], decode_next(A)}; %LobLocator + _ -> decode_clob_value(Data) + end. + +decode_clob_value(Data) -> A = decode_next(ub4,Data), B = decode_next(ub4,A), %LobSize C = decode_next(ub4,B), %LobChunkSize @@ -679,6 +686,13 @@ decode_clob(Data) -> {Value, decode_next(G)}. decode_blob(Data) -> + A = decode_next(ub4,Data), + case decode_ub1(A) of + 114 -> {[], decode_next(A)}; %LobLocator + _ -> decode_blob_value(Data) + end. + +decode_blob_value(Data) -> A = decode_next(ub4,Data), B = decode_next(ub4,A), %LobSize C = decode_next(ub4,B), %LobChunkSize From 4ef074d74893fd8872e99c46d48ecd6ab5529dc7 Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Mon, 13 Dec 2021 15:40:56 +0200 Subject: [PATCH 2/9] Update jamdb_oracle.erl --- src/jamdb_oracle.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jamdb_oracle.erl b/src/jamdb_oracle.erl index 1e0cf29..82c64a5 100644 --- a/src/jamdb_oracle.erl +++ b/src/jamdb_oracle.erl @@ -1,5 +1,5 @@ -module(jamdb_oracle). --vsn("0.4.9"). +-vsn("0.5.0"). -behaviour(gen_server). %% API From c6ad60caa7d6f430de80f17d0cb5c3e10a25a67e Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Mon, 13 Dec 2021 15:41:13 +0200 Subject: [PATCH 3/9] Update jamdb_oracle.app.src --- src/jamdb_oracle.app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jamdb_oracle.app.src b/src/jamdb_oracle.app.src index 7841ef7..e726137 100644 --- a/src/jamdb_oracle.app.src +++ b/src/jamdb_oracle.app.src @@ -1,6 +1,6 @@ {application, jamdb_oracle, [ {description, "Erlang driver for Oracle"}, - {vsn, "0.4.9"}, + {vsn, "0.5.0"}, {modules, []}, {registered, []}, {applications, [kernel,stdlib]}, From 3ec671826de444ed9bcfec06a68c47c0a45b4617 Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Mon, 4 Apr 2022 16:30:40 +0300 Subject: [PATCH 4/9] fix naive_datetime_usec utc_datetime_usec --- lib/jamdb_oracle.ex | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/jamdb_oracle.ex b/lib/jamdb_oracle.ex index 6c8d155..cb92a00 100644 --- a/lib/jamdb_oracle.ex +++ b/lib/jamdb_oracle.ex @@ -1,5 +1,5 @@ defmodule Jamdb.Oracle do - @vsn "0.4.12" + @vsn "0.5.0" @moduledoc """ Adapter module for Oracle. `DBConnection` behaviour implementation. @@ -297,8 +297,18 @@ defimpl DBConnection.Query, for: Jamdb.Oracle.Query do defp encode(true), do: "1" defp encode(false), do: "0" defp encode(%Decimal{} = decimal), do: Decimal.to_float(decimal) - defp encode(%DateTime{} = datetime), do: NaiveDateTime.to_erl(DateTime.to_naive(datetime)) - defp encode(%NaiveDateTime{} = naive), do: NaiveDateTime.to_erl(naive) + defp encode(%DateTime{microsecond: {0, 0}} = datetime), + do: NaiveDateTime.to_erl(DateTime.to_naive(datetime)) + defp encode(%DateTime{microsecond: {ms, _}} = datetime) do + {date, {hour, min, sec}} = NaiveDateTime.to_erl(DateTime.to_naive(datetime)) + {date, {hour, min, sec, ms}} + end + defp encode(%NaiveDateTime{microsecond: {0, 0}} = naive), + do: NaiveDateTime.to_erl(naive) + defp encode(%NaiveDateTime{microsecond: {ms, _}} = naive) do + {date, {hour, min, sec}} = NaiveDateTime.to_erl(naive) + {date, {hour, min, sec, ms}} + end defp encode(%Date{} = date), do: Date.to_erl(date) defp encode(%Ecto.Query.Tagged{value: elem, type: :binary}) when is_binary(elem), do: elem defp encode(elem) when is_binary(elem), do: Jamdb.Oracle.to_list(elem) From 6ee3e725390b9126d0c1acbe26913dbdda0825e4 Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Tue, 5 Apr 2022 20:04:04 +0300 Subject: [PATCH 5/9] Update jamdb_oracle_tns_encoder.erl --- src/jamdb_oracle_tns_encoder.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jamdb_oracle_tns_encoder.erl b/src/jamdb_oracle_tns_encoder.erl index 3f53780..34e36ca 100644 --- a/src/jamdb_oracle_tns_encoder.erl +++ b/src/jamdb_oracle_tns_encoder.erl @@ -318,7 +318,7 @@ encode_token(oac, DataType, Length, Flag, Charset, Max) -> 3, %flg 0, %pre 0, %data scale - (encode_sb4(Length))/binary, %max data lenght + (encode_sb4(Length))/binary, %max data length 0, %mal (encode_sb4(Flag))/binary, %fl2 0, %toid From 78f6dfc9e87111200cadd85de4117ec70c1b9a92 Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Tue, 5 Apr 2022 20:08:50 +0300 Subject: [PATCH 6/9] Update jamdb_oracle_tns_decoder.erl --- src/jamdb_oracle_tns_decoder.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jamdb_oracle_tns_decoder.erl b/src/jamdb_oracle_tns_decoder.erl index d867ef8..0cb719e 100644 --- a/src/jamdb_oracle_tns_decoder.erl +++ b/src/jamdb_oracle_tns_decoder.erl @@ -82,7 +82,7 @@ decode_token(oac, Data) -> Scale = decode_ub2(C), D = decode_next(ub2,C), %data scale Length = decode_ub4(D), - E = decode_next(ub4,D), %max data lenght + E = decode_next(ub4,D), %max data length F = decode_next(ub4,E), %mal G = decode_next(ub4,F), %fl2 J = decode_next(dalc,G), %toid @@ -314,7 +314,7 @@ decode_next(rxh,Data) -> B = decode_next(ub2,A), %Number of Requests C = decode_next(ub2,B), %Iteration Number D = decode_next(ub2,C), %Num. Iterations this time - E = decode_next(ub2,D), %UAC bufffer length + E = decode_next(ub2,D), %UAC buffer length F = decode_next(dalc,E), %Bitvec decode_next(dalc,F); decode_next(rpa,Data) -> From 1e6ca8bf541295f47f500ff7a8587e6eb7ba057e Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Thu, 28 Apr 2022 08:01:37 +0300 Subject: [PATCH 7/9] Update jamdb_oracle.ex --- lib/jamdb_oracle.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jamdb_oracle.ex b/lib/jamdb_oracle.ex index cb92a00..2a91206 100644 --- a/lib/jamdb_oracle.ex +++ b/lib/jamdb_oracle.ex @@ -204,7 +204,7 @@ defmodule Jamdb.Oracle do {mode, s} end - @impl false + @doc false def checkin(s) do {:ok, s} end From e480c1b1cbfeadcf96fbd6eb78aa42a2f42e97dd Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Thu, 28 Apr 2022 08:03:38 +0300 Subject: [PATCH 8/9] Update jamdb_oracle_ecto.ex --- lib/jamdb_oracle_ecto.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/jamdb_oracle_ecto.ex b/lib/jamdb_oracle_ecto.ex index acd96ca..2384f8b 100644 --- a/lib/jamdb_oracle_ecto.ex +++ b/lib/jamdb_oracle_ecto.ex @@ -106,6 +106,11 @@ defmodule Ecto.Adapters.Jamdb.Oracle.Connection do end end + @impl true + def query_many(_conn, _query, _params, _opts) do + error!(nil, "query_many is not supported") + end + @impl true def explain_query(conn, query, params, opts) do case query(conn, IO.iodata_to_binary(["EXPLAIN PLAN FOR ", query]), params, opts) do @@ -121,6 +126,10 @@ defmodule Ecto.Adapters.Jamdb.Oracle.Connection do query end + defp error!(nil, msg) do + raise ArgumentError, msg + end + defdelegate all(query), to: Jamdb.Oracle.Query defdelegate update_all(query), to: Jamdb.Oracle.Query defdelegate delete_all(query), to: Jamdb.Oracle.Query From 603b3f99a3e4fae9d37b78f5c23439b97843c4fe Mon Sep 17 00:00:00 2001 From: Mykhailo Vstavskyi Date: Thu, 28 Apr 2022 08:05:26 +0300 Subject: [PATCH 9/9] Bump to 0.5.0 --- mix.exs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index b8fbdc9..9d3b93c 100644 --- a/mix.exs +++ b/mix.exs @@ -3,8 +3,8 @@ defmodule Jamdb.Oracle.Mixfile do def project do [app: :jamdb_oracle, - version: "0.4.12", - elixir: "~> 1.8", + version: "0.5.0", + elixir: "~> 1.10", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, description: description(), @@ -14,7 +14,7 @@ defmodule Jamdb.Oracle.Mixfile do defp deps do [ - {:ecto_sql, "~> 3.7"}, + {:ecto_sql, "~> 3.8"}, {:ex_doc, "~> 0.21", only: :docs} ] end