Skip to content

Use connection name from QueryException when creating QueryExecuted event#405

Open
oli-laban wants to merge 1 commit intospatie:mainfrom
oli-laban:connection-name
Open

Use connection name from QueryException when creating QueryExecuted event#405
oli-laban wants to merge 1 commit intospatie:mainfrom
oli-laban:connection-name

Conversation

@oli-laban
Copy link

I'm working on a multi-tenant / multi-DB application which has no default connection as it is resolved at request time. Various things like Commands use DB::usingConnection() to temporarily set a default connection, but exceptions cascade back out of this callback and by the time Ray processes it, there is no default. This causes an exception as null gets passed to DB::connection(), which masks the original exception and is very annoying.

QueryException holds the connection name so I've simply updated it to use that. It falls back to the default as the property was added in Laravel 10.x and Ray looks to support back to 7.x.

There are currently no tests covering QueryExceptions so I haven't added any for this minor change. I can look into covering that path if needed.

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

Successfully merging this pull request may close these issues.

1 participant