GithubHelp home page GithubHelp logo

Comments (5)

janhartigan avatar janhartigan commented on June 9, 2024

Hey @demogar thanks for posting this issue. I actually have never tested it with self-relation columns. I definitely will now, though! I'm going to see if I can't find some time later tonight to test out your issue and come up with a fix.

from laravel-administrator.

gilr avatar gilr commented on June 9, 2024

I think I understand the problem: the used SQL request is the following one:

SELECT DISTINCT categories.id, categories.*, (SELECT name FROM categories WHERE categories.parent_id = categories.id) AS parent_category FROM categories GROUP BY categories.id ORDER BY categories.id ASC LIMIT 12 OFFSET 0

As here the local and foreign table is the same, the where clause is 'categories.parent_id' = 'categories.id'... Of course never found.

A correction could be to always force the use of an alias (This request works):

SELECT DISTINCT categories.id, categories.*, (SELECT name FROM categories AS foreign_table WHERE categories.parent_id = foreign_table.id) AS parent_category FROM categories GROUP BY categories.id ORDER BY categories.id ASC LIMIT 12 OFFSET 0

from laravel-administrator.

janhartigan avatar janhartigan commented on June 9, 2024

Ah ha! Good catch, @gilr! You saved me a bunch of time. I'm going to try to come up with a good solution to this issue. Will let you guys know soon!

from laravel-administrator.

demogar avatar demogar commented on June 9, 2024

Thanks a lot for all feedback guys. I will try to come up with a solution (if I find how this query is constructed 😄). I'm looking forward to hearing back about this issue.

Thanks.

from laravel-administrator.

janhartigan avatar janhartigan commented on June 9, 2024

Hey guys I just pushed this commit:

f4e26e7

For some reason it isn't attaching to this issue, but that commit should solve this problem. Along the way, I also added a nice feature where Administrator recognizes if something is a self-relationship, and as such will update the filter/edit options for that relationship after you save or delete an item. So your self-relationship will always stay up to date with the latest options. Let me know if you guys find any issues!

from laravel-administrator.

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.