diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b048abe..2d8787de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: - "1.11.4-erlang-21.3.8.24-alpine-3.13.3" mysql: - "5.7" + - "8.0" steps: - uses: earthly/actions-setup@v1 - uses: actions/checkout@v3 diff --git a/Earthfile b/Earthfile index 7c2163f4..2245a79f 100644 --- a/Earthfile +++ b/Earthfile @@ -110,7 +110,10 @@ integration-test-mysql: --pull "mysql:$MYSQL" RUN set -e; \ timeout=$(expr $(date +%s) + 30); \ - docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "mysql:$MYSQL" --sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES"; \ + docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "mysql:$MYSQL" \ + --sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES" \ + # the default authentication plugin for MySQL 8 is sha 256 but it doesn't come with the docker image. falling back to the 5.7 way + --default-authentication-plugin=mysql_native_password; \ # wait for mysql to start while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do \ test "$(date +%s)" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); \ diff --git a/integration_test/myxql/test_helper.exs b/integration_test/myxql/test_helper.exs index 23d1857d..84402f8a 100644 --- a/integration_test/myxql/test_helper.exs +++ b/integration_test/myxql/test_helper.exs @@ -19,12 +19,21 @@ Application.put_env(:ecto_sql, TestRepo, url: Application.get_env(:ecto_sql, :mysql_test_url) <> "/ecto_test", pool: Ecto.Adapters.SQL.Sandbox, show_sensitive_data_on_connection_error: true, + after_connect: {Ecto.Integration.TestRepo, :set_connection_charset, []}, log: false ) defmodule Ecto.Integration.TestRepo do use Ecto.Integration.Repo, otp_app: :ecto_sql, adapter: Ecto.Adapters.MyXQL + def set_connection_charset(conn) do + %{rows: [[version]]} = MyXQL.query!(conn, "SELECT @@version", []) + + if version >= "8.0.0" do + _ = MyXQL.query!(conn, "SET NAMES utf8mb4 COLLATE utf8mb4_0900_ai_ci;", []) + end + end + def create_prefix(prefix) do "create database #{prefix}" end