forked from transact-rs/sqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdescribe.rs
More file actions
61 lines (54 loc) 路 1.53 KB
/
Copy pathdescribe.rs
File metadata and controls
61 lines (54 loc) 路 1.53 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Types for returning SQL type information about queries.
use std::fmt::{self, Debug};
use crate::database::Database;
/// The return type of [Executor::describe].
#[non_exhaustive]
pub struct Describe<DB>
where
DB: Database + ?Sized,
{
/// The expected types for the parameters of the query.
pub param_types: Box<[DB::TypeInfo]>,
/// The type and table information, if any for the results of the query.
pub result_columns: Box<[Column<DB>]>,
}
impl<DB> Debug for Describe<DB>
where
DB: Database,
DB::TypeInfo: Debug,
Column<DB>: Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Describe")
.field("param_types", &self.param_types)
.field("result_columns", &self.result_columns)
.finish()
}
}
/// A single column of a result set.
#[non_exhaustive]
pub struct Column<DB>
where
DB: Database + ?Sized,
{
pub name: Option<Box<str>>,
pub table_id: Option<DB::TableId>,
pub type_info: DB::TypeInfo,
/// Whether or not the column cannot be `NULL` (or if that is even knowable).
pub non_null: Option<bool>,
}
impl<DB> Debug for Column<DB>
where
DB: Database + ?Sized,
DB::TableId: Debug,
DB::TypeInfo: Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Column")
.field("name", &self.name)
.field("table_id", &self.table_id)
.field("type_id", &self.type_info)
.field("nonnull", &self.non_null)
.finish()
}
}