Laravel: QueryException при использовании Laravel Passport с Postgres

  • Laravel Версия: 5.5.0
  • Версия PHP: PHP 7.1.7-1 + ubuntu16.04.1 + deb.sury.org + 1 (cli) (сборка: 7 июля 2017 г., 09:41:45) (NTS)
  • Драйвер базы данных & Версия: psql (PostgreSQL) 9.5.7

Описание:

При использовании Laravel Passport я получаю следующую ошибку в качестве ответа при использовании токена oauth:

Illuminate \ Database \ QueryException (22P02)
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "" (SQL: select * from "users" where "id" = limit 1)

Я также открыл вопрос по паспорту репо но это похоже на проблему, которая может быть связана с самой платформой, а именно с драйвером Postgres. Читая из других отчетов по этой проблеме (см. Ниже), кажется, что есть параметр, который не отформатирован должным образом и, следовательно, не добавлен в запрос (where "id" = limit 1 не включает в себя фактический идентификатор после =). Я думаю, что фреймворк каким-то образом получает это значение в виде строки, а не целое число. Поэтому форматирование запроса не выполняется. У кого-нибудь есть решение для этого или, по крайней мере, представление о том, где может существовать ошибка?

Другие сообщения о том, что кажется той же проблемой

Действия по воспроизведению:

  1. Настройте драйвер базы данных Postgres
  2. Настройте паспорт, следуя документации на веб-сайте Laravel
  3. Сгенерируйте токен oauth (я использовал Почтальон)
  4. Используйте этот токен в запросе

Скриншот установки почтальона

Полная трассировка стека:

[2017-09-05 15:27:04] local.ERROR: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: "" (SQL: select * from "users" where "id" =  limit 1) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 22P02): SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: \"\" (SQL: select * from \"users\" where \"id\" =  limit 1) at /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 22P02): SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: \"\" at /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Connection.php:330)
[stacktrace]
#0 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from \"...', Array, Object(Closure))
#1 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from \"...', Array, Object(Closure))
#2 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1705): Illuminate\\Database\\Connection->select('select * from \"...', Array, true)
#3 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1690): Illuminate\\Database\\Query\\Builder->runSelect()
#4 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(483): Illuminate\\Database\\Query\\Builder->get(Array)
#5 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(467): Illuminate\\Database\\Eloquent\\Builder->getModels(Array)
#6 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(77): Illuminate\\Database\\Eloquent\\Builder->get(Array)
#7 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php(51): Illuminate\\Database\\Eloquent\\Builder->first()
#8 /home/vagrant/Code/MyApp/vendor/laravel/passport/src/Guards/TokenGuard.php(116): Illuminate\\Auth\\EloquentUserProvider->retrieveById('')
#9 /home/vagrant/Code/MyApp/vendor/laravel/passport/src/Guards/TokenGuard.php(90): Laravel\\Passport\\Guards\\TokenGuard->authenticateViaBearerToken(Object(Illuminate\\Http\\Request))
#10 /home/vagrant/Code/MyApp/vendor/laravel/passport/src/PassportServiceProvider.php(267): Laravel\\Passport\\Guards\\TokenGuard->user(Object(Illuminate\\Http\\Request))
#11 [internal function]: Laravel\\Passport\\PassportServiceProvider->Laravel\\Passport\\{closure}(Object(Illuminate\\Http\\Request), NULL)
#12 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php(58): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request), NULL)
#13 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php(50): Illuminate\\Auth\\RequestGuard->user()
#14 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(61): Illuminate\\Auth\\RequestGuard->check()
#15 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(41): Illuminate\\Auth\\Middleware\\Authenticate->authenticate(Array)
#16 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Auth\\Middleware\\Authenticate->handle(Object(Illuminate\\Http\\Request), Object(Closure), 'api')
#17 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#19 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#20 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Router.php(571): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#21 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Router.php(549): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#22 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#23 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#24 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#25 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#28 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#31 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#34 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#37 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#38 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#39 /home/vagrant/Code/MyApp/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#40 {main}
"}

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]