pg2sqlite_core/diagnostics/
warning.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
5pub enum Severity {
6 Info,
8 Lossy,
10 Unsupported,
12 Error,
14}
15
16impl std::fmt::Display for Severity {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 match self {
19 Severity::Info => write!(f, "info"),
20 Severity::Lossy => write!(f, "lossy"),
21 Severity::Unsupported => write!(f, "unsupported"),
22 Severity::Error => write!(f, "error"),
23 }
24 }
25}
26
27#[derive(Debug, Clone)]
29pub struct Warning {
30 pub code: &'static str,
32 pub severity: Severity,
34 pub message: String,
36 pub object: Option<String>,
38}
39
40impl Warning {
41 pub fn new(code: &'static str, severity: Severity, message: impl Into<String>) -> Self {
42 Self {
43 code,
44 severity,
45 message: message.into(),
46 object: None,
47 }
48 }
49
50 pub fn with_object(mut self, object: impl Into<String>) -> Self {
51 self.object = Some(object.into());
52 self
53 }
54}
55
56impl std::fmt::Display for Warning {
57 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58 if let Some(obj) = &self.object {
59 write!(f, "[{}] {}: {}", self.code, obj, self.message)
60 } else {
61 write!(f, "[{}] {}", self.code, self.message)
62 }
63 }
64}
65
66pub const TYPE_WIDTH_IGNORED: &str = "TYPE_WIDTH_IGNORED";
70pub const NUMERIC_PRECISION_LOSS: &str = "NUMERIC_PRECISION_LOSS";
71pub const BOOLEAN_AS_INTEGER: &str = "BOOLEAN_AS_INTEGER";
72pub const DATETIME_TEXT_STORAGE: &str = "DATETIME_TEXT_STORAGE";
73pub const TIMEZONE_LOSS: &str = "TIMEZONE_LOSS";
74pub const UUID_AS_TEXT: &str = "UUID_AS_TEXT";
75pub const JSONB_LOSS: &str = "JSONB_LOSS";
76pub const ENUM_AS_TEXT: &str = "ENUM_AS_TEXT";
77pub const ARRAY_LOSSY: &str = "ARRAY_LOSSY";
78pub const DOMAIN_FLATTENED: &str = "DOMAIN_FLATTENED";
79pub const VARCHAR_LENGTH_IGNORED: &str = "VARCHAR_LENGTH_IGNORED";
80pub const CHAR_LENGTH_IGNORED: &str = "CHAR_LENGTH_IGNORED";
81pub const INTERVAL_AS_TEXT: &str = "INTERVAL_AS_TEXT";
82pub const MONEY_AS_TEXT: &str = "MONEY_AS_TEXT";
83pub const NETWORK_AS_TEXT: &str = "NETWORK_AS_TEXT";
84pub const GEO_AS_TEXT: &str = "GEO_AS_TEXT";
85pub const BIT_AS_TEXT: &str = "BIT_AS_TEXT";
86pub const XML_AS_TEXT: &str = "XML_AS_TEXT";
87pub const RANGE_AS_TEXT: &str = "RANGE_AS_TEXT";
88pub const TYPE_UNKNOWN: &str = "TYPE_UNKNOWN";
89
90pub const SERIAL_TO_ROWID: &str = "SERIAL_TO_ROWID";
92pub const SERIAL_NOT_PRIMARY_KEY: &str = "SERIAL_NOT_PRIMARY_KEY";
93
94pub const NEXTVAL_REMOVED: &str = "NEXTVAL_REMOVED";
96pub const CAST_REMOVED: &str = "CAST_REMOVED";
97pub const DEFAULT_UNSUPPORTED: &str = "DEFAULT_UNSUPPORTED";
98
99pub const FK_CYCLE_DETECTED: &str = "FK_CYCLE_DETECTED";
101pub const FK_TARGET_MISSING: &str = "FK_TARGET_MISSING";
102pub const DEFERRABLE_IGNORED: &str = "DEFERRABLE_IGNORED";
103pub const CHECK_EXPRESSION_UNSUPPORTED: &str = "CHECK_EXPRESSION_UNSUPPORTED";
104pub const ALTER_TARGET_MISSING: &str = "ALTER_TARGET_MISSING";
105
106pub const INDEX_METHOD_IGNORED: &str = "INDEX_METHOD_IGNORED";
108pub const PARTIAL_INDEX_UNSUPPORTED: &str = "PARTIAL_INDEX_UNSUPPORTED";
109pub const EXPRESSION_INDEX_UNSUPPORTED: &str = "EXPRESSION_INDEX_UNSUPPORTED";
110
111pub const SCHEMA_PREFIXED: &str = "SCHEMA_PREFIXED";
113
114pub const SEQUENCE_IGNORED: &str = "SEQUENCE_IGNORED";
116
117pub const PARSE_SKIPPED: &str = "PARSE_SKIPPED";