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

where queries and Laravel Telescope query watcher #50

Open
screw opened this issue Apr 27, 2022 · 2 comments
Open

where queries and Laravel Telescope query watcher #50

screw opened this issue Apr 27, 2022 · 2 comments

Comments

@screw
Copy link

screw commented Apr 27, 2022

I've upgraded to neoEloquent 9.0.5 which now works with Laravel Telescope, but it fails when I use where().

Just to clarify: if I turn off telescope's query watcher, I can do all sorts of cypherQueries.
But when I enable the query watcher, only simple queries - (without where filters, just get all nodes of a certain type for example).

$data = $neoClass::query(); $result=$data->paginate();

When I try to include filters aka WHERE clause ->where(...), the query fails:

           $data ->when($filterNeo, function ($query, $filterNeo) {
                return $query->where(NeoClass::COL_SOMEFIELD, 'STARTS WITH', "$filterNeo");
            });

The problem is in the telescope because it doesn't check what is returned from getPdo() (link snipped below).
But they are not willing to address it within their code.

protected function quoteStringBinding($event, $binding)
    {
        try {
            return $event->connection->getPdo()->quote($binding);
        } catch (\PDOException $e) {
            throw_if('IM001' !== $e->getCode(), $e);
        }

I am wondering how NeoEloquent works with the simple queries since those are logged in the telescope.
Maybe there is a fix since some queries work with the telescope.

Call stack:

{
    "message": "Call to a member function quote() on null",
    "exception": "Error",
    "file": "/var/www/vendor/laravel/telescope/src/Watchers/QueryWatcher.php",
    "line": 122,
    "trace": [
        {
            "file": "/var/www/vendor/laravel/telescope/src/Watchers/QueryWatcher.php",
            "line": 103,
            "function": "quoteStringBinding",
            "class": "Laravel\\Telescope\\Watchers\\QueryWatcher",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/laravel/telescope/src/Watchers/QueryWatcher.php",
            "line": 42,
            "function": "replaceBindings",
            "class": "Laravel\\Telescope\\Watchers\\QueryWatcher",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php",
            "line": 404,
            "function": "recordQuery",
            "class": "Laravel\\Telescope\\Watchers\\QueryWatcher",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php",
            "line": 249,
            "function": "Illuminate\\Events\\{closure}",
            "class": "Illuminate\\Events\\Dispatcher",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
            "line": 887,
            "function": "dispatch",
            "class": "Illuminate\\Events\\Dispatcher",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
            "line": 728,
            "function": "event",
            "class": "Illuminate\\Database\\Connection",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/ulobby/neoeloquent/src/Connection.php",
            "line": 489,
            "function": "logQuery",
            "class": "Illuminate\\Database\\Connection",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/ulobby/neoeloquent/src/Connection.php",
            "line": 214,
            "function": "run",
            "class": "Vinelab\\NeoEloquent\\Connection",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/ulobby/neoeloquent/src/Query/Builder.php",
            "line": 629,
            "function": "select",
            "class": "Vinelab\\NeoEloquent\\Connection",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/ulobby/neoeloquent/src/Query/Builder.php",
            "line": 975,
            "function": "runSelect",
            "class": "Vinelab\\NeoEloquent\\Query\\Builder",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/ulobby/neoeloquent/src/Query/Builder.php",
            "line": 257,
            "function": "get",
            "class": "Vinelab\\NeoEloquent\\Query\\Builder",
            "type": "->"
        },
        {
            "file": "/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php",
            "line": 808,
            "function": "getCountForPagination",
            "class": "Vinelab\\NeoEloquent\\Query\\Builder",
            "type": "->"
        },


@berteltorp
Copy link
Member

Haven't tried telescope - but can recommend clockwork as replacement https://github.com/itsgoingd/clockwork

@screw
Copy link
Author

screw commented May 4, 2022

Haven't tried telescope - but can recommend clockwork as replacement https://github.com/itsgoingd/clockwork

Thank you, that looks great.
I'll give it a try.
And just to be clear, you know clockwork works with NeoEloquent (and the new Laudis/neo4jphp client)?

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

2 participants