| 1 |
use std::error::Error; |
| 2 |
use std::io::Write; |
| 3 |
|
| 4 |
use crate::pg::Pg; |
| 5 |
use crate::serialize::{self, IsNull, Output, ToSql}; |
| 6 |
use crate::sql_types::*; |
| 7 |
|
| 8 |
#[cfg(feature = "postgres_backend")] |
| 9 |
impl ToSql<NullValueTreatmentEnum, Pg> for NullValueTreatment { |
| 10 |
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result { |
| 11 |
let literal = match self { |
| 12 |
Self::RaiseException => "raise_exxception", |
| 13 |
Self::UseJsonNull => "use_json_null", |
| 14 |
Self::DeleteKey => "delete_key", |
| 15 |
Self::ReturnTarget => "return_target", |
| 16 |
}; |
| 17 |
out.write_all(literal.as_bytes()) |
| 18 |
.map(|_| IsNull::No) |
| 19 |
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>) |
| 20 |
} |
| 21 |
} |