sqlx_paginated/paginated_query_as/builders/query_builders/
postgres_query_builder.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::paginated_query_as::internal::{
    get_struct_field_names, ColumnProtection, PostgresDialect,
};
use crate::QueryBuilder;
use serde::Serialize;
use std::marker::PhantomData;

impl<T> Default for QueryBuilder<'_, T, sqlx::Postgres>
where
    T: Default + Serialize,
{
    fn default() -> Self {
        Self::new()
    }
}

impl<T> QueryBuilder<'_, T, sqlx::Postgres>
where
    T: Default + Serialize,
{
    pub fn new() -> Self {
        Self {
            conditions: Vec::new(),
            arguments: sqlx::postgres::PgArguments::default(),
            valid_columns: get_struct_field_names::<T>(),
            protection: Some(ColumnProtection::default()),
            protection_enabled: true,
            dialect: Box::new(PostgresDialect),
            _phantom: PhantomData,
        }
    }
}