-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(psql): introduce column type
ltree
(#604)
* feat: introduce `LTree` column type * feat: the `ltree` type
- Loading branch information
1 parent
7f5f1af
commit cc8e78c
Showing
8 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::fmt; | ||
|
||
/// PostgreSQL `ltree` extension type. | ||
/// | ||
/// `ltree` stores a raber path which in this struct is represented as the | ||
/// tuple's first value. | ||
/// | ||
/// # PostcreSQL Reference | ||
/// | ||
/// The following set of SQL statements can be used to create a table with | ||
/// a `ltree` column. Here the `ltree` column is called `path`. | ||
/// | ||
/// The `path` column is then populated to generate the tree. | ||
/// | ||
/// ```ignore | ||
/// CREATE TABLE test (path ltree); | ||
/// INSERT INTO test VALUES ('Top'); | ||
/// INSERT INTO test VALUES ('Top.Science'); | ||
/// INSERT INTO test VALUES ('Top.Science.Astronomy'); | ||
/// INSERT INTO test VALUES ('Top.Science.Astronomy.Astrophysics'); | ||
/// INSERT INTO test VALUES ('Top.Science.Astronomy.Cosmology'); | ||
/// INSERT INTO test VALUES ('Top.Hobbies'); | ||
/// INSERT INTO test VALUES ('Top.Hobbies.Amateurs_Astronomy'); | ||
/// INSERT INTO test VALUES ('Top.Collections'); | ||
/// INSERT INTO test VALUES ('Top.Collections.Pictures'); | ||
/// INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy'); | ||
/// INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Stars'); | ||
/// INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Galaxies'); | ||
/// INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Astronauts'); | ||
/// CREATE INDEX path_gist_idx ON test USING GIST (path); | ||
/// CREATE INDEX path_idx ON test USING BTREE (path); | ||
/// ``` | ||
/// | ||
/// The set of queries above will generate the following tree: | ||
/// | ||
/// ```ignore | ||
/// Top | ||
/// / | \ | ||
/// Science Hobbies Collections | ||
/// / | \ | ||
/// Astronomy Amateurs_Astronomy Pictures | ||
/// / \ | | ||
/// Astrophysics Cosmology Astronomy | ||
/// / | \ | ||
/// Galaxies Stars Astronauts | ||
/// ``` | ||
/// [Source][1] | ||
/// | ||
/// [1]: https://www.postgresql.org/docs/current/ltree.html | ||
#[derive(Debug, Clone, Eq, PartialEq)] | ||
pub struct PgLTree; | ||
|
||
impl fmt::Display for PgLTree { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "ltree") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters