Skip to content

Commit

Permalink
run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
whossname committed Sep 28, 2019
1 parent 7c6a38e commit ca151c9
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sudo: required

language: elixir
elixir:
Expand All @@ -7,7 +8,7 @@ services:
- docker

install:
- docker-compose build
- docker-compose build mssql_ecto

script:
- docker-compose run mssql_ecto mix compile --warnings-as-errors
Expand Down
3 changes: 1 addition & 2 deletions lib/connection/ddl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ defmodule MssqlEcto.Connection.DDL do
defp ddl_log_level(_severity), do: :info

def table_exists_query(table) do
{"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ?",
[table]}
{"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ?", [table]}
end

# execute dll (all MSSQL from here on)
Expand Down
7 changes: 2 additions & 5 deletions test/mssql_ecto/constraint_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ defmodule MssqlEcto.ConstraintTest do
import Ecto.Migration, only: [constraint: 2, constraint: 3]

test "create check constraint" do
create =
{:create,
constraint(:products, "price_must_be_positive", check: "price > 0")}
create = {:create, constraint(:products, "price_must_be_positive", check: "price > 0")}

assert execute_ddl(create) ==
[
Expand Down Expand Up @@ -54,8 +52,7 @@ defmodule MssqlEcto.ConstraintTest do
~s|ALTER TABLE "products" DROP CONSTRAINT "price_must_be_positive"|
]

drop =
{:drop, constraint(:products, "price_must_be_positive", prefix: "foo")}
drop = {:drop, constraint(:products, "price_must_be_positive", prefix: "foo")}

assert execute_ddl(drop) ==
[
Expand Down
24 changes: 8 additions & 16 deletions test/mssql_ecto/create_table_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ defmodule MssqlEcto.CreateTableTest do
{:create, table(:posts),
[
{:add, :name, :string, [default: "Untitled", size: 20, null: false]},
{:add, :price, :numeric,
[precision: 8, scale: 2, default: {:fragment, "expr"}]},
{:add, :price, :numeric, [precision: 8, scale: 2, default: {:fragment, "expr"}]},
{:add, :on_hand, :integer, [default: 0, null: true]},
{:add, :published_at, :"time without time zone", [null: true]},
{:add, :is_active, :boolean, [default: true]}
Expand Down Expand Up @@ -48,22 +47,15 @@ defmodule MssqlEcto.CreateTableTest do
[
{:add, :id, :serial, [primary_key: true]},
{:add, :category_0, %Reference{table: :categories}, []},
{:add, :category_1, %Reference{table: :categories, name: :foo_bar},
[]},
{:add, :category_2,
%Reference{table: :categories, on_delete: :nothing}, []},
{:add, :category_3,
%Reference{table: :categories, on_delete: :delete_all},
{:add, :category_1, %Reference{table: :categories, name: :foo_bar}, []},
{:add, :category_2, %Reference{table: :categories, on_delete: :nothing}, []},
{:add, :category_3, %Reference{table: :categories, on_delete: :delete_all},
[null: false]},
{:add, :category_4,
%Reference{table: :categories, on_delete: :nilify_all}, []},
{:add, :category_5,
%Reference{table: :categories, on_update: :nothing}, []},
{:add, :category_6,
%Reference{table: :categories, on_update: :update_all},
{:add, :category_4, %Reference{table: :categories, on_delete: :nilify_all}, []},
{:add, :category_5, %Reference{table: :categories, on_update: :nothing}, []},
{:add, :category_6, %Reference{table: :categories, on_update: :update_all},
[null: false]},
{:add, :category_7,
%Reference{table: :categories, on_update: :nilify_all}, []},
{:add, :category_7, %Reference{table: :categories, on_update: :nilify_all}, []},
{:add, :category_8,
%Reference{
table: :categories,
Expand Down
11 changes: 3 additions & 8 deletions test/mssql_ecto/index_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ defmodule MssqlEcto.IndexTest do
~s|CREATE INDEX "posts_category_id_permalink_index" ON "foo"."posts" ("category_id", "permalink")|
]

create =
{:create,
index(:posts, ["lower(permalink)"], name: "posts$main", prefix: :foo)}
create = {:create, index(:posts, ["lower(permalink)"], name: "posts$main", prefix: :foo)}

assert execute_ddl(create) ==
[~s|CREATE INDEX "posts$main" ON "foo"."posts" (lower(permalink))|]
Expand Down Expand Up @@ -60,17 +58,14 @@ defmodule MssqlEcto.IndexTest do
end

test "create unique index with condition" do
create =
{:create,
index(:posts, [:permalink], unique: true, where: "public IS TRUE")}
create = {:create, index(:posts, [:permalink], unique: true, where: "public IS TRUE")}

assert execute_ddl(create) ==
[
~s|CREATE UNIQUE INDEX "posts_permalink_index" ON "posts" ("permalink") WHERE public IS TRUE|
]

create =
{:create, index(:posts, [:permalink], unique: true, where: :public)}
create = {:create, index(:posts, [:permalink], unique: true, where: :public)}

assert execute_ddl(create) ==
[
Expand Down
3 changes: 1 addition & 2 deletions test/mssql_ecto/migration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ defmodule MssqlEcto.MigrationTest do
end

test "rename table with prefix" do
rename =
{:rename, table(:posts, prefix: :foo), table(:new_posts, prefix: :foo)}
rename = {:rename, table(:posts, prefix: :foo), table(:new_posts, prefix: :foo)}

assert execute_ddl(rename) == [
~s|EXEC sp_rename 'foo.posts', 'new_posts', 'OBJECT'|
Expand Down
4 changes: 2 additions & 2 deletions test/mssql_ecto/select_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ defmodule MssqlEcto.SelectTest do
end

# TODO why was this skipped?
#@tag skip: "Not yet supported"
# @tag skip: "Not yet supported"
test "lock" do
query =
Schema
Expand Down Expand Up @@ -390,7 +390,7 @@ defmodule MssqlEcto.SelectTest do
query = Schema |> select([], fragment(title: 2))

assert_raise Ecto.QueryError, fn ->
parse(query)
parse(query)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/mssql_ecto/update_all_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ defmodule MssqlEcto.UpdateAllTest do
end

# TODO why was this skipped?
#@tag skip: "Arrays not supported"
# @tag skip: "Arrays not supported"
test "update all array ops" do
query =
from(m in Schema, update: [push: [w: 0]])
Expand Down

0 comments on commit ca151c9

Please sign in to comment.