From 141d96ead97ebc3852452d4b617c1d120f6c8f6f Mon Sep 17 00:00:00 2001 From: whossname Date: Sat, 28 Sep 2019 14:16:29 +0800 Subject: [PATCH] run formatter --- .travis.yml | 4 +++- lib/connection/ddl.ex | 3 +-- test/mssql_ecto/constraint_test.exs | 7 ++----- test/mssql_ecto/create_table_test.exs | 24 ++++++++---------------- test/mssql_ecto/index_test.exs | 11 +++-------- test/mssql_ecto/migration_test.exs | 3 +-- test/mssql_ecto/select_test.exs | 4 ++-- test/mssql_ecto/update_all_test.exs | 2 +- 8 files changed, 21 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0beda07..bbd3d3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +sudo: required language: elixir elixir: @@ -7,9 +8,10 @@ services: - docker install: - - docker-compose build + - docker-compose build mssql_ecto script: + - docker-compose run mssql_ecto mix format --check-formatted - docker-compose run mssql_ecto mix compile --warnings-as-errors - docker-compose run mssql_ecto mix coveralls.travis diff --git a/lib/connection/ddl.ex b/lib/connection/ddl.ex index 48f336b..1533219 100644 --- a/lib/connection/ddl.ex +++ b/lib/connection/ddl.ex @@ -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) diff --git a/test/mssql_ecto/constraint_test.exs b/test/mssql_ecto/constraint_test.exs index f29c195..6f7a669 100644 --- a/test/mssql_ecto/constraint_test.exs +++ b/test/mssql_ecto/constraint_test.exs @@ -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) == [ @@ -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) == [ diff --git a/test/mssql_ecto/create_table_test.exs b/test/mssql_ecto/create_table_test.exs index 0b3795e..3f54e89 100644 --- a/test/mssql_ecto/create_table_test.exs +++ b/test/mssql_ecto/create_table_test.exs @@ -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]} @@ -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, diff --git a/test/mssql_ecto/index_test.exs b/test/mssql_ecto/index_test.exs index 218fa25..3d6de7f 100644 --- a/test/mssql_ecto/index_test.exs +++ b/test/mssql_ecto/index_test.exs @@ -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))|] @@ -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) == [ diff --git a/test/mssql_ecto/migration_test.exs b/test/mssql_ecto/migration_test.exs index c130aa9..7e39d59 100644 --- a/test/mssql_ecto/migration_test.exs +++ b/test/mssql_ecto/migration_test.exs @@ -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'| diff --git a/test/mssql_ecto/select_test.exs b/test/mssql_ecto/select_test.exs index 76b9c5d..dd32be7 100644 --- a/test/mssql_ecto/select_test.exs +++ b/test/mssql_ecto/select_test.exs @@ -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 @@ -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 diff --git a/test/mssql_ecto/update_all_test.exs b/test/mssql_ecto/update_all_test.exs index 27073e3..2007468 100644 --- a/test/mssql_ecto/update_all_test.exs +++ b/test/mssql_ecto/update_all_test.exs @@ -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]])