Remove partial entity syntax

This was a bad mistake that we made with the actions API, and we won't
make the same mistake with BlueQL again. PES has been a terrible idea
all along, and it was a leaky abstraction.

Instead, we'll be using a more robust framework for addressing entities.
next
Sayan Nandan 2 years ago
parent 0e67872e69
commit f351be2819
No known key found for this signature in database
GPG Key ID: 42EEDF4AE9D96B54

@ -29,6 +29,7 @@ pub mod cell;
#[cfg(test)]
use std::cell::RefCell;
use {
crate::engine::{
core::model::cell::Datacell,

@ -357,14 +357,6 @@ impl<'a> QueryData<'a> for SubstitutedData<'a> {
#[derive(Debug, PartialEq)]
/// An [`Entity`] represents the location for a specific structure, such as a model
pub enum Entity<'a> {
/// A partial entity is used when switching to a model wrt the currently set space (commonly used
/// when running `use` queries)
///
/// syntax:
/// ```sql
/// :model
/// ```
Partial(Ident<'a>),
/// A single entity is used when switching to a model wrt the currently set space (commonly used
/// when running DML queries)
///
@ -408,21 +400,6 @@ impl<'a> Entity<'a> {
Entity::Single(extract!(&sl[0], Token::Ident(sl) => sl.clone()))
}
#[inline(always)]
/// Parse a partial entity from the given slice
///
/// ## Safety
///
/// Caller guarantees that the token stream matches the exact stream of tokens
/// expected for a partial entity
pub(super) unsafe fn partial_entity_from_slice(sl: &'a [Token]) -> Self {
Entity::Partial(extract!(&sl[1], Token::Ident(sl) => sl.clone()))
}
#[inline(always)]
/// Returns true if the given token stream matches the signature of partial entity syntax
pub(super) fn tokens_with_partial(tok: &[Token]) -> bool {
tok.len() > 1 && tok[0] == Token![:] && tok[1].is_ident()
}
#[inline(always)]
/// Returns true if the given token stream matches the signature of single entity syntax
///
/// ⚠ WARNING: This will pass for full and single
@ -438,7 +415,6 @@ impl<'a> Entity<'a> {
/// Attempt to parse an entity using the given token stream. It also accepts a counter
/// argument to forward the cursor
pub fn parse_from_tokens(tok: &'a [Token], c: &mut usize) -> LangResult<Self> {
let is_partial = Self::tokens_with_partial(tok);
let is_current = Self::tokens_with_single(tok);
let is_full = Self::tokens_with_full(tok);
let r = match () {
@ -450,10 +426,6 @@ impl<'a> Entity<'a> {
*c += 1;
Self::single_entity_from_slice(tok)
},
_ if is_partial => unsafe {
*c += 2;
Self::partial_entity_from_slice(tok)
},
_ => return Err(LangError::ExpectedEntity),
};
Ok(r)

@ -111,16 +111,6 @@ mod ast {
assert!(state.exhausted());
})
}
#[bench]
fn parse_entity_partial(b: &mut Bencher) {
let e = Entity::Partial(Ident::from("user"));
b.iter(|| {
let src = lex_insecure(b":user").unwrap();
let mut i = 0;
assert_eq!(Entity::parse_from_tokens(&src, &mut i).unwrap(), e);
assert_eq!(i, src.len());
});
}
}
mod ddl_queries {

@ -68,8 +68,8 @@ impl<'a> DropSpace<'a> {
#[derive(Debug, PartialEq)]
pub struct DropModel<'a> {
pub(super) entity: Entity<'a>,
pub(super) force: bool,
pub(in crate::engine) entity: Entity<'a>,
pub(in crate::engine) force: bool,
}
impl<'a> DropModel<'a> {

@ -32,12 +32,7 @@ fn entity_current() {
let r = Entity::parse_from_tokens(&t, &mut 0).unwrap();
assert_eq!(r, Entity::Single(Ident::from("hello")))
}
#[test]
fn entity_partial() {
let t = lex_insecure(b":hello").unwrap();
let r = Entity::parse_from_tokens(&t, &mut 0).unwrap();
assert_eq!(r, Entity::Partial(Ident::from("hello")))
}
#[test]
fn entity_full() {
let t = lex_insecure(b"hello.world").unwrap();

Loading…
Cancel
Save