Skip to content

Commit 62603f8

Browse files
Fix generated nested time array (#680)
1 parent 701c99e commit 62603f8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/ecto/adapters/postgres/connection.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ if Code.ensure_loaded?(Postgrex) do
17671767

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

17731773
defp column_type(type, opts)

test/ecto/adapters/postgres_test.exs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,12 +2376,14 @@ defmodule Ecto.Adapters.PostgresTest do
23762376
{:create, table(:posts),
23772377
[
23782378
{:add, :tags, {:array, {:array, :text}},
2379-
[generated: ~s|ALWAYS AS (ARRAY['foo','bar']) STORED|]}
2379+
[generated: ~s|ALWAYS AS (ARRAY['foo','bar']) STORED|]},
2380+
{:add, :times, {:array, {:array, :time}},
2381+
[generated: ~s|ALWAYS AS (ARRAY['08:00:00','09:00:00']) STORED|]}
23802382
]}
23812383

23822384
assert execute_ddl(create) == [
23832385
"""
2384-
CREATE TABLE "posts" ("tags" text[][] GENERATED ALWAYS AS (ARRAY['foo','bar']) STORED)
2386+
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)
23852387
"""
23862388
|> remove_newlines
23872389
]

0 commit comments

Comments
 (0)