Implement hashed implementation of Uniq<Array>
(#1310)
This commit is contained in:
parent
12ded8b066
commit
d1055e6088
68 changed files with 245 additions and 103 deletions
|
@ -5,7 +5,7 @@ use nom::combinator::map;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Algorithm {
|
pub enum Algorithm {
|
||||||
EdDSA,
|
EdDSA,
|
||||||
Es256,
|
Es256,
|
||||||
|
|
|
@ -15,12 +15,13 @@ use nom::character::complete::char;
|
||||||
use nom::combinator::opt;
|
use nom::combinator::opt;
|
||||||
use nom::multi::separated_list0;
|
use nom::multi::separated_list0;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashSet;
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Deserialize, Hash)]
|
||||||
pub struct Array(pub Vec<Value>);
|
pub struct Array(pub Vec<Value>);
|
||||||
|
|
||||||
impl From<Value> for Array {
|
impl From<Value> for Array {
|
||||||
|
@ -318,13 +319,16 @@ pub trait Uniq<T> {
|
||||||
|
|
||||||
impl Uniq<Array> for Array {
|
impl Uniq<Array> for Array {
|
||||||
fn uniq(mut self) -> Array {
|
fn uniq(mut self) -> Array {
|
||||||
for x in (0..self.len()).rev() {
|
let mut set: HashSet<&Value> = HashSet::new();
|
||||||
for y in (x + 1..self.len()).rev() {
|
let mut to_remove: Vec<usize> = Vec::new();
|
||||||
if self[x] == self[y] {
|
for (i, item) in self.iter().enumerate() {
|
||||||
self.remove(y);
|
if !set.insert(item) {
|
||||||
}
|
to_remove.push(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for i in to_remove.iter().rev() {
|
||||||
|
self.remove(*i);
|
||||||
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,6 +356,16 @@ mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn array_empty() {
|
||||||
|
let sql = "[]";
|
||||||
|
let res = array(sql);
|
||||||
|
assert!(res.is_ok());
|
||||||
|
let out = res.unwrap().1;
|
||||||
|
assert_eq!("[]", format!("{}", out));
|
||||||
|
assert_eq!(out.0.len(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn array_normal() {
|
fn array_normal() {
|
||||||
let sql = "[1,2,3]";
|
let sql = "[1,2,3]";
|
||||||
|
@ -381,4 +395,14 @@ mod tests {
|
||||||
assert_eq!("[1, 2, 3 + 1]", format!("{}", out));
|
assert_eq!("[1, 2, 3 + 1]", format!("{}", out));
|
||||||
assert_eq!(out.0.len(), 3);
|
assert_eq!(out.0.len(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn array_fnc_uniq_normal() {
|
||||||
|
let sql = "[1,2,1,3,3,4]";
|
||||||
|
let res = array(sql);
|
||||||
|
assert!(res.is_ok());
|
||||||
|
let out = res.unwrap().1.uniq();
|
||||||
|
assert_eq!("[1, 2, 3, 4]", format!("{}", out));
|
||||||
|
assert_eq!(out.0.len(), 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use nom::combinator::map;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Base {
|
pub enum Base {
|
||||||
Kv,
|
Kv,
|
||||||
Ns,
|
Ns,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Cond(pub Value);
|
pub struct Cond(pub Value);
|
||||||
|
|
||||||
impl Deref for Cond {
|
impl Deref for Cond {
|
||||||
|
|
|
@ -12,7 +12,7 @@ use nom::combinator::map;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Deserialize, Store)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Deserialize, Store, Hash)]
|
||||||
pub enum Constant {
|
pub enum Constant {
|
||||||
MathE,
|
MathE,
|
||||||
MathFrac1Pi,
|
MathFrac1Pi,
|
||||||
|
|
|
@ -18,7 +18,7 @@ use nom::multi::separated_list1;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Data {
|
pub enum Data {
|
||||||
EmptyExpression,
|
EmptyExpression,
|
||||||
SetExpression(Vec<(Idiom, Operator, Value)>),
|
SetExpression(Vec<(Idiom, Operator, Value)>),
|
||||||
|
|
|
@ -14,7 +14,7 @@ use std::ops;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Deserialize, Hash)]
|
||||||
pub struct Datetime(pub DateTime<Utc>);
|
pub struct Datetime(pub DateTime<Utc>);
|
||||||
|
|
||||||
impl Default for Datetime {
|
impl Default for Datetime {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use nom::character::complete::char;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub enum Dir {
|
pub enum Dir {
|
||||||
In,
|
In,
|
||||||
Out,
|
Out,
|
||||||
|
|
|
@ -20,7 +20,7 @@ static SECONDS_PER_DAY: u64 = 24 * SECONDS_PER_HOUR;
|
||||||
static SECONDS_PER_HOUR: u64 = 60 * SECONDS_PER_MINUTE;
|
static SECONDS_PER_HOUR: u64 = 60 * SECONDS_PER_MINUTE;
|
||||||
static SECONDS_PER_MINUTE: u64 = 60;
|
static SECONDS_PER_MINUTE: u64 = 60;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Deserialize, Hash)]
|
||||||
pub struct Duration(pub time::Duration);
|
pub struct Duration(pub time::Duration);
|
||||||
|
|
||||||
impl From<time::Duration> for Duration {
|
impl From<time::Duration> for Duration {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use nom::combinator::map;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Edges {
|
pub struct Edges {
|
||||||
pub dir: Dir,
|
pub dir: Dir,
|
||||||
pub from: Thing,
|
pub from: Thing,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Expression {
|
pub struct Expression {
|
||||||
pub l: Value,
|
pub l: Value,
|
||||||
pub o: Operator,
|
pub o: Operator,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub struct Fetchs(pub Vec<Fetch>);
|
pub struct Fetchs(pub Vec<Fetch>);
|
||||||
|
|
||||||
impl Deref for Fetchs {
|
impl Deref for Fetchs {
|
||||||
|
@ -33,7 +33,7 @@ impl fmt::Display for Fetchs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub struct Fetch(pub Idiom);
|
pub struct Fetch(pub Idiom);
|
||||||
|
|
||||||
impl Deref for Fetch {
|
impl Deref for Fetch {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter, Write};
|
use std::fmt::{self, Display, Formatter, Write};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Fields(pub Vec<Field>);
|
pub struct Fields(pub Vec<Field>);
|
||||||
|
|
||||||
impl Fields {
|
impl Fields {
|
||||||
|
@ -191,7 +191,7 @@ pub fn fields(i: &str) -> IResult<&str, Fields> {
|
||||||
Ok((i, Fields(v)))
|
Ok((i, Fields(v)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub enum Field {
|
pub enum Field {
|
||||||
All,
|
All,
|
||||||
Alone(Value),
|
Alone(Value),
|
||||||
|
|
|
@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Function {
|
pub enum Function {
|
||||||
Future(Value),
|
Future(Value),
|
||||||
Cast(String, Value),
|
Cast(String, Value),
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(clippy::derive_hash_xor_eq)]
|
||||||
|
|
||||||
use crate::sql::comment::mightbespace;
|
use crate::sql::comment::mightbespace;
|
||||||
use crate::sql::common::commas;
|
use crate::sql::common::commas;
|
||||||
use crate::sql::error::IResult;
|
use crate::sql::error::IResult;
|
||||||
|
@ -18,8 +20,8 @@ use nom::sequence::preceded;
|
||||||
use serde::ser::SerializeMap;
|
use serde::ser::SerializeMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt;
|
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
use std::{fmt, hash};
|
||||||
|
|
||||||
const SINGLE: char = '\'';
|
const SINGLE: char = '\'';
|
||||||
const DOUBLE: char = '\"';
|
const DOUBLE: char = '\"';
|
||||||
|
@ -514,6 +516,73 @@ impl Serialize for Geometry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl hash::Hash for Geometry {
|
||||||
|
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||||
|
match self {
|
||||||
|
Geometry::Point(p) => {
|
||||||
|
"Point".hash(state);
|
||||||
|
p.x().to_bits().hash(state);
|
||||||
|
p.y().to_bits().hash(state);
|
||||||
|
}
|
||||||
|
Geometry::Line(l) => {
|
||||||
|
"Line".hash(state);
|
||||||
|
l.points().for_each(|v| {
|
||||||
|
v.x().to_bits().hash(state);
|
||||||
|
v.y().to_bits().hash(state);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Geometry::Polygon(p) => {
|
||||||
|
"Polygon".hash(state);
|
||||||
|
p.exterior().points().for_each(|ext| {
|
||||||
|
ext.x().to_bits().hash(state);
|
||||||
|
ext.y().to_bits().hash(state);
|
||||||
|
});
|
||||||
|
p.interiors().iter().for_each(|int| {
|
||||||
|
int.points().for_each(|v| {
|
||||||
|
v.x().to_bits().hash(state);
|
||||||
|
v.y().to_bits().hash(state);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Geometry::MultiPoint(v) => {
|
||||||
|
"MultiPoint".hash(state);
|
||||||
|
v.0.iter().for_each(|v| {
|
||||||
|
v.x().to_bits().hash(state);
|
||||||
|
v.y().to_bits().hash(state);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Geometry::MultiLine(ml) => {
|
||||||
|
"MultiLine".hash(state);
|
||||||
|
ml.0.iter().for_each(|ls| {
|
||||||
|
ls.points().for_each(|p| {
|
||||||
|
p.x().to_bits().hash(state);
|
||||||
|
p.y().to_bits().hash(state);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Geometry::MultiPolygon(mp) => {
|
||||||
|
"MultiPolygon".hash(state);
|
||||||
|
mp.0.iter().for_each(|p| {
|
||||||
|
p.exterior().points().for_each(|ext| {
|
||||||
|
ext.x().to_bits().hash(state);
|
||||||
|
ext.y().to_bits().hash(state);
|
||||||
|
});
|
||||||
|
p.interiors().iter().for_each(|int| {
|
||||||
|
int.points().for_each(|v| {
|
||||||
|
v.x().to_bits().hash(state);
|
||||||
|
v.y().to_bits().hash(state);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Geometry::Collection(v) => {
|
||||||
|
"GeometryCollection".hash(state);
|
||||||
|
v.iter().for_each(|v| v.hash(state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn geometry(i: &str) -> IResult<&str, Geometry> {
|
pub fn geometry(i: &str) -> IResult<&str, Geometry> {
|
||||||
alt((simple, point, line, polygon, multipoint, multiline, multipolygon, collection))(i)
|
alt((simple, point, line, polygon, multipoint, multiline, multipolygon, collection))(i)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use nom::combinator::opt;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter, Write};
|
use std::fmt::{self, Display, Formatter, Write};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Graph {
|
pub struct Graph {
|
||||||
pub dir: Dir,
|
pub dir: Dir,
|
||||||
pub what: Tables,
|
pub what: Tables,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Groups(pub Vec<Group>);
|
pub struct Groups(pub Vec<Group>);
|
||||||
|
|
||||||
impl Deref for Groups {
|
impl Deref for Groups {
|
||||||
|
@ -35,7 +35,7 @@ impl Display for Groups {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Group(pub Idiom);
|
pub struct Group(pub Idiom);
|
||||||
|
|
||||||
impl Deref for Group {
|
impl Deref for Group {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use nom::combinator::map;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub enum Id {
|
pub enum Id {
|
||||||
Number(i64),
|
Number(i64),
|
||||||
String(String),
|
String(String),
|
||||||
|
|
|
@ -21,7 +21,7 @@ const BRACKET_END: &str = r#"⟩"#;
|
||||||
const BACKTICK: &str = r#"`"#;
|
const BACKTICK: &str = r#"`"#;
|
||||||
const BACKTICK_ESC: &str = r#"\`"#;
|
const BACKTICK_ESC: &str = r#"\`"#;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Ident(pub String);
|
pub struct Ident(pub String);
|
||||||
|
|
||||||
impl From<String> for Ident {
|
impl From<String> for Ident {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Idioms(pub Vec<Idiom>);
|
pub struct Idioms(pub Vec<Idiom>);
|
||||||
|
|
||||||
impl Deref for Idioms {
|
impl Deref for Idioms {
|
||||||
|
@ -40,7 +40,7 @@ pub fn locals(i: &str) -> IResult<&str, Idioms> {
|
||||||
Ok((i, Idioms(v)))
|
Ok((i, Idioms(v)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Idiom(pub Vec<Part>);
|
pub struct Idiom(pub Vec<Part>);
|
||||||
|
|
||||||
impl Deref for Idiom {
|
impl Deref for Idiom {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use nom::multi::separated_list1;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Kind {
|
pub enum Kind {
|
||||||
Any,
|
Any,
|
||||||
Array,
|
Array,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use nom::sequence::tuple;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Limit(pub Value);
|
pub struct Limit(pub Value);
|
||||||
|
|
||||||
impl Limit {
|
impl Limit {
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl Iterator for IntoIter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub enum Model {
|
pub enum Model {
|
||||||
Count(String, u64),
|
Count(String, u64),
|
||||||
Range(String, u64, u64),
|
Range(String, u64, u64),
|
||||||
|
|
|
@ -12,6 +12,7 @@ use nom::number::complete::recognize_float;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
use std::hash;
|
||||||
use std::iter::Product;
|
use std::iter::Product;
|
||||||
use std::iter::Sum;
|
use std::iter::Sum;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
|
@ -386,6 +387,16 @@ impl Ord for Number {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl hash::Hash for Number {
|
||||||
|
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||||
|
match self {
|
||||||
|
Number::Int(v) => v.hash(state),
|
||||||
|
Number::Float(v) => v.to_bits().hash(state),
|
||||||
|
Number::Decimal(v) => v.hash(state),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialEq for Number {
|
impl PartialEq for Number {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Deserialize, Hash)]
|
||||||
pub struct Object(pub BTreeMap<String, Value>);
|
pub struct Object(pub BTreeMap<String, Value>);
|
||||||
|
|
||||||
impl From<BTreeMap<String, Value>> for Object {
|
impl From<BTreeMap<String, Value>> for Object {
|
||||||
|
|
|
@ -2,14 +2,14 @@ use crate::sql::idiom::Idiom;
|
||||||
use crate::sql::value::Value;
|
use crate::sql::value::Value;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Operation {
|
pub struct Operation {
|
||||||
pub op: Op,
|
pub op: Op,
|
||||||
pub path: Idiom,
|
pub path: Idiom,
|
||||||
pub value: Value,
|
pub value: Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub enum Op {
|
pub enum Op {
|
||||||
None,
|
None,
|
||||||
Add,
|
Add,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use nom::combinator::map;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub enum Operator {
|
pub enum Operator {
|
||||||
Or, // ||
|
Or, // ||
|
||||||
And, // &&
|
And, // &&
|
||||||
|
|
|
@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Orders(pub Vec<Order>);
|
pub struct Orders(pub Vec<Order>);
|
||||||
|
|
||||||
impl Deref for Orders {
|
impl Deref for Orders {
|
||||||
|
@ -36,7 +36,7 @@ impl fmt::Display for Orders {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Order {
|
pub struct Order {
|
||||||
pub order: Idiom,
|
pub order: Idiom,
|
||||||
pub random: bool,
|
pub random: bool,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use nom::combinator::map;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Output {
|
pub enum Output {
|
||||||
None,
|
None,
|
||||||
Null,
|
Null,
|
||||||
|
|
|
@ -14,7 +14,7 @@ use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Param(pub Idiom);
|
pub struct Param(pub Idiom);
|
||||||
|
|
||||||
impl From<Idiom> for Param {
|
impl From<Idiom> for Param {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub enum Part {
|
pub enum Part {
|
||||||
All,
|
All,
|
||||||
Last,
|
Last,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub struct Permissions {
|
pub struct Permissions {
|
||||||
pub select: Permission,
|
pub select: Permission,
|
||||||
pub create: Permission,
|
pub create: Permission,
|
||||||
|
@ -131,7 +131,7 @@ fn specific(i: &str) -> IResult<&str, Permissions> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Permission {
|
pub enum Permission {
|
||||||
None,
|
None,
|
||||||
Full,
|
Full,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct Query(pub Statements);
|
pub struct Query(pub Statements);
|
||||||
|
|
||||||
impl Deref for Query {
|
impl Deref for Query {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use nom::character::complete::char;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Range {
|
pub struct Range {
|
||||||
pub tb: String,
|
pub tb: String,
|
||||||
pub beg: Id,
|
pub beg: Id,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Regex(String);
|
pub struct Regex(String);
|
||||||
|
|
||||||
impl From<&str> for Regex {
|
impl From<&str> for Regex {
|
||||||
|
|
|
@ -23,7 +23,7 @@ const BACKTICK_ESC: &str = r#"\`"#;
|
||||||
const OBJECT_BEG: &str = "{";
|
const OBJECT_BEG: &str = "{";
|
||||||
const OBJECT_END: &str = "}";
|
const OBJECT_END: &str = "}";
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Script(pub String);
|
pub struct Script(pub String);
|
||||||
|
|
||||||
impl From<String> for Script {
|
impl From<String> for Script {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Splits(pub Vec<Split>);
|
pub struct Splits(pub Vec<Split>);
|
||||||
|
|
||||||
impl Deref for Splits {
|
impl Deref for Splits {
|
||||||
|
@ -35,7 +35,7 @@ impl fmt::Display for Splits {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Split(pub Idiom);
|
pub struct Split(pub Idiom);
|
||||||
|
|
||||||
impl Deref for Split {
|
impl Deref for Split {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use nom::sequence::tuple;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Start(pub Value);
|
pub struct Start(pub Value);
|
||||||
|
|
||||||
impl Start {
|
impl Start {
|
||||||
|
|
|
@ -35,7 +35,7 @@ use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub struct Statements(pub Vec<Statement>);
|
pub struct Statements(pub Vec<Statement>);
|
||||||
|
|
||||||
impl Deref for Statements {
|
impl Deref for Statements {
|
||||||
|
@ -60,7 +60,7 @@ pub fn statements(i: &str) -> IResult<&str, Statements> {
|
||||||
Ok((i, Statements(v)))
|
Ok((i, Statements(v)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Statement {
|
pub enum Statement {
|
||||||
Use(UseStatement),
|
Use(UseStatement),
|
||||||
Set(SetStatement),
|
Set(SetStatement),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use nom::sequence::tuple;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct BeginStatement;
|
pub struct BeginStatement;
|
||||||
|
|
||||||
impl fmt::Display for BeginStatement {
|
impl fmt::Display for BeginStatement {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use nom::sequence::tuple;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct CancelStatement;
|
pub struct CancelStatement;
|
||||||
|
|
||||||
impl fmt::Display for CancelStatement {
|
impl fmt::Display for CancelStatement {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use nom::sequence::tuple;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct CommitStatement;
|
pub struct CommitStatement;
|
||||||
|
|
||||||
impl fmt::Display for CommitStatement {
|
impl fmt::Display for CommitStatement {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct CreateStatement {
|
pub struct CreateStatement {
|
||||||
pub what: Values,
|
pub what: Values,
|
||||||
pub data: Option<Data>,
|
pub data: Option<Data>,
|
||||||
|
|
|
@ -33,7 +33,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub enum DefineStatement {
|
pub enum DefineStatement {
|
||||||
Namespace(DefineNamespaceStatement),
|
Namespace(DefineNamespaceStatement),
|
||||||
Database(DefineDatabaseStatement),
|
Database(DefineDatabaseStatement),
|
||||||
|
@ -102,7 +102,7 @@ pub fn define(i: &str) -> IResult<&str, DefineStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineNamespaceStatement {
|
pub struct DefineNamespaceStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ fn namespace(i: &str) -> IResult<&str, DefineNamespaceStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineDatabaseStatement {
|
pub struct DefineDatabaseStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ fn database(i: &str) -> IResult<&str, DefineDatabaseStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineLoginStatement {
|
pub struct DefineLoginStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub base: Base,
|
pub base: Base,
|
||||||
|
@ -328,7 +328,7 @@ fn login_hash(i: &str) -> IResult<&str, DefineLoginOption> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineTokenStatement {
|
pub struct DefineTokenStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub base: Base,
|
pub base: Base,
|
||||||
|
@ -447,7 +447,7 @@ fn token(i: &str) -> IResult<&str, DefineTokenStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineScopeStatement {
|
pub struct DefineScopeStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub code: String,
|
pub code: String,
|
||||||
|
@ -530,7 +530,7 @@ fn scope(i: &str) -> IResult<&str, DefineScopeStatement> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum DefineScopeOption {
|
pub enum DefineScopeOption {
|
||||||
Session(Duration),
|
Session(Duration),
|
||||||
Signup(Value),
|
Signup(Value),
|
||||||
|
@ -569,7 +569,7 @@ fn scope_signin(i: &str) -> IResult<&str, DefineScopeOption> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineTableStatement {
|
pub struct DefineTableStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub drop: bool,
|
pub drop: bool,
|
||||||
|
@ -698,7 +698,7 @@ fn table(i: &str) -> IResult<&str, DefineTableStatement> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum DefineTableOption {
|
pub enum DefineTableOption {
|
||||||
Drop,
|
Drop,
|
||||||
View(View),
|
View(View),
|
||||||
|
@ -745,7 +745,7 @@ fn table_permissions(i: &str) -> IResult<&str, DefineTableOption> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineEventStatement {
|
pub struct DefineEventStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub what: Ident,
|
pub what: Ident,
|
||||||
|
@ -824,7 +824,7 @@ fn event(i: &str) -> IResult<&str, DefineEventStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineFieldStatement {
|
pub struct DefineFieldStatement {
|
||||||
pub name: Idiom,
|
pub name: Idiom,
|
||||||
pub what: Ident,
|
pub what: Ident,
|
||||||
|
@ -920,7 +920,7 @@ fn field(i: &str) -> IResult<&str, DefineFieldStatement> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum DefineFieldOption {
|
pub enum DefineFieldOption {
|
||||||
Kind(Kind),
|
Kind(Kind),
|
||||||
Value(Value),
|
Value(Value),
|
||||||
|
@ -966,7 +966,7 @@ fn field_permissions(i: &str) -> IResult<&str, DefineFieldOption> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DefineIndexStatement {
|
pub struct DefineIndexStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub what: Ident,
|
pub what: Ident,
|
||||||
|
|
|
@ -20,7 +20,7 @@ use nom::sequence::tuple;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct DeleteStatement {
|
pub struct DeleteStatement {
|
||||||
pub what: Values,
|
pub what: Values,
|
||||||
pub cond: Option<Cond>,
|
pub cond: Option<Cond>,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use nom::multi::separated_list0;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct IfelseStatement {
|
pub struct IfelseStatement {
|
||||||
pub exprs: Vec<(Value, Value)>,
|
pub exprs: Vec<(Value, Value)>,
|
||||||
pub close: Option<Value>,
|
pub close: Option<Value>,
|
||||||
|
|
|
@ -14,7 +14,7 @@ use nom::bytes::complete::tag_no_case;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub enum InfoStatement {
|
pub enum InfoStatement {
|
||||||
Kv,
|
Kv,
|
||||||
Ns,
|
Ns,
|
||||||
|
|
|
@ -21,7 +21,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct InsertStatement {
|
pub struct InsertStatement {
|
||||||
pub into: Table,
|
pub into: Table,
|
||||||
pub data: Data,
|
pub data: Data,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use nom::bytes::complete::tag_no_case;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct KillStatement {
|
pub struct KillStatement {
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct LiveStatement {
|
pub struct LiveStatement {
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub expr: Fields,
|
pub expr: Fields,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use nom::sequence::tuple;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct OptionStatement {
|
pub struct OptionStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub what: bool,
|
pub what: bool,
|
||||||
|
|
|
@ -13,7 +13,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct OutputStatement {
|
pub struct OutputStatement {
|
||||||
pub what: Value,
|
pub what: Value,
|
||||||
pub fetch: Option<Fetchs>,
|
pub fetch: Option<Fetchs>,
|
||||||
|
|
|
@ -28,7 +28,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RelateStatement {
|
pub struct RelateStatement {
|
||||||
pub kind: Table,
|
pub kind: Table,
|
||||||
pub from: Value,
|
pub from: Value,
|
||||||
|
|
|
@ -18,7 +18,7 @@ use nom::sequence::tuple;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub enum RemoveStatement {
|
pub enum RemoveStatement {
|
||||||
Namespace(RemoveNamespaceStatement),
|
Namespace(RemoveNamespaceStatement),
|
||||||
Database(RemoveDatabaseStatement),
|
Database(RemoveDatabaseStatement),
|
||||||
|
@ -87,7 +87,7 @@ pub fn remove(i: &str) -> IResult<&str, RemoveStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveNamespaceStatement {
|
pub struct RemoveNamespaceStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ fn namespace(i: &str) -> IResult<&str, RemoveNamespaceStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveDatabaseStatement {
|
pub struct RemoveDatabaseStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ fn database(i: &str) -> IResult<&str, RemoveDatabaseStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveLoginStatement {
|
pub struct RemoveLoginStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub base: Base,
|
pub base: Base,
|
||||||
|
@ -278,7 +278,7 @@ fn login(i: &str) -> IResult<&str, RemoveLoginStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveTokenStatement {
|
pub struct RemoveTokenStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub base: Base,
|
pub base: Base,
|
||||||
|
@ -372,7 +372,7 @@ fn token(i: &str) -> IResult<&str, RemoveTokenStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveScopeStatement {
|
pub struct RemoveScopeStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ fn scope(i: &str) -> IResult<&str, RemoveScopeStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveTableStatement {
|
pub struct RemoveTableStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ fn table(i: &str) -> IResult<&str, RemoveTableStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveEventStatement {
|
pub struct RemoveEventStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub what: Ident,
|
pub what: Ident,
|
||||||
|
@ -544,7 +544,7 @@ fn event(i: &str) -> IResult<&str, RemoveEventStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveFieldStatement {
|
pub struct RemoveFieldStatement {
|
||||||
pub name: Idiom,
|
pub name: Idiom,
|
||||||
pub what: Ident,
|
pub what: Ident,
|
||||||
|
@ -604,7 +604,7 @@ fn field(i: &str) -> IResult<&str, RemoveFieldStatement> {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct RemoveIndexStatement {
|
pub struct RemoveIndexStatement {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub what: Ident,
|
pub what: Ident,
|
||||||
|
|
|
@ -26,7 +26,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct SelectStatement {
|
pub struct SelectStatement {
|
||||||
pub expr: Fields,
|
pub expr: Fields,
|
||||||
pub what: Values,
|
pub what: Values,
|
||||||
|
|
|
@ -14,7 +14,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct SetStatement {
|
pub struct SetStatement {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub what: Value,
|
pub what: Value,
|
||||||
|
|
|
@ -20,7 +20,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct UpdateStatement {
|
pub struct UpdateStatement {
|
||||||
pub what: Values,
|
pub what: Values,
|
||||||
pub data: Option<Data>,
|
pub data: Option<Data>,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use nom::bytes::complete::tag_no_case;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||||
pub struct UseStatement {
|
pub struct UseStatement {
|
||||||
pub ns: Option<String>,
|
pub ns: Option<String>,
|
||||||
pub db: Option<String>,
|
pub db: Option<String>,
|
||||||
|
|
|
@ -21,7 +21,7 @@ const SINGLE_ESC: &str = r#"\'"#;
|
||||||
const DOUBLE: char = '"';
|
const DOUBLE: char = '"';
|
||||||
const DOUBLE_ESC: &str = r#"\""#;
|
const DOUBLE_ESC: &str = r#"\""#;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Deserialize, Hash)]
|
||||||
pub struct Strand(pub String);
|
pub struct Strand(pub String);
|
||||||
|
|
||||||
impl From<String> for Strand {
|
impl From<String> for Strand {
|
||||||
|
|
|
@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub enum Subquery {
|
pub enum Subquery {
|
||||||
Value(Value),
|
Value(Value),
|
||||||
Ifelse(IfelseStatement),
|
Ifelse(IfelseStatement),
|
||||||
|
|
|
@ -11,7 +11,7 @@ use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Tables(pub Vec<Table>);
|
pub struct Tables(pub Vec<Table>);
|
||||||
|
|
||||||
impl From<Table> for Tables {
|
impl From<Table> for Tables {
|
||||||
|
@ -38,7 +38,7 @@ pub fn tables(i: &str) -> IResult<&str, Tables> {
|
||||||
Ok((i, Tables(v)))
|
Ok((i, Tables(v)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Table(pub String);
|
pub struct Table(pub String);
|
||||||
|
|
||||||
impl From<String> for Table {
|
impl From<String> for Table {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use serde::ser::SerializeStruct;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Deserialize, Store)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Deserialize, Store, Hash)]
|
||||||
pub struct Thing {
|
pub struct Thing {
|
||||||
pub tb: String,
|
pub tb: String,
|
||||||
pub id: Id,
|
pub id: Id,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Timeout(pub Duration);
|
pub struct Timeout(pub Duration);
|
||||||
|
|
||||||
impl Deref for Timeout {
|
impl Deref for Timeout {
|
||||||
|
|
|
@ -13,7 +13,7 @@ use std::fmt::{self, Display, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Deserialize, Hash)]
|
||||||
pub struct Uuid(pub uuid::Uuid);
|
pub struct Uuid(pub uuid::Uuid);
|
||||||
|
|
||||||
impl From<&str> for Uuid {
|
impl From<&str> for Uuid {
|
||||||
|
|
|
@ -55,7 +55,7 @@ use std::str::FromStr;
|
||||||
|
|
||||||
static MATCHER: Lazy<SkimMatcherV2> = Lazy::new(|| SkimMatcherV2::default().ignore_case());
|
static MATCHER: Lazy<SkimMatcherV2> = Lazy::new(|| SkimMatcherV2::default().ignore_case());
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
pub struct Values(pub Vec<Value>);
|
pub struct Values(pub Vec<Value>);
|
||||||
|
|
||||||
impl Deref for Values {
|
impl Deref for Values {
|
||||||
|
@ -94,7 +94,7 @@ pub fn whats(i: &str) -> IResult<&str, Values> {
|
||||||
Ok((i, Values(v)))
|
Ok((i, Values(v)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Deserialize, Store)]
|
#[derive(Clone, Debug, PartialEq, PartialOrd, Deserialize, Store, Hash)]
|
||||||
pub enum Value {
|
pub enum Value {
|
||||||
None,
|
None,
|
||||||
Null,
|
Null,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use nom::bytes::complete::tag_no_case;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct Version(pub Datetime);
|
pub struct Version(pub Datetime);
|
||||||
|
|
||||||
impl fmt::Display for Version {
|
impl fmt::Display for Version {
|
||||||
|
|
|
@ -10,7 +10,7 @@ use nom::sequence::preceded;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
pub struct View {
|
pub struct View {
|
||||||
pub expr: Fields,
|
pub expr: Fields,
|
||||||
pub what: Tables,
|
pub what: Tables,
|
||||||
|
|
38
lib/tests/function.rs
Normal file
38
lib/tests/function.rs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
mod parse;
|
||||||
|
use parse::Parse;
|
||||||
|
use surrealdb::sql::Value;
|
||||||
|
use surrealdb::Datastore;
|
||||||
|
use surrealdb::Error;
|
||||||
|
use surrealdb::Session;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn array_distinct() -> Result<(), Error> {
|
||||||
|
let sql = r#"
|
||||||
|
SELECT * FROM array::distinct([1, 3, 2, 1, 3, 3, 4]);
|
||||||
|
SELECT * FROM array::distinct([]);
|
||||||
|
SELECT * FROM array::distinct("something");
|
||||||
|
SELECT * FROM array::distinct(["something"]);
|
||||||
|
"#;
|
||||||
|
let dbs = Datastore::new("memory").await?;
|
||||||
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
||||||
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
||||||
|
assert_eq!(res.len(), 4);
|
||||||
|
//
|
||||||
|
let tmp = res.remove(0).result?;
|
||||||
|
let val = Value::parse("[1, 3, 2, 4]");
|
||||||
|
assert_eq!(tmp, val);
|
||||||
|
//
|
||||||
|
let tmp = res.remove(0).result?;
|
||||||
|
let val = Value::parse("[]");
|
||||||
|
assert_eq!(tmp, val);
|
||||||
|
//
|
||||||
|
let tmp = res.remove(0).result?;
|
||||||
|
let val = Value::parse("[NONE]");
|
||||||
|
assert_eq!(tmp, val);
|
||||||
|
//
|
||||||
|
let tmp = res.remove(0).result?;
|
||||||
|
let val = Value::parse("['something']");
|
||||||
|
assert_eq!(tmp, val);
|
||||||
|
//
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
Reference in a new issue