使用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)
我也opened an issue on the passport repo但这似乎是一个可能与框架本身有关的问题,即Postgres驱动程序。从这个问题的其他报告中读取(见下文),似乎有一个参数没有正确格式化,因此没有添加到查询中(where "id" = limit 1
不包括实际在=
之后的ID。我认为框架以某种方式将此值作为字符串接收,而不是整数。因此,查询格式失败。有没有人有这方面的解决方案,或者至少知道错误可能存在的地方?
完整堆栈跟踪:
[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}
"}