Skip to content

Creating clients with scopes fails #47

@jfpedroza

Description

@jfpedroza

Hi, thanks for the library!.

Creating a client with scopes like here fails with the following error:

** (Postgrex.Error) ERROR 23502 (not_null_violation) null value in column "id" of relation "oauth_clients_scopes" violates not-null constraint

    table: oauth_clients_scopes
    column: id

Failing row contains (null, fd43592f-9d24-428f-8ffb-b4ae35e572a5, b6950353-ab83-4050-8534-378ab2f3cc06).
    (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1098: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:969: Ecto.Adapters.SQL.insert_all/9
    (ecto 3.13.2) lib/ecto/repo/schema.ex:84: Ecto.Repo.Schema.do_insert_all/7
    (ecto 3.13.2) lib/ecto/association.ex:1562: Ecto.Association.ManyToMany.on_repo_change/5
    (ecto 3.13.2) lib/ecto/association.ex:633: anonymous fn/8 in Ecto.Association.on_repo_change/7
    (elixir 1.19.1) lib/enum.ex:2520: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto 3.13.2) lib/ecto/association.ex:629: Ecto.Association.on_repo_change/7
    (elixir 1.19.1) lib/enum.ex:2520: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto 3.13.2) lib/ecto/association.ex:574: Ecto.Association.on_repo_change/4
    (ecto 3.13.2) lib/ecto/repo/schema.ex:1198: Ecto.Repo.Schema.process_children/5
    (ecto 3.13.2) lib/ecto/repo/schema.ex:1285: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6
    (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1458: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
    (db_connection 2.8.0) lib/db_connection.ex:1753: DBConnection.run_transaction/4
    (ecto 3.13.2) lib/ecto/repo/schema.ex:381: Ecto.Repo.Schema.insert!/4

Because the oauth_clients_scopes table has an id field and Ecto does not populate it.
I had to manually create the scopes using Admin.create_scope/1 then use Repo.query! with INSERT INTO to create the association between clients and scopes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions