Skip to main content

sqlparser_canonicalize/
lib.rs

1#![no_std]
2#![doc = include_str!("../README.md")]
3
4extern crate alloc;
5
6use alloc::string::String;
7
8use thiserror::Error;
9
10mod canonicalize;
11
12pub use canonicalize::{Canonicalizer, hash_canonical};
13
14/// Why a predicate could not be turned into canonical text.
15#[derive(Clone, Debug, Error, Eq, PartialEq)]
16#[non_exhaustive]
17pub enum CanonicalizeError {
18    /// The SQL did not parse. The message comes from the parser.
19    #[error("SQL parse error: {0}")]
20    Parse(String),
21    /// The input was longer than the crate will accept. Shortening it may succeed.
22    #[error("SQL input is longer than {limit} bytes")]
23    InputTooLong { limit: usize },
24    /// The expression nested deeper than the crate will walk. Simplifying it may succeed.
25    #[error("Expression nests deeper than {limit} levels")]
26    TooDeep { limit: usize },
27    /// The predicate has no canonical spelling the parser can read back unchanged, so
28    /// hashing it would risk giving two different predicates one key.
29    #[error("Canonical text would not read back as itself: {0}")]
30    NotRoundTrippable(String),
31    /// Syntax this crate does not canonicalize.
32    #[error("Unsupported SQL: {0}")]
33    Unsupported(String),
34}