Skip to content

Commit 64fb24a

Browse files
committed
rename
1 parent 73197df commit 64fb24a

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
- types: a new crate `clickhouse-types` was added to the project workspace. This crate is required for
3737
`RowBinaryWithNamesAndTypes` struct definition validation, as it contains ClickHouse data types AST, as well as
3838
functions and utilities to parse the types out of the ClickHouse server response. ([#221]).
39-
- sql: added `ScopedIdentifier` type to represent scoped identifiers (e.g., `table.column`) safely as bind values
39+
- sql: added `QualifiedIdentifier` type to represent qualified identifiers (e.g., `table.column`) safely as client-side bind values
4040

4141
[#221]: https://github.com/ClickHouse/clickhouse-rs/pull/221
4242
[#245]: https://github.com/ClickHouse/clickhouse-rs/pull/245

src/sql/bind.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ impl Bind for Identifier<'_> {
3232
}
3333
}
3434

35+
/// A variant on `Identifier` which supports qualifying an identifier. For example,
36+
/// `QualifiedIdentifier("foo", "bar")` will emit the SQL `\`foo\`.\`bar\``.
3537
#[derive(Clone, Copy)]
36-
pub struct ScopedIdentifier<'a>(pub &'a str, pub &'a str);
38+
pub struct QualifiedIdentifier<'a>(pub &'a str, pub &'a str);
3739

3840
#[sealed]
39-
impl Bind for ScopedIdentifier<'_> {
41+
impl Bind for QualifiedIdentifier<'_> {
4042
#[inline]
4143
fn write(&self, dst: &mut impl fmt::Write) -> Result<(), String> {
4244
if self.0.len() > 0 {
@@ -49,7 +51,7 @@ impl Bind for ScopedIdentifier<'_> {
4951

5052
#[cfg(test)]
5153
mod tests {
52-
use super::{Bind, ScopedIdentifier};
54+
use super::{Bind, QualifiedIdentifier};
5355

5456
fn bind_to_string(b: impl Bind) -> String {
5557
let mut s = String::new();
@@ -58,23 +60,26 @@ mod tests {
5860
}
5961

6062
#[test]
61-
fn test_scoped_identifier() {
63+
fn test_qualified_identifier() {
6264
assert_eq!(
63-
bind_to_string(ScopedIdentifier("foo", "bar baz")),
65+
bind_to_string(QualifiedIdentifier("foo", "bar baz")),
6466
"`foo`.`bar baz`"
6567
);
66-
assert_eq!(bind_to_string(ScopedIdentifier("", "bar baz")), "`bar baz`");
68+
assert_eq!(
69+
bind_to_string(QualifiedIdentifier("", "bar baz")),
70+
"`bar baz`"
71+
);
6772

6873
assert_eq!(
69-
bind_to_string(ScopedIdentifier("`'.", ".................````")),
74+
bind_to_string(QualifiedIdentifier("`'.", ".................````")),
7075
"`\\`\\'.`.`.................\\`\\`\\`\\``"
7176
);
7277

7378
assert_eq!(
74-
bind_to_string(ScopedIdentifier("クリック", "ハウス")),
79+
bind_to_string(QualifiedIdentifier("クリック", "ハウス")),
7580
"`クリック`.`ハウス`"
7681
);
7782

78-
assert_eq!(bind_to_string(ScopedIdentifier(" ", " ")), "` `.` `");
83+
assert_eq!(bind_to_string(QualifiedIdentifier(" ", " ")), "` `.` `");
7984
}
8085
}

src/sql/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
row::{self, Row},
66
};
77

8-
pub use bind::{Bind, Identifier, ScopedIdentifier};
8+
pub use bind::{Bind, Identifier, QualifiedIdentifier};
99

1010
mod bind;
1111
pub(crate) mod escape;

0 commit comments

Comments
 (0)