Koka / odbc-rs

Rust ODBC FFI binding
MIT License
97 stars 30 forks source link

[FreeTDS][SQL Server]Invalid data type #49

Closed bbigras closed 6 years ago

bbigras commented 7 years ago

error

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: State: HY004, Native error: 0, Message: [FreeTDS][SQL Server]Invalid data type', /checkout/src/libcore/result.rs:860

code

let param = "something";

let mut stmt = stmt.prepare("SELECT col1, col2 FROM table WHERE p = ?")?;

let stmt = stmt.bind_parameter(1, &param)?;

rustc 1.19.0-nightly (cfb5debbc 2017-06-12) odbc b88e6837704aafbcfd23a7bdc8556a7b6f02a20e Driver=FreeTDS freetds 1.00.40-1 Arch Linux 64-bit

pacman82 commented 7 years ago

I think the issue is very likely, that we do not infer the type based on the rust type, but let it be figured out by the odbc driver itself. We should consider passing something different to Unknown in this piece of code:

https://github.com/Koka/odbc-rs/blob/6c316a2a063e17a63cfb42f120aa6867d561dddc/src/statement/input.rs#L65

Koka commented 7 years ago

I've created a branch with possible fix, but I can't test it right now as I have no access to SQL Server and it works in either way in Postgres

bbigras commented 7 years ago

I'll test it at work tomorrow.

bbigras commented 7 years ago

Sorry for the duplicate post. I replied with the wrong account.

I don't have the "Invalid data type" problem anymore.

I tested with a simple query and it was fine. I tested with a query with 3 "INNER JOIN" and the requests hangs for about 20 seconds and the query results contain 0 when it shouldn't be. Not sure if I should open another issue or if it could be related.

Also I think you might be able to use the microsoft/mssql-server-linux docker image[1] for your unit tests.

1: https://hub.docker.com/r/microsoft/mssql-server-linux/

Koka commented 6 years ago

@bbigras I've released invalid data type fix as 0.9.0. Could you please check if other problem (with joins) is resolved now? If not, we could move this to a separate bug and it would be great to share some additional details and examples like SQL query, table structure etc

bbigras commented 6 years ago

I filled a new issue: #53