Skip to content

Commit

Permalink
[minor] Updating deps (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cλstor authored Jan 8, 2024
1 parent 7b36421 commit 72d353a
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 37 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ jobs:
runs-on: ubuntu-latest
env:
MIX_ENV: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
container:
image: elixir:1.14.4-alpine
image: hexpm/elixir:1.16.0-erlang-26.2.1-alpine-3.17.5
services:
ravendb:
image: ravendb/ravendb
Expand All @@ -24,9 +27,6 @@ jobs:
RAVEN_License_Eula_Accepted: "true"
RAVEN_Security_UnsecuredAccessAllowed: "PublicNetwork"
steps:
- uses: technote-space/auto-cancel-redundant-job@v1
with:
EXCLUDE_MERGED: "true"
- name: Install Git/Curl/GNU Tar
run: apk add --no-cache curl tar git make gcc libc-dev g++
- name: Fix git permissions
Expand All @@ -41,10 +41,10 @@ jobs:
path: |
_build
deps
key: ${{ runner.os }}-01-build-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-02-build-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-01-build-${{ hashFiles('mix.lock') }}
${{ runner.os }}-01-build-
${{ runner.os }}-02-build-${{ hashFiles('mix.lock') }}
${{ runner.os }}-02-build-
# - name: Dyalizer Cache
# uses: actions/cache@v3
# id: mix-dialyzer
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/hex-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
env:
MIX_ENV: dev
container:
image: elixir:1.14.4-alpine
image: hexpm/elixir:1.16.0-erlang-26.2.1-alpine-3.17.5
steps:
- name: Install Git/Curl/GNU Tar
run: apk add --no-cache curl tar git make gcc libc-dev g++
Expand All @@ -31,10 +31,10 @@ jobs:
path: |
_build
deps
key: ${{ runner.os }}-01-build-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-02-build-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-01-build-${{ hashFiles('mix.lock') }}
${{ runner.os }}-01-build-
${{ runner.os }}-02-build-${{ hashFiles('mix.lock') }}
${{ runner.os }}-02-build-
- name: Instal Mix and Rebar
run: mix local.hex --force && mix local.rebar --force
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion lib/ravix_ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ defmodule Ravix.Ecto.Adapter do

defdelegate update(repo, meta, fields, filters, returning, opts), to: @schema

defdelegate delete(adapter_meta, schema_meta, filters, options), to: @schema
defdelegate delete(adapter_meta, schema_meta, filters, returning, options), to: @schema

defdelegate storage_up(opts), to: @storage

Expand Down
34 changes: 34 additions & 0 deletions lib/ravix_ecto/adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,25 @@ defmodule Ravix.Ecto.Planner do
[type]
end

defp load_time(nil), do: {:ok, nil}
defp load_time(time), do: Time.from_iso8601(time)

defp load_date(nil), do: {:ok, nil}

defp load_date(date) do
date |> Date.from_iso8601()
end

defp load_naive_datetime(nil) do
{:ok, nil}
end

defp load_naive_datetime(datetime) when is_bitstring(datetime) do
{:ok, NaiveDateTime.from_iso8601!(datetime)}
end

defp load_datetime(nil), do: {:ok, nil}

defp load_datetime(datetime) when is_bitstring(datetime) do
{:ok, utc_date_time, _} = DateTime.from_iso8601(datetime)
{:ok, utc_date_time}
Expand All @@ -90,6 +99,10 @@ defmodule Ravix.Ecto.Planner do
{:ok, map}
end

defp load_binary(nil, _) do
{:ok, nil}
end

defp load_binary(binary, :ecto_uuid) do
Ecto.UUID.dump(binary)
end
Expand All @@ -111,6 +124,12 @@ defmodule Ravix.Ecto.Planner do
{:ok, id}
end

defp load_id(nil) do
{:ok, nil}
end

def load_decimal(nil), do: {:ok, nil}

def load_decimal(decimal) do
Decimal.cast(decimal)
end
Expand All @@ -129,10 +148,13 @@ defmodule Ravix.Ecto.Planner do
def dumpers(:decimal, type), do: [type, &dump_decimal/1]
def dumpers(_base, type), do: [type]

defp dump_time(nil), do: {:ok, nil}
defp dump_time({h, m, s, _}), do: Time.from_erl({h, m, s})
defp dump_time(%Time{} = time), do: {:ok, time}
defp dump_time(_), do: :error

defp dump_date(nil), do: {:ok, nil}

defp dump_date({_, _, _} = date) do
dt =
{date, {0, 0, 0}}
Expand All @@ -146,6 +168,8 @@ defmodule Ravix.Ecto.Planner do
{:ok, date}
end

defp dump_utc_datetime(nil), do: {:ok, nil}

defp dump_utc_datetime({{_, _, _} = date, {h, m, s, ms}}) do
datetime =
{date, {h, m, s}}
Expand All @@ -168,6 +192,8 @@ defmodule Ravix.Ecto.Planner do
{:ok, datetime}
end

defp dump_naive_datetime(nil), do: {:ok, nil}

defp dump_naive_datetime({{_, _, _} = date, {h, m, s, ms}}) do
datetime =
{date, {h, m, s}}
Expand All @@ -193,6 +219,8 @@ defmodule Ravix.Ecto.Planner do
{:ok, datetime}
end

defp dump_binary(nil, _), do: {:ok, nil}

defp dump_binary(binary, :ecto_uuid) when is_binary(binary) do
Ecto.UUID.load(binary)
end
Expand All @@ -201,14 +229,20 @@ defmodule Ravix.Ecto.Planner do
{:ok, Enum.join(for <<c::utf8 <- binary>>, do: <<c::utf8>>)}
end

defp dump_objectid(nil), do: {:ok, nil}

defp dump_objectid(objectid) do
{:ok, objectid}
end

defp dump_id(nil), do: {:ok, nil}

defp dump_id(id) when is_integer(id) do
{:ok, id}
end

def dump_decimal(nil), do: {:ok, nil}

def dump_decimal(decimal) when is_number(decimal) do
{:ok, Integer.to_string(decimal)}
end
Expand Down
7 changes: 4 additions & 3 deletions lib/ravix_ecto/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule Ravix.Ecto.Schema do
end

@impl Ecto.Adapter.Schema
def delete(adapter_meta, %{schema: schema}, filters, _options) do
def delete(adapter_meta, %{schema: schema}, filters, _returning, _options) do
pk = primary_key(schema)

case Executor.delete_one(adapter_meta, filters, pk) do
Expand All @@ -74,9 +74,10 @@ defmodule Ravix.Ecto.Schema do

@impl Ecto.Adapter.Schema
def autogenerate(:binary_id), do: UUID.uuid4()
def autogenerate(:embed_id),do: UUID.uuid4()
def autogenerate(:id), do: raise "[RAVIX-ECTO] RavenDB does not support auto-generated integer ids!"
def autogenerate(:embed_id), do: UUID.uuid4()

def autogenerate(:id),
do: raise("[RAVIX-ECTO] RavenDB does not support auto-generated integer ids!")

defp returning_fields_for_list(_adapter_meta, _schema_meta, _result, [], _primary_key, _opts),
do: nil
Expand Down
Loading

0 comments on commit 72d353a

Please sign in to comment.