Repository: phoenixframework/phoenix
Pull request #3098 (2018-10-14 23:08:55)

Readme fixes


Patch:
diff --git a/README.md b/README.md
index 40376d0fe..ac62e3383 100644
--- a/README.md
+++ b/README.md
@@ -52,13 +52,15 @@ $ cd ..
 $ MIX_ENV=docs mix docs
 ```
 
-To build phoenix from source:
+To build Phoenix from source:
+
 ```bash
 $ mix deps.get
 $ mix compile
 ```
 
-To build the phoenix installer from source
+To build the Phoenix installer from source:
+
 ```bash
 $ mix deps.get
 $ mix compile
diff --git a/guides/ecto.md b/guides/ecto.md
index 8d31700e5..4dd5f496a 100644
--- a/guides/ecto.md
+++ b/guides/ecto.md
@@ -471,7 +471,9 @@ defmodule HelloPhoenix.MixProject do
     [
       {:phoenix, "~> 1.3.0"},
       {:phoenix_pubsub, "~> 1.0"},
-      {:phoenix_ecto, "~> 3.2"},
+      {:phoenix_ecto, "~> 3.5"},
+      {:ecto, "~> 3.0-rc", override: true},
+      {:ecto_sql, "~> 3.0-rc", override: true},
       {:mariaex, ">= 0.0.0"},
       {:phoenix_html, "~> 2.10"},
       {:phoenix_live_reload, "~> 1.2-rc", only: :dev},
diff --git a/installer/templates/phx_single/config/config.exs b/installer/templates/phx_single/config/config.exs
index fa3fc582b..409ac2747 100644
--- a/installer/templates/phx_single/config/config.exs
+++ b/installer/templates/phx_single/config/config.exs
@@ -24,9 +24,8 @@ config :logger, :console,
   format: "$time $metadata[$level] $message\n",
   metadata: [:request_id]
 
-# Use Jason for JSON parsing in Phoenix<%= if ecto do %> and Ecto<% end %>
-config :phoenix, :json_library, Jason<%= if ecto do %>
-config :ecto, :json_library, Jason<% end %>
+# Use Jason for JSON parsing in Phoenix
+config :phoenix, :json_library, Jason
 
 # Import environment specific config. This must remain at the bottom
 # of this file so it overrides the configuration defined above.
diff --git a/installer/templates/phx_single/mix.exs b/installer/templates/phx_single/mix.exs
index f05477828..a9eeabc26 100644
--- a/installer/templates/phx_single/mix.exs
+++ b/installer/templates/phx_single/mix.exs
@@ -39,8 +39,10 @@ defmodule <%= app_module %>.MixProject do
     [
       <%= phoenix_dep %>,
       {:phoenix_pubsub, "~> 1.1"},<%= if ecto do %>
-      {:phoenix_ecto, "~> 3.2"},
-      {<%= inspect adapter_app %>, ">= 0.0.0"},<% end %><%= if html do %>
+      {:phoenix_ecto, "~> 3.5"},
+      {:ecto, "~> 3.0-rc", override: true},
+      {:ecto_sql, "~> 3.0-rc", override: true},
+      {<%= inspect adapter_app %>, ">= 0.0.0-rc"},<% end %><%= if html do %>
       {:phoenix_html, "~> 2.11"},
       {:phoenix_live_reload, "~> 1.2-rc", only: :dev},<% end %>
       {:gettext, "~> 0.11"},
diff --git a/installer/templates/phx_umbrella/apps/app_name/mix.exs b/installer/templates/phx_umbrella/apps/app_name/mix.exs
index 3a6b59bc1..3f9528820 100644
--- a/installer/templates/phx_umbrella/apps/app_name/mix.exs
+++ b/installer/templates/phx_umbrella/apps/app_name/mix.exs
@@ -36,8 +36,9 @@ defmodule <%= app_module %>.MixProject do
   # Type `mix help deps` for examples and options.
   defp deps do
     [<%= if ecto do %>
-      {:<%= adapter_app %>, ">= 0.0.0"},
-      {:ecto, "~> 2.2"}
+      {:<%= adapter_app %>, ">= 0.0.0-rc"},
+      {:ecto, "~> 3.0-rc", override: true},
+      {:ecto_sql, "~> 3.0-rc"},
     <% end %>]
   end
 
diff --git a/lib/mix/phoenix/schema.ex b/lib/mix/phoenix/schema.ex
index 129009785..26a2af9e2 100644
--- a/lib/mix/phoenix/schema.ex
+++ b/lib/mix/phoenix/schema.ex
@@ -32,9 +32,24 @@ defmodule Mix.Phoenix.Schema do
             context_app: nil,
             route_helper: nil
 
-  @valid_types [:integer, :float, :decimal, :boolean, :map, :string,
-                :array, :references, :text, :date, :time,
-                :naive_datetime, :utc_datetime, :uuid, :binary]
+  @valid_types [
+    :integer,
+    :float,
+    :decimal,
+    :boolean,
+    :map,
+    :string,
+    :array,
+    :references,
+    :text,
+    :date,
+    :time,
+    :naive_datetime,
+    :naive_datetime_usec,
+    :utc_datetime,
+    :uuid,
+    :binary
+  ]
 
   def valid_types, do: @valid_types
 
@@ -190,8 +205,9 @@ defmodule Mix.Phoenix.Schema do
         :date           -> %Date{year: 2010, month: 4, day: 17}
         :time           -> %Time{hour: 14, minute: 0, second: 0, microsecond: {0, 6}}
         :uuid           -> "7488a646-e31f-11e4-aace-600308960662"
-        :utc_datetime   -> "2010-04-17 14:00:00.000000Z"
-        :naive_datetime -> ~N[2010-04-17 14:00:00.000000]
+        :utc_datetime   -> "2010-04-17T14:00:00.000000Z"
+        :naive_datetime -> ~N[2010-04-17 14:00:00]
+        :naive_datetime_usec -> ~N[2010-04-17 14:00:00.000000]
         _               -> "some #{key}"
     end
   end
@@ -207,8 +223,9 @@ defmodule Mix.Phoenix.Schema do
         :date           -> %Date{year: 2011, month: 5, day: 18}
         :time           -> %Time{hour: 15, minute: 1, second: 1, microsecond: {0, 6}}
         :uuid           -> "7488a646-e31f-11e4-aace-600308960668"
-        :utc_datetime   -> "2011-05-18 15:01:01.000000Z"
-        :naive_datetime -> ~N[2011-05-18 15:01:01.000000]
+        :utc_datetime   -> "2011-05-18T15:01:01.000000Z"
+        :naive_datetime -> ~N[2011-05-18 15:01:01]
+        :naive_datetime_usec -> ~N[2011-05-18 15:01:01.000000]
         _               -> "some updated #{key}"
     end
   end


Test patch:
diff --git a/installer/test/phx_new_test.exs b/installer/test/phx_new_test.exs
index cadca0465..e554b7739 100644
--- a/installer/test/phx_new_test.exs
+++ b/installer/test/phx_new_test.exs
@@ -33,7 +33,6 @@ defmodule Mix.Tasks.Phx.NewTest do
       assert_file "phx_blog/config/config.exs", fn file ->
         assert file =~ "ecto_repos: [PhxBlog.Repo]"
         assert file =~ "config :phoenix, :json_library, Jason"
-        assert file =~ "config :ecto, :json_library, Jason"
         refute file =~ "namespace: PhxBlog"
         refute file =~ "config :phx_blog, :generators"
       end
@@ -177,7 +176,6 @@ defmodule Mix.Tasks.Phx.NewTest do
       assert_file "phx_blog/config/config.exs", fn file ->
         refute file =~ "config :phx_blog, :generators"
         refute file =~ "ecto_repos:"
-        refute file =~ "config :ecto, :json_library, Jason"
       end
 
       assert_file "phx_blog/config/dev.exs", fn file ->
diff --git a/installer/test/phx_new_umbrella_test.exs b/installer/test/phx_new_umbrella_test.exs
index 649d97d06..691013099 100644
--- a/installer/test/phx_new_umbrella_test.exs
+++ b/installer/test/phx_new_umbrella_test.exs
@@ -222,7 +222,6 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
       assert_file app_path(@app, "config/config.exs"), fn file ->
         refute file =~ "config :phx_blog_web, :generators"
         refute file =~ "ecto_repos:"
-        refute file =~ "config :ecto, :json_library, Jason"
       end
       assert_file web_path(@app, "config/config.exs"), fn file ->
         refute file =~ "config :phx_blog_web, :generators"
diff --git a/test/mix/phoenix_test.exs b/test/mix/phoenix_test.exs
index cb41e3580..c4b031ff4 100644
--- a/test/mix/phoenix_test.exs
+++ b/test/mix/phoenix_test.exs
@@ -75,7 +75,7 @@ defmodule Mix.PhoenixTest do
       name: "some name",
       date_of_birth: %Date{year: 2010, month: 4, day: 17},
       happy_hour: %Time{hour: 14, minute: 0, second: 0, microsecond: {0, 6}},
-      joined: %NaiveDateTime{year: 2010, month: 4, day: 17, hour: 14, minute: 0, second: 0, microsecond: {0, 6}},
+      joined: %NaiveDateTime{year: 2010, month: 4, day: 17, hour: 14, minute: 0, second: 0},
       token: "7488a646-e31f-11e4-aace-600308960662",
       other: "some other"
     }
diff --git a/test/mix/tasks/phx.gen.html_test.exs b/test/mix/tasks/phx.gen.html_test.exs
index 7151cd036..57651f6f7 100644
--- a/test/mix/tasks/phx.gen.html_test.exs
+++ b/test/mix/tasks/phx.gen.html_test.exs
@@ -39,6 +39,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
       Gen.Html.run(~w(Blog Post posts title slug:unique votes:integer cost:decimal
                       tags:array:text popular:boolean drafted_at:datetime
                       published_at:utc_datetime deleted_at:naive_datetime
+                      locked_at:naive_datetime_usec
                       secret:uuid announcement_date:date alarm:time
                       weight:float user_id:references:users))
 
@@ -47,14 +48,15 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
       assert_file "test/phoenix/blog/blog_test.exs", fn file ->
         assert file =~ "alarm: ~T[15:01:01.000000]"
         assert file =~ "announcement_date: ~D[2010-04-17]"
-        assert file =~ "deleted_at: ~N[2010-04-17 14:00:00.000000]"
+        assert file =~ "deleted_at: ~N[2010-04-17 14:00:00]"
+        assert file =~ "locked_at: ~N[2010-04-17 14:00:00.000000]"
         assert file =~ "cost: \"120.5\""
-        assert file =~ "published_at: \"2010-04-17 14:00:00.000000Z\""
+        assert file =~ "published_at: \"2010-04-17T14:00:00.000000Z\""
         assert file =~ "weight: 120.5"
 
         assert file =~ "assert post.announcement_date == ~D[2011-05-18]"
-        assert file =~ "assert post.deleted_at == ~N[2011-05-18 15:01:01.000000]"
-        assert file =~ "assert post.published_at == DateTime.from_naive!(~N[2011-05-18 15:01:01.000000Z], \"Etc/UTC\")"
+        assert file =~ "assert post.deleted_at == ~N[2011-05-18 15:01:01]"
+        assert file =~ "assert post.published_at == DateTime.from_naive!(~N[2011-05-18T15:01:01.000000Z], \"Etc/UTC\")"
         assert file =~ "assert post.alarm == ~T[15:01:01.000000]"
         assert file =~ "assert post.cost == Decimal.new(\"120.5\")"
         assert file =~ "assert post.weight == 120.5"
diff --git a/test/mix/tasks/phx.gen.json_test.exs b/test/mix/tasks/phx.gen.json_test.exs
index d124f7575..afee2e127 100644
--- a/test/mix/tasks/phx.gen.json_test.exs
+++ b/test/mix/tasks/phx.gen.json_test.exs
@@ -39,6 +39,7 @@ defmodule Mix.Tasks.Phx.Gen.JsonTest do
      Gen.Json.run(~w(Blog Post posts title slug:unique votes:integer cost:decimal
                      tags:array:text popular:boolean drafted_at:datetime
                      published_at:utc_datetime deleted_at:naive_datetime
+                     locked_at:naive_datetime_usec
                      secret:uuid announcement_date:date alarm:time
                      weight:float user_id:references:users))
 
@@ -58,10 +59,11 @@ defmodule Mix.Tasks.Phx.Gen.JsonTest do
                        "alarm" => "14:00:00.000000",
                        "announcement_date" => "2010-04-17",
                        "cost" => "120.5",
-                       "deleted_at" => "2010-04-17T14:00:00.000000",
-                       "drafted_at" => "2010-04-17T14:00:00.000000",
+                       "deleted_at" => "2010-04-17T14:00:00",
+                       "drafted_at" => "2010-04-17T14:00:00",
+                       "locked_at" => "2010-04-17T14:00:00.000000",
                        "popular" => true,
-                       "published_at" => "2010-04-17 14:00:00.000000Z",
+                       "published_at" => "2010-04-17T14:00:00.000000Z",
                        "secret" => "7488a646-e31f-11e4-aace-600308960662",
                        "slug" => "some slug",
                        "tags" => [],
diff --git a/test/mix/tasks/phx.gen.schema_test.exs b/test/mix/tasks/phx.gen.schema_test.exs
index a2da949f3..d6f769e8f 100644
--- a/test/mix/tasks/phx.gen.schema_test.exs
+++ b/test/mix/tasks/phx.gen.schema_test.exs
@@ -204,11 +204,12 @@ defmodule Mix.Tasks.Phx.Gen.SchemaTest do
 
   test "generates schema with proper datetime types", config do
     in_tmp_project config.test, fn ->
-      Gen.Schema.run(~w(Blog.Comment comments title:string drafted_at:datetime published_at:naive_datetime edited_at:utc_datetime))
+      Gen.Schema.run(~w(Blog.Comment comments title:string drafted_at:datetime published_at:naive_datetime edited_at:utc_datetime locked_at:naive_datetime_usec))
 
       assert_file "lib/phoenix/blog/comment.ex", fn file ->
         assert file =~ "field :drafted_at, :naive_datetime"
         assert file =~ "field :published_at, :naive_datetime"
+        assert file =~ "field :locked_at, :naive_datetime_usec"
         assert file =~ "field :edited_at, :utc_datetime"
       end