Struct ParseResult

Source
pub struct ParseResult {
    pub protobuf: ParseResult,
    pub warnings: Vec<String>,
    pub tables: Vec<(String, Context)>,
    pub aliases: HashMap<String, String>,
    pub cte_names: Vec<String>,
    pub functions: Vec<(String, Context)>,
    pub filter_columns: Vec<(Option<String>, String)>,
}
Expand description

Result from calling parse

Fields§

§protobuf: ParseResult§warnings: Vec<String>§tables: Vec<(String, Context)>§aliases: HashMap<String, String>§cte_names: Vec<String>§functions: Vec<(String, Context)>§filter_columns: Vec<(Option<String>, String)>

Implementations§

Source§

impl ParseResult

Source

pub fn new(protobuf: ParseResult, stderr: String) -> Self

Source

pub fn tables(&self) -> Vec<String>

Returns all referenced tables in the query

Source

pub fn select_tables(&self) -> Vec<String>

Returns only tables that were selected from

Source

pub fn dml_tables(&self) -> Vec<String>

Returns only tables that were modified by the query

Source

pub fn ddl_tables(&self) -> Vec<String>

Returns only tables that were modified by DDL statements

Source

pub fn functions(&self) -> Vec<String>

Returns all function references

Source

pub fn ddl_functions(&self) -> Vec<String>

Returns DDL functions

Source

pub fn call_functions(&self) -> Vec<String>

Returns functions that were called

Source

pub fn deparse(&self) -> Result<String>

Converts the parsed query back into a SQL string

Source

pub fn truncate(&self, max_length: usize) -> Result<String>

Intelligently truncates queries to a max length.

§Example
let query = "INSERT INTO \"x\" (a, b, c, d, e, f) VALUES ($1)";
let result = pg_query::parse(query).unwrap();
assert_eq!(result.truncate(32).unwrap(), "INSERT INTO x (...) VALUES (...)")
Source

pub fn statement_types(&self) -> Vec<&str>

Returns all statement types in the query

Trait Implementations§

Source§

impl Debug for ParseResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.