From 410da84a669632256de4780b569437932c278036 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 19 Dec 2024 16:27:52 -0500 Subject: [PATCH] chore: format --- lib/data_layer.ex | 4 ++-- lib/migration_generator/migration_generator.ex | 6 +++--- lib/multitenancy.ex | 2 +- lib/repo/before_compile.ex | 2 +- lib/verifiers/validate_references.ex | 2 +- mix.exs | 1 + test/support/repo_case.ex | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/data_layer.ex b/lib/data_layer.ex index 2e7cc0ea..4614dd44 100644 --- a/lib/data_layer.ex +++ b/lib/data_layer.ex @@ -1171,7 +1171,8 @@ defmodule AshPostgres.DataLayer do end |> case do {:ok, through_query} -> - through_query = Ecto.Query.exclude(through_query, :select) + through_query = Ecto.Query.exclude(through_query, :select) + if query.__ash_bindings__[:__order__?] do subquery = subquery( @@ -1201,7 +1202,6 @@ defmodule AshPostgres.DataLayer do ) ) - {:ok, from(source in data_layer_query, where: field(source, ^source_attribute) in ^source_values, diff --git a/lib/migration_generator/migration_generator.ex b/lib/migration_generator/migration_generator.ex index 6c58be70..3f3dd5bf 100644 --- a/lib/migration_generator/migration_generator.ex +++ b/lib/migration_generator/migration_generator.ex @@ -177,7 +177,7 @@ defmodule AshPostgres.MigrationGenerator do |> Path.join(repo_name) |> Path.join("extensions.json") - unless opts.dry_run || opts.check do + if !(opts.dry_run || opts.check) do File.rename(legacy_snapshot_file, snapshot_file) end @@ -1027,7 +1027,7 @@ defmodule AshPostgres.MigrationGenerator do end defp create_new_snapshot(snapshots, repo_name, opts, tenant?) do - unless opts.dry_run do + if !opts.dry_run do Enum.each(snapshots, fn snapshot -> snapshot_binary = snapshot_to_binary(snapshot) @@ -2868,7 +2868,7 @@ defmodule AshPostgres.MigrationGenerator do configured_reference = configured_reference(resource, table, attribute.source || attribute.name, relationship) - unless Map.get(configured_reference, :ignore?) do + if !Map.get(configured_reference, :ignore?) do destination_attribute = Ash.Resource.Info.attribute( relationship.destination, diff --git a/lib/multitenancy.ex b/lib/multitenancy.ex index fbae77fe..505c9cb0 100644 --- a/lib/multitenancy.ex +++ b/lib/multitenancy.ex @@ -90,7 +90,7 @@ defmodule AshPostgres.MultiTenancy do end defp validate_tenant_name!(tenant_name) do - unless Regex.match?(@tenant_name_regex, tenant_name) do + if !Regex.match?(@tenant_name_regex, tenant_name) do raise "Tenant name must match #{inspect(@tenant_name_regex)}, got: #{tenant_name}" end end diff --git a/lib/repo/before_compile.ex b/lib/repo/before_compile.ex index a53f96d0..c2e9a310 100644 --- a/lib/repo/before_compile.ex +++ b/lib/repo/before_compile.ex @@ -3,7 +3,7 @@ defmodule AshPostgres.Repo.BeforeCompile do defmacro __before_compile__(_env) do quote do - unless Module.defines?(__MODULE__, {:min_pg_version, 0}, :def) do + if !Module.defines?(__MODULE__, {:min_pg_version, 0}, :def) do IO.warn(""" Please define `min_pg_version/0` in repo module: #{inspect(__MODULE__)} diff --git a/lib/verifiers/validate_references.ex b/lib/verifiers/validate_references.ex index 0bb6955c..3f2c90aa 100644 --- a/lib/verifiers/validate_references.ex +++ b/lib/verifiers/validate_references.ex @@ -7,7 +7,7 @@ defmodule AshPostgres.Verifiers.ValidateReferences do dsl |> AshPostgres.DataLayer.Info.references() |> Enum.each(fn reference -> - unless Ash.Resource.Info.relationship(dsl, reference.relationship) do + if !Ash.Resource.Info.relationship(dsl, reference.relationship) do raise Spark.Error.DslError, path: [:postgres, :references, reference.relationship], module: Verifier.get_persisted(dsl, :module), diff --git a/mix.exs b/mix.exs index be1f9f54..ec2ef870 100644 --- a/mix.exs +++ b/mix.exs @@ -237,6 +237,7 @@ defmodule AshPostgres.MixProject do "spark.replace_doc_links", "spark.cheat_sheets_in_search" ], + format: "format --migrate", "spark.formatter": "spark.formatter --extensions AshPostgres.DataLayer", "spark.cheat_sheets": "spark.cheat_sheets --extensions AshPostgres.DataLayer", "spark.cheat_sheets_in_search": diff --git a/test/support/repo_case.ex b/test/support/repo_case.ex index f4b535c9..28d9f3d2 100644 --- a/test/support/repo_case.ex +++ b/test/support/repo_case.ex @@ -19,7 +19,7 @@ defmodule AshPostgres.RepoCase do setup tags do :ok = Sandbox.checkout(AshPostgres.TestRepo) - unless tags[:async] do + if !tags[:async] do Sandbox.mode(AshPostgres.TestRepo, {:shared, self()}) end