Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using with Filament 3 summaries #156

Open
mikewink opened this issue Aug 17, 2023 · 3 comments
Open

Error when using with Filament 3 summaries #156

mikewink opened this issue Aug 17, 2023 · 3 comments

Comments

@mikewink
Copy link

Hello Ryan,

I have lots of fun with Orbit flat files as my data store. I am building a small demo application for me. One piece is a basic budget list with an amount integer field. In my Filament 3 table, I want to use a summaries row to show the average and sum for the field/column. But there I run into that error message:

SQLSTATE[HY000]: General error: 1 near ".": syntax error

select
  avg(budget_list_items.amount) as "uOXarbNylBj8KxXR"
from
  (
    select
      *
    from
      "/Users/.../project-name/storage/framework/cache/orbit/orbit"."sqlite"."budget_list_items"
  ) as "budget_list_items"

It looks like the orbit.sqlite is causing a problem here, as it is misinterpreted. Is that an error on my end or a limitation/issue of Orbit?

I am running the latest versions/releases of Laravel, Filament 3 and Orbit.

Thank you very much for any of your wisdom and insight.

Mike

@ryangjchandler
Copy link
Owner

Hm, this is a bit of a strange one. I haven't used Orbit in this way myself yet, but it seems the SQL generation is doing something weird with the table name.

@mikewink
Copy link
Author

Can I maybe help with that? Do you have some insight on where to look for the cause? Which sub system that would be handled in?

@crotanite
Copy link

I know this issue is now over a year old, but I thought I'd mention that I came across the same problem when using the withCount method.

Turns out its a problem with the prependDatabaseNameIfCrossDatabaseQuery method:

protected function prependDatabaseNameIfCrossDatabaseQuery($query)
{
    if ($query->getConnection()->getDatabaseName() !==
        $this->getConnection()->getDatabaseName()) {
        $databaseName = $query->getConnection()->getDatabaseName(); // SPECIFICALLY HERE

        if (strpos($query->from, $databaseName) !== 0 && strpos($query->from, '.') === false) {
            $query->from($databaseName.'.'.$query->from);
        }
    }

    return $query;
}

The getDatabaseName method returns the full path to sqlite file which causes an issue. However. Even manually overriding this and forcing it to be 'orbit' still doesn't work:

SQLSTATE[HY000]: General error: 1 no such table: orbit.posts (Connection: , SQL: select "categories".*, (select count(*) from "orbit"."posts" where "categories"."key" = "posts"."category_key") as "posts_count" from "categories" limit 1)

I'm not sure what the solution to this is (or if there even is one), I dug in as much as I was able and hit a road block.

Just thought I'd leave this info here in case someone more versed with Laravel's query builder can see how to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants