Skip to content

Ecto 3 support#3

Open
blatyo wants to merge 2 commits into100Starlings:masterfrom
blatyo:ecto3
Open

Ecto 3 support#3
blatyo wants to merge 2 commits into100Starlings:masterfrom
blatyo:ecto3

Conversation

@blatyo
Copy link
Copy Markdown

@blatyo blatyo commented Nov 4, 2019

Started trying to upgrade this to Ecto 3. I've got 4 tests failing with these changes. Haven't attempted to run the integration tests yet.


# Inherit all behaviour from Ecto.Adapters.SQL
use Ecto.Adapters.SQL, :postgrex
use Ecto.Adapters.SQL, driver: :postgrex, migration_lock: nil
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migration_lock is intended to create a read lock on the schema migrations table so that migrations can be run concurrently, but only one runner proceeds. For postgres and mysql, it uses FOR UPDATE as in SELECT * FROM schema_migrations FOR UPDATE. I didn't check if redshift has something equivalent.

current =
case elem(sources, pos) do
{table, schema} ->
{table, schema, _alias} ->
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ecto 3 allows naming for bindings. I believe that's what the third argument is, but it'll need to be double checked.


defp default_expr({:ok, %{} = map}, :map) do
default = Ecto.Adapter.json_library().encode!(map)
default = json_library().encode!(map)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ecto 3 got rid of this method and instead tells you to configure postgrex with the json library. I went with just using the postgrex configured one for now.

{:ecto, "~> 2.2"},
{:postgrex, "~> 0.13"},
{:ecto_replay_sandbox, "~> 1.0.0"},
{:ecto_sql, "~> 3.2"},
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ecto 3 split into ecto and ecto_sql, ecto_sql pulls in both dependencies and contains the adapter code.

|> select([m], {m.id, ^true})
|> join(:inner, [], Schema2, fragment("?", ^true))
|> join(:inner, [], Schema2, fragment("?", ^false))
|> join(:inner, [], Schema2, on: fragment("?", ^true))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

join now requires the on clause to be specified under the on: key


assert execute_ddl(create) == [
~s|CREATE TABLE "posts" ("a" varchar(max) DEFAULT '{"foo":"bar","baz":"boom"}')|
~s|CREATE TABLE "posts" ("a" varchar(max) DEFAULT '{"baz":"boom","foo":"bar"}')|
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON library produced a different order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant