Skip to content

bug: spark info generator can't handle tuple #269

@matt-beanland

Description

@matt-beanland

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Versions

ash 3.23.1
spark 2.6.1
elixir 1.19.5
erlang OTP 28

Operating system

macOS

Current Behavior

When I attempt to use Spark.InfoGenerator I get

having trouble with Spark.InfoGenerator == Compilation error in file lib/data_layer/info.ex ==
** (ArgumentError) tried to unquote invalid AST: [{{:atom, [], Elixir}, {:atom, [], Elixir}, {:atom, [], Elixir}, {:atom, [], Elixir}}]
Did you forget to escape term using Macro.escape/1?
    (elixir 1.19.5) src/elixir_quote.erl:592: :elixir_quote.argument_error/1
    (spark 2.6.1) lib/spark/info_generator.ex:204: Spark.InfoGenerator.generate_config_function/1
    (elixir 1.19.5) lib/enum.ex:1688: Enum."-map/2-lists^map/1-1-"/2
    (elixir 1.19.5) lib/enum.ex:1688: Enum."-map/2-lists^map/1-1-"/2
    (spark 2.6.1) lib/spark/info_generator.ex:124: anonymous fn/2 in Spark.InfoGenerator."MACRO-generate_config_functions"/3
    (stdlib 7.2) maps.erl:894: :maps.fold_1/4
    (spark 2.6.1) expanding macro: Spark.InfoGenerator.generate_config_functions/2
    lib/data_layer/info.ex:6: AshNeo4j.DataLayer.Info (module)
beanlanda@Matts-MacBook-Pro ash_neo4j %

The spark DSL section is

  @neo4j %Spark.Dsl.Section{
    name: :neo4j,
    examples: [
      """
      neo4j do
        label :Comment
        relate [{:post, :BELONGS_TO, :outgoing}]
      end
      """
    ],
    schema: [
      label: [
        type: :atom,
        doc: "Optional node label",
        required: false
      ],
      relate: [
        type: {:list, {:tuple, [:atom, :atom, :atom, :atom]}},
        doc:
          "Optional list of relationships, as tuples of {relationship_name, edge_label, edge_direction, destination_label}",
        required: false
      ],
      guard: [
        type: {:list, {:tuple, [:atom, :atom, :atom]}},
        doc: "Optional list of node relationships, as tuples of {edge_label, edge_direction, destination_label}",
        required: false
      ],
      skip: [
        type: {:list, :atom},
        doc: "Optional list of attributes not to be stored directly as node properties",
        required: false
      ]
    ]
  }

The issue is likely related to the tuples used in guard and relate.

Reproduction

No response

Expected Behavior

Expected AshNeo4j.DataLayer.Info to be generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions