GithubHelp home page GithubHelp logo

sjke / pg_ltree Goto Github PK

View Code? Open in Web Editor NEW
75.0 75.0 19.0 165 KB

Adds PostgreSQL's ltree support for ActiveRecord models

License: MIT License

Ruby 100.00%
activerecord ltree ltree-extension rails

pg_ltree's People

Contributors

abuisman avatar arjan0307 avatar askamist avatar attilahorvath avatar caulfield avatar chrisortman avatar danielwestendorf avatar joshua5201 avatar mprog avatar mweitzel avatar sb1752 avatar sjke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pg_ltree's Issues

Ability to make ActiveRecord joins to root, parent, etc

I've been working on a project that uses this gem, and I'm frequently finding myself wanting to query with joins to root using ActiveRecord's joins with root... however, since root isn't a proper ActiveRecord relationship, that's not possible.

Also, having a family relationship as well, to bring up all the nodes belonging to the tree :)

@sjke Is this something you'd be interested in? I can gladly take a good try at this, I've already got a plan ๐Ÿ˜ˆ and might get some code ready as well.

Right way to render tree

I used this way:

  def as_html_tree
    if children.empty?
      %Q{<li><a href="/path/#{slug}">#{name}</a></li>}
    else
      %Q{
        <li><a href="/path/#{slug}">#{name}</a>
          <ul>
            #{children.to_a.map(&:as_html_tree).join("</a>")}
          </ul>
        </li>
        }
    end
  end

It is right?

.destroy removes all nodes on same level

Currently a call to model.destroy will remove the model AND remove all other models on the same depth of tree (instead of it's children)

Space Destroy (1.4ms)  DELETE FROM "spaces" WHERE "spaces"."id" = $1  [["id", 141]]
Space Destroy (0.7ms)  DELETE FROM "spaces" WHERE (spaces.path <@ '133.134.137')

Should be:

Space Destroy (0.7ms)  DELETE FROM "spaces" WHERE (spaces.path <@ '133.134.137.141')

Support for Rails 6.0

Now that Rails 6.0 is released, would it be possible to loosen the Active Record dependency to allow using this gem in Rails 6 projects?

Support for Rails 7

Hi, is it possible to allow support for Rails 7 official releases (seems only compatible with <= 7.0.0.rc1)?

NoMethodError: undefined method 'ltree' for Foo:Class

Hello, normally I wouldn't submit an issue like this with so little information, but I saw this gem had a quite a bit of recent restructuring and a recently redacted 1.2.0 tag.

We've been using this gem and in abnormal load orders we're seeing

NoMethodError: undefined method 'ltree' for Foo:Class

when an ltree attribute would normally be defined. Referencing PgLtree in that same location results in an uninitialized constant error.

The error will does not occur if that code is preceeded with

require "pg_ltree/ltree"
ActiveSupport.on_load(:active_record) { extend PgLtree::Ltree }

We haven't been able to reproduce it on rails console or rails server, but have seen it running rake tasks and rspec specs.

An isolated reproduction (i.e. not a branch on our application) has been harder that expected. We're continuing to look into it and will provide more information when we can.

versions

ruby 3.1.2p20
rails 7.0.3
ltree 1.1.9

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.