Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ecto/adapters/postgres/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ if Code.ensure_loaded?(Postgrex) do

defp column_type(type, opts) when type in ~w(time utc_datetime naive_datetime)a do
generated = Keyword.get(opts, :generated)
[ecto_to_db(type), "(0)", generated_expr(generated)]
[[ecto_to_db(type), "(0)"], generated_expr(generated)]
end

defp column_type(type, opts)
Expand Down
6 changes: 4 additions & 2 deletions test/ecto/adapters/postgres_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2376,12 +2376,14 @@ defmodule Ecto.Adapters.PostgresTest do
{:create, table(:posts),
[
{:add, :tags, {:array, {:array, :text}},
[generated: ~s|ALWAYS AS (ARRAY['foo','bar']) STORED|]}
[generated: ~s|ALWAYS AS (ARRAY['foo','bar']) STORED|]},
{:add, :times, {:array, {:array, :time}},
[generated: ~s|ALWAYS AS (ARRAY['08:00:00','09:00:00']) STORED|]}
]}

assert execute_ddl(create) == [
"""
CREATE TABLE "posts" ("tags" text[][] GENERATED ALWAYS AS (ARRAY['foo','bar']) STORED)
CREATE TABLE "posts" ("tags" text[][] GENERATED ALWAYS AS (ARRAY['foo','bar']) STORED, "times" time(0)[][] GENERATED ALWAYS AS (ARRAY['08:00:00','09:00:00']) STORED)
"""
|> remove_newlines
]
Expand Down
Loading