Skip to content

Commit

Permalink
no parenthesis on ecto DSL function + assert_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmonjo committed Mar 10, 2018
1 parent 4096ed3 commit 64661f3
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 137 deletions.
34 changes: 33 additions & 1 deletion .formatter.exs
@@ -1,4 +1,36 @@
# Used by "mix format"
[
inputs: ["mix.exs", "{config,lib,test,examples}/**/*.{ex,exs}"]
inputs: [
"mix.exs",
".formatter.exs",
"{config,lib,test,examples}/**/*.{ex,exs}"
],
locals_without_parens: [
# Query
from: 2,

# Schema
field: 1,
field: 2,
field: 3,
timestamps: 0,
timestamps: 1,
belongs_to: 2,
belongs_to: 3,
has_one: 2,
has_one: 3,
has_many: 2,
has_many: 3,
many_to_many: 2,
many_to_many: 3,
embeds_one: 2,
embeds_one: 3,
embeds_one: 4,
embeds_many: 2,
embeds_many: 3,
embeds_many: 4,

# Test assertion
assert_fields: 2
]
]
12 changes: 5 additions & 7 deletions examples/simple/lib/simple.ex
Expand Up @@ -21,10 +21,10 @@ defmodule Weather do
@primary_key {:id, :binary_id, autogenerate: true}

schema "weather" do
field(:city, :string)
field(:temp_lo, :integer)
field(:temp_hi, :integer)
field(:prcp, :float, default: 0.0)
field :city, :string
field :temp_lo, :integer
field :temp_hi, :integer
field :prcp, :float, default: 0.0
timestamps
end
end
Expand All @@ -34,11 +34,9 @@ defmodule Simple do

def sample_query do
query =
from(
w in Weather,
from w in Weather,
where: w.prcp > 0.0 or is_nil(w.prcp),
select: w
)

Simple.Repo.all(query)
end
Expand Down
1 change: 0 additions & 1 deletion lib/mongo_ecto.ex
Expand Up @@ -542,7 +542,6 @@ defmodule Mongo.Ecto do
}}
end


# Copy from the Elixir 1.4.5. TODO: Replace with native methods, when we stick on ~> 1.4.
# Source: https://github.com/elixir-lang/elixir/blob/v1.4/lib/elixir/lib/calendar.ex#L1477
defp datetime_from_naive!(naive_datetime, time_zone) do
Expand Down
6 changes: 3 additions & 3 deletions test/mongo_ecto/migrations_test.exs
Expand Up @@ -56,8 +56,8 @@ defmodule Mongo.Ecto.MigrationsTest do
use Ecto.Integration.Schema

schema "rename_migration" do
field(:to_be_renamed, :integer)
field(:was_renamed, :integer)
field :to_be_renamed, :integer
field :was_renamed, :integer
end
end

Expand Down Expand Up @@ -131,7 +131,7 @@ defmodule Mongo.Ecto.MigrationsTest do
assert :ok == up(TestRepo, 20_150_718_120_000, RenameColumnMigration, log: false)

assert {nil, 1} ==
TestRepo.one(from(p in RenameSchema, select: {p.to_be_renamed, p.was_renamed}))
TestRepo.one(from p in RenameSchema, select: {p.to_be_renamed, p.was_renamed})

:ok = down(TestRepo, 20_150_718_120_000, RenameColumnMigration, log: false)
end
Expand Down

0 comments on commit 64661f3

Please sign in to comment.