prisma / tiberius

TDS 7.2+ (Microsoft SQL Server) driver for Rust
Apache License 2.0
311 stars 113 forks source link

SQL_Latin1_General_CP850_CI_AS #326

Closed TheLexoPlexx closed 3 weeks ago

TheLexoPlexx commented 6 months ago

Hi there,

I am trying to use Tiberius with an MS-SQL-Database but I keep gettin the error: Error getting row: Encoding error: encoding: unspported encoding (LCID: 0x409, sort ID: 42)

And this is quite annoying. As far as I can tell, tiberius does not seem to support the aforementioned encoding and I am not sure how to work my way around this.

Code: https://gist.github.com/TheLexoPlexx/01a050cdef973f72c2673fd537837050

Additionally: Reading the colum names works fine.

All ideas are welcome.

Sincerely Alex

Edit: I switched to SQLx@0.6.3 because that still supports MS-SQL, guess I'll use that until they have a pro version.

lekamm commented 3 weeks ago

As a work around, you can change the COLLATE in your query. As far as I understand the source code, this error arises when the encoding is not supported by Rust (not by tiberius). Also, instead of an error, we might be able to map to another encoding that would work?

SELECT Name COLLATE SQL_Latin1_General_CP1_CI_AS AS Name, Address COLLATE SQL_Latin1_General_CP1_CI_AS AS Address, ZipCode COLLATE SQL_Latin1_General_CP1_CI_AS AS ZipCode, City COLLATE SQL_Latin1_General_CP1_CI_AS AS City, Country COLLATE SQL_Latin1_General_CP1_CI_AS AS Country, ... FROM Partners ORDER BY Balance DESC;

TheLexoPlexx commented 3 weeks ago

To be honest, I solved the problem by not using tiberius and went back to SQLx 0.6.3, which still has MS-SQL-Support. The underlying database is a mess and I don't blame tiberius for this.