sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

MSSQL Query - Protocol unknown value

Open carlos-rian opened this issue 3 years ago • 4 comments

About

I'm new to rust, but I'm trying to create a simple async "driver" to use in python, so I'll connect via rust to access SQL Server and do statements and queries.

I´m trying

When trying to do a simple test of querying a 1000 row table with RUST.

Example

Code

use sqlx::mssql::MssqlPool;
use sqlx;
use sqlx::Error;


async fn query() -> Result<(), Error> {//Result<Vec<sqlx::mssql::MssqlRow>, Error> {
    let conn_uri = "mssql://sa:Super&-23@localhost:1433/master";

    let query = "
        SELECT *
        FROM TempTest
    ";

    let conn = MssqlPool::connect(conn_uri).await?;

    let rows = sqlx::query(query).fetch_all(&conn).await?;

    println!("{}", rows.len());
    Ok(())
}

#[tokio::main]
async fn main() -> Result<(), sqlx::Error> {
    let _row = query().await?;
    Ok(())
}

Error

Error: Protocol("unknown value `0x32` for message type in token stream")

Code + Data + Docker to reproduce the error.

I put in this repository the exact example I'm trying to run.

Link: https://github.com/carlos-rian/async-odbc-mssql/tree/main/core

carlos-rian avatar Apr 28 '22 13:04 carlos-rian

I got the similar error when I used the mssql and sqlx version is 0.5.13.

hackers267 avatar Jun 26 '22 01:06 hackers267

I guest the reason is there are some fields which type is nvarchar(max). Try to change these fields type to the fixed number again. @carlos-rian

hackers267 avatar Jun 26 '22 23:06 hackers267

@hackers267 I understand, but this is a bug. I think it's a problem, right?

carlos-rian avatar Sep 13 '22 19:09 carlos-rian

@carlos-rian I think it is a bug too. I will recover the code in the feature

hackers267 avatar Sep 14 '22 00:09 hackers267