diff --git a/.gitignore b/.gitignore index c403c34..807922d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target .idea/ +.DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index f6d09af..2cd2caa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 5.1.1 2024-10-30 + +* Make `ParseResult` struct public and implement `Debug` + ## 5.1.0 2024-01-09 * Update to libpg_query 16-5.1.0 diff --git a/Cargo.lock b/Cargo.lock index 0a3d1ca..9865652 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,7 +390,7 @@ dependencies = [ [[package]] name = "pg_query" -version = "5.1.0" +version = "5.1.1" dependencies = [ "bindgen", "cc", diff --git a/Cargo.toml b/Cargo.toml index 23ae4d9..7d1e606 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pg_query" description = "PostgreSQL parser that uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree." -version = "5.1.0" +version = "5.1.1" edition = "2021" documentation = "https://docs.rs/pg_query/" build = "build.rs" diff --git a/src/parse_result.rs b/src/parse_result.rs index 4063d80..cd908b5 100644 --- a/src/parse_result.rs +++ b/src/parse_result.rs @@ -51,6 +51,8 @@ impl protobuf::ParseResult { } } +/// Result from calling [parse] +#[derive(Debug)] pub struct ParseResult { pub protobuf: protobuf::ParseResult, pub warnings: Vec, @@ -215,7 +217,7 @@ impl ParseResult { .collect() } - /// Returns any references to tables in the query + /// Returns all function references pub fn functions(&self) -> Vec { let mut functions = HashSet::new(); self.functions.iter().for_each(|(f, _c)| { @@ -246,6 +248,7 @@ impl ParseResult { .collect() } + /// Converts the parsed query back into a SQL string pub fn deparse(&self) -> Result { crate::deparse(&self.protobuf) } @@ -263,6 +266,7 @@ impl ParseResult { crate::truncate(&self.protobuf, max_length) } + /// Returns all statement types in the query pub fn statement_types(&self) -> Vec<&str> { self.protobuf .stmts