mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-14 01:46:19 +00:00
Distinguish between INT
and INTEGER
types (#525)
* support integer * fmt * Update src/ast/data_type.rs Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
c884fbc388
commit
f29ce10a1a
3 changed files with 23 additions and 5 deletions
|
@ -55,8 +55,12 @@ pub enum DataType {
|
|||
UnsignedSmallInt(Option<u64>),
|
||||
/// Integer with optional display width e.g. INT or INT(11)
|
||||
Int(Option<u64>),
|
||||
/// Integer with optional display width e.g. INTEGER or INTEGER(11)
|
||||
Integer(Option<u64>),
|
||||
/// Unsigned integer with optional display width e.g. INT UNSIGNED or INT(11) UNSIGNED
|
||||
UnsignedInt(Option<u64>),
|
||||
/// Unsigned integer with optional display width e.g. INTGER UNSIGNED or INTEGER(11) UNSIGNED
|
||||
UnsignedInteger(Option<u64>),
|
||||
/// Big integer with optional display width e.g. BIGINT or BIGINT(20)
|
||||
BigInt(Option<u64>),
|
||||
/// Unsigned big integer with optional display width e.g. BIGINT UNSIGNED or BIGINT(20) UNSIGNED
|
||||
|
@ -134,6 +138,12 @@ impl fmt::Display for DataType {
|
|||
DataType::UnsignedInt(zerofill) => {
|
||||
format_type_with_optional_length(f, "INT", zerofill, true)
|
||||
}
|
||||
DataType::Integer(zerofill) => {
|
||||
format_type_with_optional_length(f, "INTEGER", zerofill, false)
|
||||
}
|
||||
DataType::UnsignedInteger(zerofill) => {
|
||||
format_type_with_optional_length(f, "INTEGER", zerofill, true)
|
||||
}
|
||||
DataType::BigInt(zerofill) => {
|
||||
format_type_with_optional_length(f, "BIGINT", zerofill, false)
|
||||
}
|
||||
|
|
|
@ -2859,7 +2859,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(DataType::SmallInt(optional_precision?))
|
||||
}
|
||||
}
|
||||
Keyword::INT | Keyword::INTEGER => {
|
||||
Keyword::INT => {
|
||||
let optional_precision = self.parse_optional_precision();
|
||||
if self.parse_keyword(Keyword::UNSIGNED) {
|
||||
Ok(DataType::UnsignedInt(optional_precision?))
|
||||
|
@ -2867,6 +2867,14 @@ impl<'a> Parser<'a> {
|
|||
Ok(DataType::Int(optional_precision?))
|
||||
}
|
||||
}
|
||||
Keyword::INTEGER => {
|
||||
let optional_precision = self.parse_optional_precision();
|
||||
if self.parse_keyword(Keyword::UNSIGNED) {
|
||||
Ok(DataType::UnsignedInteger(optional_precision?))
|
||||
} else {
|
||||
Ok(DataType::Integer(optional_precision?))
|
||||
}
|
||||
}
|
||||
Keyword::BIGINT => {
|
||||
let optional_precision = self.parse_optional_precision();
|
||||
if self.parse_keyword(Keyword::UNSIGNED) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue