Skip to content

Commit 6e040b5

Browse files
committed
WIP 20250517-1136
1 parent 5d22ea2 commit 6e040b5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/transformer.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ defmodule AshRandomParams.Transformer do
114114
|> Enum.reject(&(&1.name in rel_names))
115115
|> Enum.reject(&(&1.name in belongs_to_attrs))
116116
|> Enum.reject(&(&1.name in omit))
117-
|> Enum.reject(& &1.allow_nil?)
117+
|> Enum.reject(&(&1.allow_nil? || &1.default != nil))
118118

119119
fields_by_fill = candidates |> Enum.filter(&(&1.name in populate))
120120

test/ash_random_params_test.exs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule AshRandomParamsTest do
1717
attribute :opt_str, :string, allow_nil?: true, public?: true
1818

1919
attribute :req_int, :integer, allow_nil?: false, public?: true
20-
attribute :opt_int, :integer, allow_nil?: true, public?: true
20+
attribute :opt_int, :integer, allow_nil?: false, public?: true, default: 123
2121
end
2222

2323
actions do
@@ -82,7 +82,7 @@ defmodule AshRandomParamsTest do
8282
req_str: "req_str-" <> _,
8383
opt_str: nil,
8484
req_int: 777,
85-
opt_int: nil
85+
opt_int: 123
8686
} =
8787
params =
8888
Post
@@ -104,7 +104,7 @@ defmodule AshRandomParamsTest do
104104
req_str: "req_str-" <> _,
105105
opt_str: nil,
106106
req_int: 123_456,
107-
opt_int: nil
107+
opt_int: 123
108108
} =
109109
Post
110110
|> Ash.ActionInput.for_action(
@@ -125,7 +125,7 @@ defmodule AshRandomParamsTest do
125125
req_str: "req_str-" <> _,
126126
opt_str: "opt_str-" <> _,
127127
req_int: 777,
128-
opt_int: nil
128+
opt_int: 123
129129
} =
130130
Post
131131
|> Ash.ActionInput.for_action(
@@ -143,7 +143,7 @@ defmodule AshRandomParamsTest do
143143
author_id: nil,
144144
opt_str: nil,
145145
req_int: 777,
146-
opt_int: nil
146+
opt_int: 123
147147
} =
148148
params =
149149
Post
@@ -187,7 +187,7 @@ defmodule AshRandomParamsTest do
187187
req_str: "req_str-" <> _,
188188
opt_str: nil,
189189
req_int: 777,
190-
opt_int: nil
190+
opt_int: 123
191191
} =
192192
Post.random_params!(:create)
193193

0 commit comments

Comments
 (0)