Eloquent on MSSQL return error SQLSTATE[IMSSP]: Field 2 returned no data. #48465
-
Laravel Version10.23.1 PHP Version8.1.23 Database Driver & Versionphp-sqlsrv-5.11.0-1.el9 DescriptionOS: Alma 9 After minor update to PHP
Model
Error:
The above raw query (generated by Laravel) works perfectly if I run in a native SQL client. Before upgrading, my app works perfectly fine. Steps To ReproduceModel
(or whatever model, it will break anyway) Tinker (or controller)
This line will throw error. |
Beta Was this translation helpful? Give feedback.
Replies: 30 comments 4 replies
-
Gonna go on a hunch and say it's related to #47937. I'm not sure why things broke for you but if it broke while updating mssql dependencies then it doesn't looks like a Laravel issue to me. |
Beta Was this translation helpful? Give feedback.
-
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
Beta Was this translation helpful? Give feedback.
-
#47937 was fixed by php-sqlsrv-5.11.1-1.el9.remi.8.1.x86_64 therefore I updated to PHP 8.1.23 and php-sqlsrv-5.11.1 to see whether my app having any comparability issue. It must be difference.
To be fair, error like this can be caused by:
|
Beta Was this translation helpful? Give feedback.
-
To clarify, it seem only throw error on |
Beta Was this translation helpful? Give feedback.
-
Can you test with Laravel Framework version before the whole PDO issue solved the problem? This can eliminate if any recent changes would cause any issue. |
Beta Was this translation helpful? Give feedback.
-
I just revert to Laravel version 10.0.0, but it's still not working :( |
Beta Was this translation helpful? Give feedback.
-
Just out of curiosity: try removing the dbo from your $table var on your model |
Beta Was this translation helpful? Give feedback.
-
Update:
|
Beta Was this translation helpful? Give feedback.
-
thanks, I tried but unfortunately it still not work. |
Beta Was this translation helpful? Give feedback.
-
ok, try adding 'charset' => 'utf8' to your database connection config. It might not work, but the error should change. |
Beta Was this translation helpful? Give feedback.
-
thanks, it's in my config/database.php already |
Beta Was this translation helpful? Give feedback.
-
One more: Are you able to perform the query in your MsSQL client app? |
Beta Was this translation helpful? Give feedback.
-
Yes, works on native sqlcmd on same machine Edit: it show results in sqlcmd, but also error at the end: Sqlcmd: Error: Internal error at ReadAndHandleColumnData (Reason: Error reading column data). To clarify: my webapp run in WSL (Alma), and this sqlcmd run on same WSL. If I copy the same query to run on Heidi on Windows, it works perfectly fine. |
Beta Was this translation helpful? Give feedback.
-
Update: if I select certain fields, it will have this error:
It seem somehow related to encoding. |
Beta Was this translation helpful? Give feedback.
-
I open an issue in sqlsrv repo microsoft/msphpsql#1479, will close this if can confirm it's other side's issue |
Beta Was this translation helpful? Give feedback.
-
I tried to reproduce it, but no matter what I did, I couldn't get the error to occur. At least php/php-src#11622 is irrelevant. It's possible that other parts included in Microsoft's hotfix are having an effect, but I don't know because I haven't looked closely. It may be easier to advise if you state what the original version of both php and sqlsev was. It says it's a minor update, so are thay 8.0 and 5.10? |
Beta Was this translation helpful? Give feedback.
-
My PHP version PHP SQLSRV or PDO_SQLSRV version Microsoft ODBC Driver version SQL Server version Microsoft SQL Server 2016 Database collation: I think it relates to converting Unicode. |
Beta Was this translation helpful? Give feedback.
-
What are previous versions? |
Beta Was this translation helpful? Give feedback.
-
It was php-8.1.21 and php-sqlsrv-5.11.0 |
Beta Was this translation helpful? Give feedback.
-
Thank you. Can you share the definition part of the Laravel migration file? Also, I would like to know what settings are made for the sql server part of |
Beta Was this translation helpful? Give feedback.
-
It also throw error if I select CardType, with other error |
Beta Was this translation helpful? Give feedback.
-
Could I want to know the exact contents of the migration file. |
Beta Was this translation helpful? Give feedback.
-
It's OCRD table for SAP B1 database, you can find it here https://sap.erpref.com/?schema=BusinessOne9.3&module_id=3&table=OCRD |
Beta Was this translation helpful? Give feedback.
-
Hmm. Apparently I don't have enough time to reproduce this. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your kind effort. |
Beta Was this translation helpful? Give feedback.
-
Is it possible that this is involved? |
Beta Was this translation helpful? Give feedback.
-
Thank you, it's not. I have |
Beta Was this translation helpful? Give feedback.
-
Update: It's not Laravel's fault. Thank you all for helping. |
Beta Was this translation helpful? Give feedback.
-
How about reverting to php 8.1.21 and seeing if the error occurred? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Update:
It's related to this https://stackoverflow.com/a/77140830/223934
TL;DR the fix is install
glibc-gconv-extra
.It's not Laravel's fault.
Thank you all for helping.