Skip to content

Commit

Permalink
fix(format): adjust formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnylushington committed May 13, 2024
1 parent 6e0c555 commit 972b860
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/moebius/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,11 @@ defmodule Moebius.Query do
vals = Keyword.values(criteria)

first_available_param = length(cmd.params) + 1

{cols, _col_count} =
Enum.map_reduce(cols, first_available_param,
fn col, acc ->
{"#{col} = $#{acc}", acc + 1}
end)
Enum.map_reduce(cols, first_available_param, fn col, acc ->
{"#{col} = $#{acc}", acc + 1}
end)

params = cmd.params ++ vals
columns = Enum.join(cols, ", ")
Expand Down
6 changes: 2 additions & 4 deletions test/moebius/update_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ defmodule Moebius.UpdateTest do
assert cmd.params == ["test", "[email protected]"]
end


test "basic update with 'in' filter" do
names = ["Super", "Mike"]

cmd =
db(:users)
|> filter(:first, in: names)
Expand All @@ -56,19 +56,17 @@ defmodule Moebius.UpdateTest do
assert cmd.params == names ++ [["newrole"]]
end


test "basic update with '>' filter" do
cmd =
db(:users)
|> filter(:order_count, gt: 5)
|> update(roles: ["newrole"])

assert cmd.sql == "update users set roles = $2 where order_count > $1 returning *;"
assert length(cmd.params) == 2
assert cmd.params == [5, ["newrole"]]
end



# TODO: Move this to date tests

# test "it actually works" do
Expand Down

0 comments on commit 972b860

Please sign in to comment.