Skip to content

Trying to implement composite types postgress: unsupported type X of column #7 ("url") #1038

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

Open
lucaswxp opened this issue Feb 7, 2021 · 3 comments

Comments

@lucaswxp
Copy link

lucaswxp commented Feb 7, 2021

Hello again.

I'm trying to run the following query:


    // Make a simple query to return the given parameter
    let rows = sqlx::query!(r#"
    SELECT * FROM pc.rakuten_catalog
    "#)
        .fetch_all(&pool)
        .await?;

    println!("rows {:?}", rows);

But I get

error: unsupported type rakuten_url of column #7 ("url")

I tried:

#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize, sqlx::Type)]
#[yaserde()]
#[sqlx(type_name = "pc.rakuten_url")]
pub struct Url {
    #[yaserde(rename = "productImage")]
    pub product_image: String,

    #[yaserde(rename = "buy")]
    pub buy: String,
}

But sqlx still can't detect my type, what am I missing?

@jplatte
Copy link
Contributor

jplatte commented Feb 7, 2021

See #1004.

@lucaswxp
Copy link
Author

lucaswxp commented Feb 7, 2021

Thanks!

This example didn't work:

SELECT url as "url: _" FROM pc.rakuten_catalog

I get columns may not have wildcard overrides in query!()orquery_as!()`, but this one did:

SELECT url as "url: Url" FROM pc.rakuten_catalog

@jplatte
Copy link
Contributor

jplatte commented Feb 7, 2021

Right, _ only works for query_as! where the type is inferred from the output struct's field type.

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

No branches or pull requests

2 participants