perdumonocle / sql-builder

Simple SQL code generator.
MIT License
123 stars 13 forks source link

Is there any support for Postgres Array? #15

Open TaQuanMinhLong opened 1 year ago

TaQuanMinhLong commented 1 year ago

Hey, can we add a function for postgres array text, something similar or better than this?

use serde::Serialize;
    use sql_builder::quote;
    use std::fmt::Display;

    pub fn pg_array<T: Display + Serialize>(value: &[T]) -> String {
        quote(
            serde_json::to_string(value)
                .expect("Failed to serialize value")
                .replace("[", "{")
                .replace("]", "}"),
        )
    }