Skip to content

Commit

Permalink
Update for ecto 3.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ukutaht committed Apr 26, 2021
1 parent b30ccc9 commit 1969f14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/clickhouse_ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ defmodule ClickhouseEcto do
@moduledoc false
@behaviour Ecto.Adapter.Storage

use Ecto.Adapters.SQL,
driver: :clickhousex,
migration_lock: "FOR UPDATE"
use Ecto.Adapters.SQL, driver: :clickhousex

alias ClickhouseEcto.Migration
alias ClickhouseEcto.Storage
Expand All @@ -27,6 +25,7 @@ defmodule ClickhouseEcto do

## Migration
def supports_ddl_transaction?, do: Migration.supports_ddl_transaction?()
def lock_for_migrations(meta, opts, fun), do: Migration.lock_for_migrations(meta, opts, fun)

## Storage
@impl Ecto.Adapter.Storage
Expand Down
5 changes: 4 additions & 1 deletion lib/clickhouse_ecto/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,12 @@ defmodule ClickhouseEcto.Connection do
@doc false
def delete_all(query), do: SQL.delete_all(query)

def insert(prefix, table, header, rows, on_conflict, returning),
def insert(prefix, table, header, rows, on_conflict, returning, []),
do: SQL.insert(prefix, table, header, rows, on_conflict, returning)

def insert(prefix, table, header, rows, on_conflict, returning, _placeholder),
do: raise("Clickhouse_ecto does not support placeholder in `insert_all`")

def update(prefix, table, fields, filters, returning),
do: SQL.update(prefix, table, fields, filters, returning)

Expand Down
9 changes: 9 additions & 0 deletions lib/clickhouse_ecto/migration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ defmodule ClickhouseEcto.Migration do

@drops [:drop, :drop_if_exists]

def lock_for_migrations(meta, _opts, fun) do
%{opts: adapter_opts} = meta
if Keyword.get(adapter_opts, :migration_lock) do
raise "Migration locks are not supported in clickhouse_ecto"
else
fun.()
end
end

@doc """
Receives a DDL command and returns a query that executes it.
"""
Expand Down

0 comments on commit 1969f14

Please sign in to comment.