From 377fdbacbe3170039bfc1806881f9650c16251b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 21 Apr 2020 19:10:31 +0200 Subject: [PATCH] Remove cache_write_statements as it has no use case for now --- CHANGELOG.md | 3 +-- integration_test/myxql/test_helper.exs | 3 +-- integration_test/pg/test_helper.exs | 3 +-- integration_test/tds/test_helper.exs | 3 +-- lib/ecto/adapters/myxql.ex | 9 +-------- lib/ecto/adapters/postgres.ex | 5 ----- lib/ecto/adapters/sql.ex | 14 +++----------- lib/ecto/adapters/tds.ex | 5 ----- 8 files changed, 8 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4be3296b..68fcdab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ ### Bug fixes - * [ecto] Support `as` and `parent_as` from Ecto vv3.4.3+ - * [repo] Support `cache_write_statements: :per_schema | :per_operation` at the Repo configuration to control how write queries are cached + * [ecto] Support `as` and `parent_as` from Ecto v3.4.3+ ## v3.4.2 (2020-04-02) diff --git a/integration_test/myxql/test_helper.exs b/integration_test/myxql/test_helper.exs index 2b8756fe..383bda26 100644 --- a/integration_test/myxql/test_helper.exs +++ b/integration_test/myxql/test_helper.exs @@ -18,8 +18,7 @@ alias Ecto.Integration.TestRepo 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, - cache_write_statements: :per_schema + show_sensitive_data_on_connection_error: true ) defmodule Ecto.Integration.TestRepo do diff --git a/integration_test/pg/test_helper.exs b/integration_test/pg/test_helper.exs index aa4abef9..3064519b 100644 --- a/integration_test/pg/test_helper.exs +++ b/integration_test/pg/test_helper.exs @@ -18,8 +18,7 @@ alias Ecto.Integration.TestRepo Application.put_env(:ecto_sql, TestRepo, url: Application.get_env(:ecto_sql, :pg_test_url) <> "/ecto_test", pool: Ecto.Adapters.SQL.Sandbox, - show_sensitive_data_on_connection_error: true, - cache_write_statements: :per_schema + show_sensitive_data_on_connection_error: true ) defmodule Ecto.Integration.TestRepo do diff --git a/integration_test/tds/test_helper.exs b/integration_test/tds/test_helper.exs index 89637974..d9e54d8e 100644 --- a/integration_test/tds/test_helper.exs +++ b/integration_test/tds/test_helper.exs @@ -80,8 +80,7 @@ Application.put_env( url: Application.get_env(:ecto_sql, :tds_test_url) <> "/ecto_test", pool: Ecto.Adapters.SQL.Sandbox, set_allow_snapshot_isolation: :on, - show_sensitive_data_on_connection_error: true, - cache_write_statements: :per_schema + show_sensitive_data_on_connection_error: true ) defmodule Ecto.Integration.TestRepo do diff --git a/lib/ecto/adapters/myxql.ex b/lib/ecto/adapters/myxql.ex index b3f157a0..63470f3c 100644 --- a/lib/ecto/adapters/myxql.ex +++ b/lib/ecto/adapters/myxql.ex @@ -28,11 +28,6 @@ defmodule Ecto.Adapters.MyXQL do This option is only used for `mix ecto.load` and `mix ecto.dump`, via the `mysql` command. For more information, please check [MySQL docs](https://dev.mysql.com/doc/en/connecting.html) - * `:cache_write_statements` - how Ecto should cache INSERT/UPDATE/DELETE statements. - It defaults to `:per_schema` (one cache key is used for each schema) and - can be set to `:per_operation` (one cache key is use for each operation). - Note SELECTs use a more complete cache mechanism that considers the query - itself. * `:socket_options` - Specifies socket configuration * `:show_sensitive_data_on_connection_error` - show connection data and configuration whenever there is an error attempting to connect to the @@ -231,9 +226,7 @@ defmodule Ecto.Adapters.MyXQL do key = primary_key!(schema_meta, returning) {fields, values} = :lists.unzip(params) sql = @conn.insert(prefix, source, fields, [fields], on_conflict, []) - - cache_statement = Ecto.Adapters.SQL.cache_write_statements(adapter_meta, "insert", source) - opts = [{:cache_statement, cache_statement} | opts] + opts = [{:cache_statement, "ecto_insert_#{source}"} | opts] case Ecto.Adapters.SQL.query(adapter_meta, sql, values ++ query_params, opts) do {:ok, %{num_rows: 1, last_insert_id: last_insert_id}} -> diff --git a/lib/ecto/adapters/postgres.ex b/lib/ecto/adapters/postgres.ex index e2af7ee7..44ccf99f 100644 --- a/lib/ecto/adapters/postgres.ex +++ b/lib/ecto/adapters/postgres.ex @@ -40,11 +40,6 @@ defmodule Ecto.Adapters.Postgres do * `:ssl` - Set to true if ssl should be used (default: false) * `:ssl_opts` - A list of ssl options, see Erlang's `ssl` docs * `:parameters` - Keyword list of connection parameters - * `:cache_write_statements` - how Ecto should cache INSERT/UPDATE/DELETE statements. - It defaults to `:per_schema` (one cache key is used for each schema) and - can be set to `:per_operation` (one cache key is use for each operation). - Note SELECTs use a more complete cache mechanism that considers the query - itself. * `:connect_timeout` - The timeout for establishing new connections (default: 5000) * `:prepare` - How to prepare queries, either `:named` to use named queries or `:unnamed` to force unnamed queries (default: `:named`) diff --git a/lib/ecto/adapters/sql.ex b/lib/ecto/adapters/sql.ex index 5b9df439..ec7b8dc6 100644 --- a/lib/ecto/adapters/sql.ex +++ b/lib/ecto/adapters/sql.ex @@ -453,10 +453,9 @@ defmodule Ecto.Adapters.SQL do telemetry_prefix = Keyword.fetch!(config, :telemetry_prefix) telemetry = {config[:repo], log, telemetry_prefix ++ [:query]} - {cache_write_statements, config} = Keyword.pop(config, :cache_write_statements, :per_schema) config = adapter_config(config) opts = Keyword.take(config, @pool_opts) - meta = %{telemetry: telemetry, sql: connection, opts: opts, cache_write_statements: cache_write_statements} + meta = %{telemetry: telemetry, sql: connection, opts: opts} {:ok, connection.child_spec(config), meta} end @@ -490,13 +489,6 @@ defmodule Ecto.Adapters.SQL do ## Query - @doc false - def cache_write_statements(%{cache_write_statements: :per_schema}, operation, source), - do: "ecto_#{operation}_#{source}" - - def cache_write_statements(%{cache_write_statements: :per_operation}, operation, _source), - do: "ecto_#{operation}" - @doc false def insert_all(adapter_meta, schema_meta, conn, header, rows, on_conflict, returning, opts) do %{source: source, prefix: prefix} = schema_meta @@ -504,7 +496,7 @@ defmodule Ecto.Adapters.SQL do {rows, params} = unzip_inserts(header, rows) sql = conn.insert(prefix, source, header, rows, on_conflict, returning) - opts = [{:cache_statement, cache_write_statements(adapter_meta, "insert_all", source)} | opts] + opts = [{:cache_statement, "ecto_insert_all_#{source}"} | opts] %{num_rows: num, rows: rows} = query!(adapter_meta, sql, Enum.reverse(params) ++ conflict_params, opts) @@ -633,7 +625,7 @@ defmodule Ecto.Adapters.SQL do @doc false def struct(adapter_meta, conn, sql, operation, source, params, values, on_conflict, returning, opts) do - cache_statement = cache_write_statements(adapter_meta, operation, source) + cache_statement = "ecto_#{operation}_#{source}" case query(adapter_meta, sql, values, [cache_statement: cache_statement] ++ opts) do {:ok, %{rows: nil, num_rows: 1}} -> diff --git a/lib/ecto/adapters/tds.ex b/lib/ecto/adapters/tds.ex index 2c795812..66f1b964 100644 --- a/lib/ecto/adapters/tds.ex +++ b/lib/ecto/adapters/tds.ex @@ -18,11 +18,6 @@ defmodule Ecto.Adapters.Tds do * `:pool` - The connection pool module, defaults to `DBConnection.ConnectionPool` * `:ssl` - Set to true if ssl should be used (default: false) * `:ssl_opts` - A list of ssl options, see Erlang's `ssl` docs - * `:cache_write_statements` - how Ecto should cache INSERT/UPDATE/DELETE statements. - It defaults to `:per_schema` (one cache key is used for each schema) and - can be set to `:per_operation` (one cache key is use for each operation). - Note SELECTs use a more complete cache mechanism that considers the query - itself. * `:show_sensitive_data_on_connection_error` - show connection data and configuration whenever there is an error attempting to connect to the database