pub struct SchemaValidator { /* private fields */ }Expand description
Validates a LogicalPlan against a schema catalogue.
Build the validator with SchemaValidator::new, register tables via
SchemaValidator::add_table, then call SchemaValidator::validate.
§Example
use oxisql_parse::{parse_one, plan_statement, SchemaValidator};
let mut v = SchemaValidator::new();
v.add_table("users", &["id", "name", "age"]);
let stmt = parse_one("SELECT * FROM users").unwrap();
let plan = plan_statement(&stmt).unwrap();
assert!(v.validate(&plan).is_ok());Implementations§
Source§impl SchemaValidator
impl SchemaValidator
Sourcepub fn add_table(&mut self, name: &str, columns: &[&str])
pub fn add_table(&mut self, name: &str, columns: &[&str])
Register a table with its column list.
Both name and every element of columns are stored in lower-case so
comparisons are case-insensitive.
Sourcepub fn validate(&self, plan: &LogicalPlan) -> Result<(), ValidationError>
pub fn validate(&self, plan: &LogicalPlan) -> Result<(), ValidationError>
Validate plan against the registered schema.
Returns Ok(()) when all referenced tables and columns are known.
§Errors
Returns the first ValidationError encountered during the tree walk.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaValidator
impl RefUnwindSafe for SchemaValidator
impl Send for SchemaValidator
impl Sync for SchemaValidator
impl Unpin for SchemaValidator
impl UnsafeUnpin for SchemaValidator
impl UnwindSafe for SchemaValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more