From 506c75c2eb59cbafc4294500810ba9556b63b319 Mon Sep 17 00:00:00 2001 From: Greg Rychlewski Date: Tue, 24 Jun 2025 05:41:20 -0400 Subject: [PATCH] fix generated nested time array --- lib/ecto/adapters/postgres/connection.ex | 2 +- test/ecto/adapters/postgres_test.exs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ecto/adapters/postgres/connection.ex b/lib/ecto/adapters/postgres/connection.ex index c9486020..7653c572 100644 --- a/lib/ecto/adapters/postgres/connection.ex +++ b/lib/ecto/adapters/postgres/connection.ex @@ -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) diff --git a/test/ecto/adapters/postgres_test.exs b/test/ecto/adapters/postgres_test.exs index f95e4783..2c4695d0 100644 --- a/test/ecto/adapters/postgres_test.exs +++ b/test/ecto/adapters/postgres_test.exs @@ -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 ]