mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-29 05:54:21 +01:00
Accept parsing SET statements with repeated names, like `.. SET (a, a) =
(1, 2)`
This commit is contained in:
@@ -1292,6 +1292,39 @@ impl QualifiedName {
|
||||
}
|
||||
}
|
||||
|
||||
/// Ordered set of column names
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct Names(Vec<Name>);
|
||||
|
||||
impl Names {
|
||||
/// Initialize
|
||||
pub fn new(name: Name) -> Self {
|
||||
let mut dn = Self(Vec::new());
|
||||
dn.0.push(name);
|
||||
dn
|
||||
}
|
||||
/// Single column name
|
||||
pub fn single(name: Name) -> Self {
|
||||
let mut dn = Self(Vec::with_capacity(1));
|
||||
dn.0.push(name);
|
||||
dn
|
||||
}
|
||||
/// Push name
|
||||
pub fn insert(&mut self, name: Name) -> Result<(), ParserError> {
|
||||
self.0.push(name);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Names {
|
||||
type Target = Vec<Name>;
|
||||
|
||||
fn deref(&self) -> &Vec<Name> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Ordered set of distinct column names
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
@@ -1319,6 +1352,7 @@ impl DistinctNames {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for DistinctNames {
|
||||
type Target = IndexSet<Name>;
|
||||
|
||||
@@ -1735,7 +1769,7 @@ pub enum InsertBody {
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct Set {
|
||||
/// column name(s)
|
||||
pub col_names: DistinctNames,
|
||||
pub col_names: Names,
|
||||
/// expression
|
||||
pub expr: Expr,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user