mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 23:14:07 +00:00
Add a mutable visitor (#782)
* Add a mutable visitor This adds the ability to mutate parsed sql queries. Previously, only visitors taking an immutable reference to the visited structures were allowed. * add utility functions for mutable visits * bump version numbers
This commit is contained in:
parent
86d71f2109
commit
524b8a7e7b
14 changed files with 428 additions and 150 deletions
|
@ -32,7 +32,7 @@ use core::str::Chars;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "visitor")]
|
||||
use sqlparser_derive::Visit;
|
||||
use sqlparser_derive::{Visit, VisitMut};
|
||||
|
||||
use crate::ast::DollarQuotedString;
|
||||
use crate::dialect::SnowflakeDialect;
|
||||
|
@ -42,7 +42,7 @@ use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
|
|||
/// SQL Token enumeration
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub enum Token {
|
||||
/// An end-of-file marker, not a real token
|
||||
EOF,
|
||||
|
@ -269,7 +269,7 @@ impl Token {
|
|||
/// A keyword (like SELECT) or an optionally quoted SQL identifier
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub struct Word {
|
||||
/// The value of the token, without the enclosing quotes, and with the
|
||||
/// escape sequences (if any) processed (TODO: escapes are not handled)
|
||||
|
@ -308,7 +308,7 @@ impl Word {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub enum Whitespace {
|
||||
Space,
|
||||
Newline,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue