Skip to content

unknown type handling not substituting when generating domain resources #588

@aikomastboom

Description

@aikomastboom

Versions

Versions

  • ash 3.5.25
  • ash_admin 0.13.11
  • ash_phoenix 2.3.9
  • ash_postgres 2.6.9
  • ash_sql 0.2.84
  • igniter 0.6.10
$ elixir --version
Erlang/OTP 27 [erts-15.2.7] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Elixir 1.18.4 (compiled with Erlang/OTP 27)

Operating system

nixos

Current Behavior

Generated x_it app
Generating resources from [XIt.Repo]
Unknown type: character. What should we use as the type?

Provide the value as literal source code that should be placed into the
generated file, i.e

   - :string
   - MyApp.Types.CustomType
   - {:array, :string}

Use `skip` to skip ignore this attribute.
 :string

Igniter:

.
.
.

Create: lib/x_it/access/access_key.ex

1  |defmodule XIt.Access.AccessKey do
2  |  use Ash.Resource,
3  |    domain: XIt.Access,
4  |    data_layer: AshPostgres.DataLayer
5  |
6  |  postgres do
7  |    table "access_keys"
8  |    repo XIt.Repo
9  |    migrate? false
10 |
11 |    identity_index_names idx_26201_access_key: "idx_26201_access_key"
12 |  end
13 |
14 |  actions do
15 |    defaults [:read, :destroy, create: :*, update: :*]
16 |  end
17 |
18 |  attributes do
19 |    attribute :id, :integer do
20 |      primary_key? true
21 |      allow_nil? false
22 |      generated? true
23 |      public? true
24 |    end
25 |
26 |    attribute :access_key, %AshPostgres.ResourceGenerator.Spec.Attribute{
27 |      name: "access_key",
28 |      type: "character",
29 |      attr_type: :string,
30 |      default: nil,
31 |      migration_default: nil,
32 |      size: 40,
33 |      source: "access_key",
34 |      generated?: false,
35 |      primary_key?: false,
36 |      sensitive?: true,
37 |      allow_nil?: false
38 |    } do
39 |      allow_nil? false
40 |      sensitive? true
41 |      public? true
42 |    end
.
.
.

Reproduction

set a field in postgres schema to char(40) and run gen.resource

Expected Behavior

28 |      type: "character",

should become the user provided value
in above case that would be:

28 |      type: :string,

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions