Skip to content

Commit 2afe964

Browse files
committed
fix: properly detect nested array decimals
1 parent dc81e68 commit 2afe964

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/migration_generator/migration_generator.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3593,8 +3593,8 @@ defmodule AshPostgres.MigrationGenerator do
35933593
["decimal", precision, scale]
35943594
end
35953595

3596-
defp sanitize_type(type, size, precision, decimal) when is_atom(type) and is_integer(size) do
3597-
[sanitize_type(type, nil, precision, decimal), size]
3596+
defp sanitize_type(type, size, precision, decimal) when is_tuple(type) do
3597+
sanitize_type(elem(type, 0), size, precision, decimal)
35983598
end
35993599

36003600
defp sanitize_type(type, _, _, _) do

test/migration_generator_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,11 @@ defmodule AshPostgres.MigrationGeneratorTest do
25112511
public?: true
25122512
)
25132513

2514+
attribute(:decimal_list, {:array, :decimal},
2515+
default: [Decimal.new("123.4567890987654321987")],
2516+
public?: true
2517+
)
2518+
25142519
attribute(:name, :string, default: "Fred", public?: true)
25152520
attribute(:tag, :atom, default: :value, public?: true)
25162521
attribute(:enabled, :boolean, default: false, public?: true)

0 commit comments

Comments
 (0)