GithubHelp home page GithubHelp logo

Comments (13)

janhartigan avatar janhartigan commented on September 28, 2024

Hey @loljak,

I've never really had a chance to test this out in PG, so I imagined there would be bugs. The problem with your solution is that it starts to create problems when you have relationship columns. The "group_by" is there because of this. If you follow the code further down the page, you'll see I have to use a few custom hacks to get everything working, and I imagine at some point in there, something I'm doing is causing this error. Incidentally, that hack I use won't be necessary in L4 as soon as I port Administrator over.

However, there's also a chance that the issue here has something to do with your configuration. Could you paste the model, admin model, and table schema for me so I can see what might be going on?

from laravel-administrator.

loljak avatar loljak commented on September 28, 2024

Hi,
Thank for your response. You're right concerning the fact that I'm
experimenting problems with relationships...
I can reproduce the same issue with an adaptation of the example you give,
to PG (No change to ModelHelper class, so). The whole example files are
joined, with also the little changes I made in the migration files.
May be I don't understand well something in Laravel core. But some little
things I have done was working with the lara_admin bundle. But I find
Administrator much adapted to my goals, (best features separation, easy
and smart use of namespace, compacity and more flexible).
If that can help you, and me in return... I will be glad!

LJ

2013/1/16 janhartigan [email protected]

Hey @loljak https://github.com/loljak,

I've never really had a chance to test this out in PG, so I imagined there
would be bugs. The problem with your solution is that it starts to create
problems when you have relationship columns. The "group_by" is there
because of this. If you follow the code further down the page, you'll see I
have to use a few custom hacks to get everything working, and I imagine at
some point in there, something I'm doing is causing this error.
Incidentally, that hack I use won't be necessary in L4 as soon as I port
Administrator over.

However, there's also a chance that the issue here has something to do
with your configuration. Could you paste the model, admin model, and table
schema for me so I can see what might be going on?


Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-12299608.

Loljak
"Certitudes, servitudes."

from laravel-administrator.

janhartigan avatar janhartigan commented on September 28, 2024

Hey @loljak,

I think you responded to the email and tried to attach files. I don't think that works on GitHub. Can you paste them to http://paste.laravel.com?

from laravel-administrator.

loljak avatar loljak commented on September 28, 2024

Yes...

I have past the changes I've done to Film model, film model admin, films
Migration and the error that I've got. If you need something more, ask me.

http://paste.laravel.com/fUp

Thank

2013/1/16 janhartigan [email protected]

Hey @loljak https://github.com/loljak,

I think you responded to the email and tried to attach files. I don't
think that works on GitHub. Can you paste them to http://paste.laravel.com
?


Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-12344469.

Loljak
"Certitudes, servitudes."

from laravel-administrator.

janhartigan avatar janhartigan commented on September 28, 2024

Alright so...after some preliminary searching, it would appear that my approach to fetching rows simply does not work when using postgresql :(. This has to do with PG not allowing you to arbitrarily select columns when doing groupings. I'm not quite sure how specifically to do a PG sql select that does the same thing, though I'm sure it's possible.

I recognize that this is a problem. The only apparent general way to solve this problem would be to come up with different getRows() methods for each DB driver. I'm not too familiar with all the particularities of PG, so any help here would be useful. I won't get this in for 3.0.0, but hopefully in a subsequent release. The method in question is here:

https://github.com/FrozenNode/Laravel-Administrator/blob/2.3.0/Libraries/ModelHelper.php#L219-L345

from laravel-administrator.

neo13 avatar neo13 commented on September 28, 2024

The problem is exactly here:
https://github.com/FrozenNode/Laravel-Administrator/blob/2.3.0/Libraries/ModelHelper.php#L236

Apparently the PostgreSQL won't let you use group_by as easy as MySQL, according to what I found:
" The problem is, that in PostgreSQL you need to add all the columns you want to have in your select to your group by." ( http://stackoverflow.com/questions/16012818/postgresql-grouping-error )

so I changed it a little bit and now it's working fine, both for MySQL and PostgreSQL, it's not the best effort I guess but it's working, you can find it here:
https://gist.github.com/neo13/5390091

just replace the getRows() method and you'll be fine, and last not least I wanted to thank janhartigan for this great job that he did.

from laravel-administrator.

loljak avatar loljak commented on September 28, 2024

Thank for your patch, I will take a look and try it. I think this behaviour is not postgresql specific, but sqlserver and many other databases don't like grouping columns if the whole columns were not called in the sql request.
Thank a lot for your work and times spent for solve this problem.
Thank to Janhartigan for sharing his job, too!
Cheers!

from laravel-administrator.

cheluis avatar cheluis commented on September 28, 2024

Hi! I'm testing this bundle and I'm concern about the Postgres support of the bundle. I'm testing it with the @loljak patch, and worked fine, but when I tried to get rows from a Model with a foreign key, again it gives an error because of the grouping behaviour of Postgres and almost all the database engine. Mysql is very permissive with this kind of behaviours. @loljak did you tried this case too?

Excelent work.

from laravel-administrator.

loljak avatar loljak commented on September 28, 2024

Hello,
Yes, this solution unfortunately does not work when foreign keys are
present, it's @neo who wrote the patch... My need was a dynamic crud,
Laravel-Administrator makes this work, but it is closely related to MYSQL.
Raw queries work only with this database (Typical grouping behavior). I
decided to set up a less rich solution but agnostic with respect to the
database. I now use a simple user interface based extensively on jqGrid
(Despite my poor JS skills...) and exclusively the data abstraction layer
provided by Laravel, and a little pinch of Bootstrapper bundle. This allows
me to work independently of the DBMS, or even mix them. My plan is much
less ambitious than the work done to Laravel-Administrator, but satisfied
my needs (Quickly generate interface and forms from a simple model
definition).
Laravel-Administrator is a great work. May be it needs to be more Laravel
compliant (I think DB and components like paginator, I had used
Bootstrapper one, and it was working fine).
Regards

2013/5/28 Jose Luis Romero [email protected]

Hi! I'm testing this bundle and I'm concern about the Postgres support of
the bundle. I'm testing it with the @loljak https://github.com/loljakpatch, and worked fine, but when I tried to get rows from a Model with a
foreign key, again it gives an error because of the grouping behaviour of
Postgres and almost all the database engine. Mysql is very permissive with
this kind of behaviours. @loljak https://github.com/loljak did you
tried this case too?

Excelent work.


Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-18582306
.

Loljak
"Certitudes, servitudes."

from laravel-administrator.

cheluis avatar cheluis commented on September 28, 2024

@loljak right, it was a @neo patch. My bad. But something that I found interesting is that, on Postgres 9.1, this behaviour doesn't throw any errors! Tried a select id, table.* from table group by id and it worked fine! I was looking for exactly the same solution that you need, A kind of Cake's scaffolding thing. This is more like Django's admin interface, just with a little more configuration steps. If you have some code that I can try and contribute give a pm.

from laravel-administrator.

janhartigan avatar janhartigan commented on September 28, 2024

The big problem with L3 and why I needed to more or less manually build the query is because of a bug in the paginator class. Basically, when you perform a group_by (which is necessary in our case), it doesn't factor that into the pagination. It's been a long time since I've looked deeply at the problem, but at the time I realized that this won't be a problem in L4, and as such it might then be possible to switch everything back to the query builder (including basic pagination).

Exactly what is needed to solve the postgresql problem is a bit beyond my expertise at the moment in Administrator 3 and Laravel 3. I want to take another look at it when I make the push to L4, but for the moment I've filed it under the "intractable problems" category in my list of things to do. I kind of suspect that moving to L4 will solve all the problems, but we will have to wait and see.

from laravel-administrator.

janhartigan avatar janhartigan commented on September 28, 2024

Is this a problem that people are still having? I don't run postgresql on my dev environment, so it would be good to have some feedback.

from laravel-administrator.

alanpearce avatar alanpearce commented on September 28, 2024

I'm still getting this in 32bb076 with Postgres 8.4. I'm not yet sure if I'm able to try upgrading to Postgres 9. There's another workaround, but I don't think that it's standard. It also mentions that the changes in 9.1 only apply when the primary key is part of the GROUP BY clause.

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.