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

Query extractor does not work well with enum #3565

Open
juchiast opened this issue Feb 4, 2025 · 0 comments
Open

Query extractor does not work well with enum #3565

juchiast opened this issue Feb 4, 2025 · 0 comments

Comments

@juchiast
Copy link

juchiast commented Feb 4, 2025

Steps to Reproduce (for bugs)

I have 2 kinds of query, using this enum:

        #[derive(Deserialize, Debug)]
        #[serde(untagged)]
        pub enum Query {
            FlowTag { flow: i32, tag: String },
            Id { id: String },
        }

However, it fails to decode ?flow=123&tag=latest. Replacing flow type with String makes it pass.

        #[derive(Deserialize, Debug)]
        #[serde(untagged)]
        pub enum Query1 {
            // fail when using i32
            FlowTag { flow: i32, tag: String },
            Id { id: String },
        }

        #[derive(Deserialize, Debug)]
        #[serde(untagged)]
        pub enum Query2 {
            // success when using a string
            FlowTag { flow: String, tag: String },
            Id { id: String },
        }

        let req = TestRequest::with_uri("/start?flow=123&tag=latest").to_http_request();
        web::Query::<Query1>::extract(&req).await.unwrap();
        web::Query::<Query2>::extract(&req).await.unwrap();
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

1 participant