mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 21:13:10 +12:00
feat: add source
option to attributes
This commit is contained in:
parent
c41761ef62
commit
15bdae0d99
4 changed files with 18 additions and 3 deletions
|
@ -109,6 +109,7 @@ locals_without_parens = [
|
|||
sensitive?: 1,
|
||||
soft?: 1,
|
||||
sort: 1,
|
||||
source: 1,
|
||||
source_field: 1,
|
||||
source_field_on_join_table: 1,
|
||||
strategy: 1,
|
||||
|
|
|
@ -13,6 +13,7 @@ defmodule Ash.Resource.Attribute do
|
|||
:default,
|
||||
:update_default,
|
||||
:description,
|
||||
:source,
|
||||
sensitive?: false,
|
||||
filterable?: true,
|
||||
constraints: []
|
||||
|
@ -52,6 +53,12 @@ defmodule Ash.Resource.Attribute do
|
|||
doc:
|
||||
"Whether or not the attribute value contains sensitive information, like PII. If so, it will be redacted while inspecting data."
|
||||
],
|
||||
source: [
|
||||
type: :atom,
|
||||
doc: """
|
||||
If the field should be mapped to a different name in the data layer.
|
||||
"""
|
||||
],
|
||||
always_select?: [
|
||||
type: :boolean,
|
||||
default: false,
|
||||
|
|
|
@ -33,7 +33,8 @@ defmodule Ash.Schema do
|
|||
constraint_opts,
|
||||
primary_key: attribute.primary_key?,
|
||||
read_after_writes: read_after_writes?,
|
||||
redact: attribute.sensitive?
|
||||
redact: attribute.sensitive?,
|
||||
source: attribute.source
|
||||
)
|
||||
)
|
||||
end
|
||||
|
@ -120,7 +121,8 @@ defmodule Ash.Schema do
|
|||
constraint_opts,
|
||||
primary_key: attribute.primary_key?,
|
||||
read_after_writes: read_after_writes?,
|
||||
redact: attribute.sensitive?
|
||||
redact: attribute.sensitive?,
|
||||
source: attribute.source
|
||||
)
|
||||
)
|
||||
end
|
||||
|
|
|
@ -25,7 +25,12 @@ defmodule Ash.Resource.Transformers.SetTypes do
|
|||
Transformer.replace_entity(
|
||||
dsl_state,
|
||||
[:attributes],
|
||||
%{attribute | type: type, constraints: constraints},
|
||||
%{
|
||||
attribute
|
||||
| type: type,
|
||||
constraints: constraints,
|
||||
source: attribute.source || attribute.name
|
||||
},
|
||||
fn replacing ->
|
||||
replacing.name == attribute.name
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue