Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raw_sql with a error sql returns infinity of result??? #3662

Open
yuyang-ok opened this issue Jan 2, 2025 · 4 comments
Open

raw_sql with a error sql returns infinity of result??? #3662

yuyang-ok opened this issue Jan 2, 2025 · 4 comments
Labels
bug db:sqlite Related to SQLite E-easy

Comments

@yuyang-ok
Copy link

Bug Description

raw_sql with a error sql returns infinity of result???

Minimal Reproduction

use std::ops::DerefMut;

use futures_util::StreamExt;
use sqlx::pool::PoolOptions;
#[tokio::main]
async fn main() {
    let mut opts: PoolOptions<sqlx::sqlite::Sqlite> = PoolOptions::new();
    opts = opts.max_connections(100);
    let pool = opts.connect("d:\\sqlite.test.db").await.unwrap();
    let mut conn = pool.acquire().await.unwrap();

    let mut  r =   sqlx::raw_sql("insert int has_data values(0.8590210177835114 , 0.3817967967226874 , 0.8726363155846135 , 0.33576135310349586 ,0.019454064037705665 ,0.6635454850159139 ,0.39498634785777)").fetch_many(conn .deref_mut()) ;

    let mut count = 0;

    while let Some(r) = r.next().await {
        match r {
            Ok(_) => todo!(),
            Err(err) => {
                println!("count:{} {:?}", count, err);
                count += 1;
                if count > 5000 {
                    break;
                }
            }
        }
    }
}


[package]
name = "abc-rust"
version = "0.1.0"
edition = "2024"

[dependencies]
futures-util = "0.3.31"
sqlx = { version = "0.8.2", features = ["runtime-tokio", "sqlite"] }
tokio = { version = "1.42.0", features = ["full"] }

Info

  • SQLx version: [REQUIRED]
    "0.8.2
  • SQLx features enabled: [REQUIRED]
    features = ["runtime-tokio", "sqlite"]
  • Database server and version: [REQUIRED] (MySQL / Postgres / SQLite <x.y.z>)
    SQLite 3.42.0
  • Operating system: [REQUIRED]
    windows11
  • rustc --version: [REQUIRED]
    rustc 1.85.0-nightly (bdc6b3de4 2024-12-23)
@yuyang-ok yuyang-ok added the bug label Jan 2, 2025
@yuyang-ok
Copy link
Author

@yuyang-ok
Copy link
Author

count:4983 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4984 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4985 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4986 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4987 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4988 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4989 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4990 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4991 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4992 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4993 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4994 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4995 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4996 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4997 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4998 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:4999 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })
count:5000 Database(SqliteError { code: 1, message: "near \"int\": syntax error" })

@abonander
Copy link
Collaborator

Easy fix. This loop, and the while let one below it, need to break on encountering an error:

for res in iter {

@abonander abonander added db:sqlite Related to SQLite E-easy labels Jan 4, 2025
@yuyang-ok
Copy link
Author

@abonander thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug db:sqlite Related to SQLite E-easy
Projects
None yet
Development

No branches or pull requests

2 participants