|
10 | 10 | // See the License for the specific language governing permissions and
|
11 | 11 | // limitations under the License.
|
12 | 12 |
|
13 |
| -use super::SQLObjectName; |
| 13 | +use super::ObjectName; |
14 | 14 |
|
15 | 15 | /// SQL data types
|
16 | 16 | #[derive(Debug, Clone, PartialEq, Hash)]
|
17 |
| -pub enum SQLType { |
| 17 | +pub enum DataType { |
18 | 18 | /// Fixed-length character type e.g. CHAR(10)
|
19 | 19 | Char(Option<u64>),
|
20 | 20 | /// Variable-length character type e.g. VARCHAR(10)
|
@@ -60,44 +60,44 @@ pub enum SQLType {
|
60 | 60 | /// Bytea
|
61 | 61 | Bytea,
|
62 | 62 | /// Custom type such as enums
|
63 |
| - Custom(SQLObjectName), |
| 63 | + Custom(ObjectName), |
64 | 64 | /// Arrays
|
65 |
| - Array(Box<SQLType>), |
| 65 | + Array(Box<DataType>), |
66 | 66 | }
|
67 | 67 |
|
68 |
| -impl ToString for SQLType { |
| 68 | +impl ToString for DataType { |
69 | 69 | fn to_string(&self) -> String {
|
70 | 70 | match self {
|
71 |
| - SQLType::Char(size) => format_type_with_optional_length("char", size), |
72 |
| - SQLType::Varchar(size) => format_type_with_optional_length("character varying", size), |
73 |
| - SQLType::Uuid => "uuid".to_string(), |
74 |
| - SQLType::Clob(size) => format!("clob({})", size), |
75 |
| - SQLType::Binary(size) => format!("binary({})", size), |
76 |
| - SQLType::Varbinary(size) => format!("varbinary({})", size), |
77 |
| - SQLType::Blob(size) => format!("blob({})", size), |
78 |
| - SQLType::Decimal(precision, scale) => { |
| 71 | + DataType::Char(size) => format_type_with_optional_length("char", size), |
| 72 | + DataType::Varchar(size) => format_type_with_optional_length("character varying", size), |
| 73 | + DataType::Uuid => "uuid".to_string(), |
| 74 | + DataType::Clob(size) => format!("clob({})", size), |
| 75 | + DataType::Binary(size) => format!("binary({})", size), |
| 76 | + DataType::Varbinary(size) => format!("varbinary({})", size), |
| 77 | + DataType::Blob(size) => format!("blob({})", size), |
| 78 | + DataType::Decimal(precision, scale) => { |
79 | 79 | if let Some(scale) = scale {
|
80 | 80 | format!("numeric({},{})", precision.unwrap(), scale)
|
81 | 81 | } else {
|
82 | 82 | format_type_with_optional_length("numeric", precision)
|
83 | 83 | }
|
84 | 84 | }
|
85 |
| - SQLType::Float(size) => format_type_with_optional_length("float", size), |
86 |
| - SQLType::SmallInt => "smallint".to_string(), |
87 |
| - SQLType::Int => "int".to_string(), |
88 |
| - SQLType::BigInt => "bigint".to_string(), |
89 |
| - SQLType::Real => "real".to_string(), |
90 |
| - SQLType::Double => "double".to_string(), |
91 |
| - SQLType::Boolean => "boolean".to_string(), |
92 |
| - SQLType::Date => "date".to_string(), |
93 |
| - SQLType::Time => "time".to_string(), |
94 |
| - SQLType::Timestamp => "timestamp".to_string(), |
95 |
| - SQLType::Interval => "interval".to_string(), |
96 |
| - SQLType::Regclass => "regclass".to_string(), |
97 |
| - SQLType::Text => "text".to_string(), |
98 |
| - SQLType::Bytea => "bytea".to_string(), |
99 |
| - SQLType::Array(ty) => format!("{}[]", ty.to_string()), |
100 |
| - SQLType::Custom(ty) => ty.to_string(), |
| 85 | + DataType::Float(size) => format_type_with_optional_length("float", size), |
| 86 | + DataType::SmallInt => "smallint".to_string(), |
| 87 | + DataType::Int => "int".to_string(), |
| 88 | + DataType::BigInt => "bigint".to_string(), |
| 89 | + DataType::Real => "real".to_string(), |
| 90 | + DataType::Double => "double".to_string(), |
| 91 | + DataType::Boolean => "boolean".to_string(), |
| 92 | + DataType::Date => "date".to_string(), |
| 93 | + DataType::Time => "time".to_string(), |
| 94 | + DataType::Timestamp => "timestamp".to_string(), |
| 95 | + DataType::Interval => "interval".to_string(), |
| 96 | + DataType::Regclass => "regclass".to_string(), |
| 97 | + DataType::Text => "text".to_string(), |
| 98 | + DataType::Bytea => "bytea".to_string(), |
| 99 | + DataType::Array(ty) => format!("{}[]", ty.to_string()), |
| 100 | + DataType::Custom(ty) => ty.to_string(), |
101 | 101 | }
|
102 | 102 | }
|
103 | 103 | }
|
|
0 commit comments