@@ -2331,13 +2331,41 @@ defmodule Ecto.Adapters.PostgresTest do
23312331 primary_key: true ,
23322332 generated: "ALWAYS AS IDENTITY (MINVALUE 0 START WITH 0 INCREMENT BY 1)"
23332333 ] } ,
2334- { :add , :id_str , :string , [ generated: ~s| ALWAYS AS (id) STORED| ] } ,
2335- { :add , :tags , { :array , :text } , [ generated: ~s| ALWAYS AS (ARRAY['foo','bar']) STORED| ] }
2334+ { :add , :id_str , :string , [ generated: ~s| ALWAYS AS (id) STORED| ] }
23362335 ] }
23372336
23382337 assert execute_ddl ( create ) == [
23392338 """
2340- CREATE TABLE "posts" ("id" integer GENERATED ALWAYS AS IDENTITY (MINVALUE 0 START WITH 0 INCREMENT BY 1), "id_str" varchar(255) GENERATED ALWAYS AS (id) STORED, \" tags\" text[] GENERATED ALWAYS AS (ARRAY['foo','bar']) STORED, PRIMARY KEY ("id"))
2339+ CREATE TABLE "posts" ("id" integer GENERATED ALWAYS AS IDENTITY (MINVALUE 0 START WITH 0 INCREMENT BY 1), "id_str" varchar(255) GENERATED ALWAYS AS (id) STORED, PRIMARY KEY ("id"))
2340+ """
2341+ |> remove_newlines
2342+ ]
2343+ end
2344+
2345+ test "create table with generated array column" do
2346+ create =
2347+ { :create , table ( :posts ) ,
2348+ [ { :add , :tags , { :array , :text } , [ generated: ~s| ALWAYS AS (ARRAY['foo','bar']) STORED| ] } ] }
2349+
2350+ assert execute_ddl ( create ) == [
2351+ """
2352+ CREATE TABLE "posts" ("tags" text[] GENERATED ALWAYS AS (ARRAY['foo','bar']) STORED)
2353+ """
2354+ |> remove_newlines
2355+ ]
2356+ end
2357+
2358+ test "create table with generated nested array column" do
2359+ create =
2360+ { :create , table ( :posts ) ,
2361+ [
2362+ { :add , :tags , { :array , { :array , :text } } ,
2363+ [ generated: ~s| ALWAYS AS (ARRAY['foo','bar']) STORED| ] }
2364+ ] }
2365+
2366+ assert execute_ddl ( create ) == [
2367+ """
2368+ CREATE TABLE "posts" ("tags" text[][] GENERATED ALWAYS AS (ARRAY['foo','bar']) STORED)
23412369 """
23422370 |> remove_newlines
23432371 ]
0 commit comments