Skip to content

Commit 9dcc348

Browse files
committed
Merge remote-tracking branch 'upstream/main' into eper/tag-and-policy-object-name
2 parents 1bf1650 + 239e30a commit 9dcc348

34 files changed

Lines changed: 2611 additions & 564 deletions

examples/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $ cargo run --example cli - [--dialectname]
6363
};
6464

6565
let contents = if filename == "-" {
66-
println!("Parsing from stdin using {:?}", dialect);
66+
println!("Parsing from stdin using {dialect:?}");
6767
let mut buf = Vec::new();
6868
stdin()
6969
.read_to_end(&mut buf)

sqlparser_bench/benches/sqlparser_bench.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,24 @@ fn basic_queries(c: &mut Criterion) {
4545

4646
let large_statement = {
4747
let expressions = (0..1000)
48-
.map(|n| format!("FN_{}(COL_{})", n, n))
48+
.map(|n| format!("FN_{n}(COL_{n})"))
4949
.collect::<Vec<_>>()
5050
.join(", ");
5151
let tables = (0..1000)
52-
.map(|n| format!("TABLE_{}", n))
52+
.map(|n| format!("TABLE_{n}"))
5353
.collect::<Vec<_>>()
5454
.join(" JOIN ");
5555
let where_condition = (0..1000)
56-
.map(|n| format!("COL_{} = {}", n, n))
56+
.map(|n| format!("COL_{n} = {n}"))
5757
.collect::<Vec<_>>()
5858
.join(" OR ");
5959
let order_condition = (0..1000)
60-
.map(|n| format!("COL_{} DESC", n))
60+
.map(|n| format!("COL_{n} DESC"))
6161
.collect::<Vec<_>>()
6262
.join(", ");
6363

6464
format!(
65-
"SELECT {} FROM {} WHERE {} ORDER BY {}",
66-
expressions, tables, where_condition, order_condition
65+
"SELECT {expressions} FROM {tables} WHERE {where_condition} ORDER BY {order_condition}"
6766
)
6867
};
6968

src/ast/data_type.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,14 @@ pub enum DataType {
446446
///
447447
/// [PostgreSQL]: https://www.postgresql.org/docs/9.5/functions-geometry.html
448448
GeometricType(GeometricTypeKind),
449+
/// PostgreSQL text search vectors, see [PostgreSQL].
450+
///
451+
/// [PostgreSQL]: https://www.postgresql.org/docs/17/datatype-textsearch.html
452+
TsVector,
453+
/// PostgreSQL text search query, see [PostgreSQL].
454+
///
455+
/// [PostgreSQL]: https://www.postgresql.org/docs/17/datatype-textsearch.html
456+
TsQuery,
449457
}
450458

451459
impl fmt::Display for DataType {
@@ -658,7 +666,7 @@ impl fmt::Display for DataType {
658666
}
659667
DataType::Enum(vals, bits) => {
660668
match bits {
661-
Some(bits) => write!(f, "ENUM{}", bits),
669+
Some(bits) => write!(f, "ENUM{bits}"),
662670
None => write!(f, "ENUM"),
663671
}?;
664672
write!(f, "(")?;
@@ -706,16 +714,16 @@ impl fmt::Display for DataType {
706714
}
707715
// ClickHouse
708716
DataType::Nullable(data_type) => {
709-
write!(f, "Nullable({})", data_type)
717+
write!(f, "Nullable({data_type})")
710718
}
711719
DataType::FixedString(character_length) => {
712-
write!(f, "FixedString({})", character_length)
720+
write!(f, "FixedString({character_length})")
713721
}
714722
DataType::LowCardinality(data_type) => {
715-
write!(f, "LowCardinality({})", data_type)
723+
write!(f, "LowCardinality({data_type})")
716724
}
717725
DataType::Map(key_data_type, value_data_type) => {
718-
write!(f, "Map({}, {})", key_data_type, value_data_type)
726+
write!(f, "Map({key_data_type}, {value_data_type})")
719727
}
720728
DataType::Tuple(fields) => {
721729
write!(f, "Tuple({})", display_comma_separated(fields))
@@ -737,7 +745,9 @@ impl fmt::Display for DataType {
737745
DataType::NamedTable { name, columns } => {
738746
write!(f, "{} TABLE ({})", name, display_comma_separated(columns))
739747
}
740-
DataType::GeometricType(kind) => write!(f, "{}", kind),
748+
DataType::GeometricType(kind) => write!(f, "{kind}"),
749+
DataType::TsVector => write!(f, "TSVECTOR"),
750+
DataType::TsQuery => write!(f, "TSQUERY"),
741751
}
742752
}
743753
}
@@ -932,7 +942,7 @@ impl fmt::Display for CharacterLength {
932942
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
933943
match self {
934944
CharacterLength::IntegerLength { length, unit } => {
935-
write!(f, "{}", length)?;
945+
write!(f, "{length}")?;
936946
if let Some(unit) = unit {
937947
write!(f, " {unit}")?;
938948
}
@@ -987,7 +997,7 @@ impl fmt::Display for BinaryLength {
987997
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
988998
match self {
989999
BinaryLength::IntegerLength { length } => {
990-
write!(f, "{}", length)?;
1000+
write!(f, "{length}")?;
9911001
}
9921002
BinaryLength::Max => {
9931003
write!(f, "MAX")?;

src/ast/dcl.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl fmt::Display for AlterRoleOperation {
173173
in_database,
174174
} => {
175175
if let Some(database_name) = in_database {
176-
write!(f, "IN DATABASE {} ", database_name)?;
176+
write!(f, "IN DATABASE {database_name} ")?;
177177
}
178178

179179
match config_value {
@@ -187,7 +187,7 @@ impl fmt::Display for AlterRoleOperation {
187187
in_database,
188188
} => {
189189
if let Some(database_name) = in_database {
190-
write!(f, "IN DATABASE {} ", database_name)?;
190+
write!(f, "IN DATABASE {database_name} ")?;
191191
}
192192

193193
match config_name {
@@ -218,15 +218,15 @@ impl fmt::Display for Use {
218218
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
219219
f.write_str("USE ")?;
220220
match self {
221-
Use::Catalog(name) => write!(f, "CATALOG {}", name),
222-
Use::Schema(name) => write!(f, "SCHEMA {}", name),
223-
Use::Database(name) => write!(f, "DATABASE {}", name),
224-
Use::Warehouse(name) => write!(f, "WAREHOUSE {}", name),
225-
Use::Role(name) => write!(f, "ROLE {}", name),
221+
Use::Catalog(name) => write!(f, "CATALOG {name}"),
222+
Use::Schema(name) => write!(f, "SCHEMA {name}"),
223+
Use::Database(name) => write!(f, "DATABASE {name}"),
224+
Use::Warehouse(name) => write!(f, "WAREHOUSE {name}"),
225+
Use::Role(name) => write!(f, "ROLE {name}"),
226226
Use::SecondaryRoles(secondary_roles) => {
227-
write!(f, "SECONDARY ROLES {}", secondary_roles)
227+
write!(f, "SECONDARY ROLES {secondary_roles}")
228228
}
229-
Use::Object(name) => write!(f, "{}", name),
229+
Use::Object(name) => write!(f, "{name}"),
230230
Use::Default => write!(f, "DEFAULT"),
231231
}
232232
}

0 commit comments

Comments
 (0)