Giter Site home page Giter Site logo

descendants error about arbor HOT 6 CLOSED

getong avatar getong commented on August 11, 2024
descendants error

from arbor.

Comments (6)

coryodaniel avatar coryodaniel commented on August 11, 2024 1

@sfusato are you setting the FK type in your module? https://github.com/coryodaniel/arbor/blob/master/README.md#options

Can you open a separate ticket and include a minimal example of the module and query that fails

from arbor.

coryodaniel avatar coryodaniel commented on August 11, 2024

Can you provide the elixir syntax that generated that?

from arbor.

getong avatar getong commented on August 11, 2024

just like this:

    my_comment
     |> Comment.descendants
     |> Repo.all

from arbor.

coryodaniel avatar coryodaniel commented on August 11, 2024

I can't reproduce this, can you make a minimal example in a github that does and share it?

from arbor.

sfusato avatar sfusato commented on August 11, 2024

I have a different error for the same descendants function:

Ecto.Query.CastError at GET /admin/menu/3/nodes
lib/nemo/menus/nodes/menu_node.ex:1: value `3` in `where` cannot be cast to type :binary_id in query:

from m0 in Nemo.Menus.Nodes.MenuNode,
  where: m0.id in fragment("WITH RECURSIVE menu_nodes_tree AS (\n  SELECT id,\n         0 AS depth\n  FROM menu_nodes\n  WHERE parent_id = ?\nUNION ALL\n  SELECT menu_nodes.id,\n         menu_nodes_tree.depth + 1\n  FROM menu_nodes\n    JOIN menu_nodes_tree\n    ON menu_nodes.parent_id = menu_nodes_tree.id\n  WHERE menu_nodes_tree.depth + 1 < ?\n)\nSELECT id FROM menu_nodes_tree\n", type(^3, :binary_id), type(^2147483647, :integer)),
  select: m0

My schema uses the default :id type for primary keys/foreign keys. Not sure if that has anything to do with it.

from arbor.

sfusato avatar sfusato commented on August 11, 2024

You are right. The issue was because of my lack of attention. I didn't modify/update the config options I copy-pasted from the documentation to use :id in my case:

use Arbor.Tree, foreign_key_type: :binary_id

Thank you for the swift reply. I apologize for this.

from arbor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.