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

Any driver does not support the Postgres type PgTypeInfo(Uuid) #3571

Open
Huyyyyyyyy opened this issue Oct 22, 2024 · 2 comments
Open

Any driver does not support the Postgres type PgTypeInfo(Uuid) #3571

Huyyyyyyyy opened this issue Oct 22, 2024 · 2 comments
Labels

Comments

@Huyyyyyyyy
Copy link

Huyyyyyyyy commented Oct 22, 2024

Bug Description

A clear and concise description of what the bug is.
I got an error while I am trying to get data from column has type UUID
ColumnDecode { index: "request_id", source: AnyDriverError("Any driver does not support the Postgres type PgTypeInfo(Uuid)") }
My query use:
select request_id from tb_purchase
request_id is UUID type in PostgreSQL

Code block:

use super::trait_connection::IConnection;
use async_trait::async_trait;
use sqlx::{any::AnyRow, pool::PoolOptions, AnyPool};

#[derive(Debug)]
pub struct PostgresConnection {
    pub database_url: String,
    pub pool: Option<AnyPool>,
}
// ... code snippet

    async fn query(&self, query: &str) -> Result<Vec<AnyRow>, String> {
        let pool = self
            .pool
            .as_ref()
            .ok_or("Database connection not established")?;

        if query.is_empty() {
            return Err("No query provided".to_string());
        }

        let rows = sqlx::query(query)
            .fetch_all(pool)
            .await
            .map_err(|e| format!("Failed to query - {:?}", e))?;

        Ok(rows)
    }

Got error due to I am using AnyPool
When I replace AnyPool with PgPool, the system work normally. But I prefer using AnyPool because I am thinking of AnyPool can adapt to different DB types, instead of hardcoded to PostgreSQL

Minimal Reproduction

A small code snippet or a link to a Github repo or Gist, with instructions on reproducing the bug.

Info

  • SQLx version: [0.8.2]
  • Database server and version: ( Postgres <15.3>)
  • Operating system: Windows 10
  • rustc --version: [1.79.0]
@Huyyyyyyyy Huyyyyyyyy added the bug label Oct 22, 2024
@Norlock
Copy link
Contributor

Norlock commented Oct 31, 2024

Also PgTypeInfo(Numeric) is not recognized as anytypeinfo, I found out.

AnyTypeInfoKind::Real | AnyTypeInfoKind::Double, cannot be parsed to from PgTypeInfo(Numeric)

@Shirogaki
Copy link

Seems like you'll have to switch implementation, use an adapter or limit yourself to Postgre

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants