Use `Ident` to avoid major future refactors

next
Sayan Nandan 2 years ago
parent 080563cc24
commit 79f8630424
No known key found for this signature in database
GPG Key ID: 42EEDF4AE9D96B54

@ -28,8 +28,8 @@
//! This module provides functions to work with `DEL` queries
use crate::{
corestore::table::DataModel, dbnet::prelude::*,
kvengine::encoding::ENCODING_LUT_ITER, util::compiler,
corestore::table::DataModel, dbnet::prelude::*, kvengine::encoding::ENCODING_LUT_ITER,
util::compiler,
};
action!(

@ -28,8 +28,8 @@
//! This module provides functions to work with `EXISTS` queries
use crate::{
corestore::table::DataModel, dbnet::prelude::*,
kvengine::encoding::ENCODING_LUT_ITER, queryengine::ActionIter, util::compiler,
corestore::table::DataModel, dbnet::prelude::*, kvengine::encoding::ENCODING_LUT_ITER,
queryengine::ActionIter, util::compiler,
};
action!(

@ -30,7 +30,11 @@ action!(
/// Run a `KEYLEN` query
///
/// At this moment, `keylen` only supports a single key
fn keylen(handle: &crate::corestore::Corestore, con: &mut Connection<C, P>, mut act: ActionIter<'a>) {
fn keylen(
handle: &crate::corestore::Corestore,
con: &mut Connection<C, P>,
mut act: ActionIter<'a>,
) {
ensure_length::<P>(act.len(), |len| len == 1)?;
let res: Option<usize> = {
let reader = handle.get_table_with::<P, KVEBlob>()?;

@ -33,7 +33,11 @@ const DEFAULT_COUNT: usize = 10;
action!(
/// Run an `LSKEYS` query
fn lskeys(handle: &crate::corestore::Corestore, con: &mut Connection<C, P>, mut act: ActionIter<'a>) {
fn lskeys(
handle: &crate::corestore::Corestore,
con: &mut Connection<C, P>,
mut act: ActionIter<'a>,
) {
ensure_length::<P>(act.len(), |size| size < 4)?;
let (table, count) = if act.is_empty() {
(get_tbl!(handle, con), DEFAULT_COUNT)

@ -25,8 +25,8 @@
*/
use crate::{
corestore, dbnet::prelude::*, kvengine::encoding::ENCODING_LUT_ITER,
queryengine::ActionIter, util::compiler,
corestore, dbnet::prelude::*, kvengine::encoding::ENCODING_LUT_ITER, queryengine::ActionIter,
util::compiler,
};
action!(

@ -25,13 +25,17 @@
*/
use crate::{
corestore::SharedSlice, dbnet::prelude::*,
kvengine::encoding::ENCODING_LUT_ITER_PAIR, util::compiler,
corestore::SharedSlice, dbnet::prelude::*, kvengine::encoding::ENCODING_LUT_ITER_PAIR,
util::compiler,
};
action!(
/// Run an `MSET` query
fn mset(handle: &crate::corestore::Corestore, con: &mut Connection<C, P>, mut act: ActionIter<'a>) {
fn mset(
handle: &crate::corestore::Corestore,
con: &mut Connection<C, P>,
mut act: ActionIter<'a>,
) {
let howmany = act.len();
ensure_length::<P>(howmany, |size| size & 1 == 0 && size != 0)?;
let kve = handle.get_table_with::<P, KVEBlob>()?;

@ -25,13 +25,17 @@
*/
use crate::{
corestore::SharedSlice, dbnet::prelude::*,
kvengine::encoding::ENCODING_LUT_ITER_PAIR, util::compiler,
corestore::SharedSlice, dbnet::prelude::*, kvengine::encoding::ENCODING_LUT_ITER_PAIR,
util::compiler,
};
action!(
/// Run an `MUPDATE` query
fn mupdate(handle: &crate::corestore::Corestore, con: &mut Connection<C, P>, mut act: ActionIter<'a>) {
fn mupdate(
handle: &crate::corestore::Corestore,
con: &mut Connection<C, P>,
mut act: ActionIter<'a>,
) {
let howmany = act.len();
ensure_length::<P>(howmany, |size| size & 1 == 0 && size != 0)?;
let kve = handle.get_table_with::<P, KVEBlob>()?;

@ -31,7 +31,11 @@ use crate::{corestore::SharedSlice, dbnet::prelude::*, queryengine::ActionIter};
action!(
/// Run a `SET` query
fn set(handle: &crate::corestore::Corestore, con: &mut Connection<C, P>, mut act: ActionIter<'a>) {
fn set(
handle: &crate::corestore::Corestore,
con: &mut Connection<C, P>,
mut act: ActionIter<'a>,
) {
ensure_length::<P>(act.len(), |len| len == 2)?;
if registry::state_okay() {
let did_we = {

@ -108,9 +108,7 @@ pub(super) fn snapshot_and_insert<'a, T: 'a + DerefUnsafeSlice>(
// fine, the keys were non-existent when we looked at them
while let (Some(key), Some(value)) = (act.next(), act.next()) {
unsafe {
if let Some(fresh) =
lowtable.fresh_entry(SharedSlice::new(key.deref_slice()))
{
if let Some(fresh) = lowtable.fresh_entry(SharedSlice::new(key.deref_slice())) {
fresh.insert(SharedSlice::new(value.deref_slice()));
}
// we don't care if some other thread initialized the value we checked

@ -25,15 +25,19 @@
*/
use crate::{
corestore::SharedSlice, dbnet::prelude::*,
kvengine::encoding::ENCODING_LUT_ITER_PAIR, queryengine::ActionIter, util::compiler,
corestore::SharedSlice, dbnet::prelude::*, kvengine::encoding::ENCODING_LUT_ITER_PAIR,
queryengine::ActionIter, util::compiler,
};
action!(
/// Run an `USET` query
///
/// This is like "INSERT or UPDATE"
fn uset(handle: &crate::corestore::Corestore, con: &mut Connection<C, P>, mut act: ActionIter<'a>) {
fn uset(
handle: &crate::corestore::Corestore,
con: &mut Connection<C, P>,
mut act: ActionIter<'a>,
) {
let howmany = act.len();
ensure_length::<P>(howmany, |size| size & 1 == 0 && size != 0)?;
let kve = handle.get_table_with::<P, KVEBlob>()?;

@ -25,10 +25,7 @@
*/
use {
crate::{
dbnet::prelude::*, kvengine::encoding,
storage::v1::sengine::SnapshotActionResult,
},
crate::{dbnet::prelude::*, kvengine::encoding, storage::v1::sengine::SnapshotActionResult},
core::str,
std::path::{Component, PathBuf},
};
@ -36,7 +33,11 @@ use {
action!(
/// Create a snapshot
///
fn mksnap(handle: &crate::corestore::Corestore, con: &mut Connection<C, P>, mut act: ActionIter<'a>) {
fn mksnap(
handle: &crate::corestore::Corestore,
con: &mut Connection<C, P>,
mut act: ActionIter<'a>,
) {
let engine = handle.get_engine();
if act.is_empty() {
// traditional mksnap

@ -25,10 +25,7 @@
*/
use {
crate::{
corestore::booltable::BoolTable, dbnet::prelude::*,
storage::v1::interface::DIR_ROOT,
},
crate::{corestore::booltable::BoolTable, dbnet::prelude::*, storage::v1::interface::DIR_ROOT},
libsky::VERSION,
};

@ -116,5 +116,7 @@ macro_rules! dbgfn {
#[allow(unused_macros)]
macro_rules! void {
() => {()};
() => {
()
};
}

@ -32,7 +32,7 @@ use {
self::traits::ASTNode,
super::{
ddl, dml,
lex::{LitIR, Slice, Token},
lex::{Ident, LitIR, Token},
LangError, LangResult,
},
crate::{
@ -361,7 +361,7 @@ pub enum Entity<'a> {
/// ```sql
/// :model
/// ```
Partial(Slice<'a>),
Partial(Ident<'a>),
/// A single entity is used when switching to a model wrt the currently set space (commonly used
/// when running DML queries)
///
@ -369,7 +369,7 @@ pub enum Entity<'a> {
/// ```sql
/// model
/// ```
Single(Slice<'a>),
Single(Ident<'a>),
/// A full entity is a complete definition to a model wrt to the given space (commonly used with
/// DML queries)
///
@ -377,14 +377,7 @@ pub enum Entity<'a> {
/// ```sql
/// space.model
/// ```
Full(Slice<'a>, Slice<'a>),
}
impl<'a> From<(Slice<'a>, Slice<'a>)> for Entity<'a> {
#[inline(always)]
fn from((space, model): (Slice<'a>, Slice<'a>)) -> Self {
Self::Full(space, model)
}
Full(Ident<'a>, Ident<'a>),
}
impl<'a> Entity<'a> {
@ -543,7 +536,7 @@ pub enum Statement<'a> {
/// - Space is not in active use
DropSpace(ddl::drop::DropSpace<'a>),
/// DDL query to inspect a space (returns a list of models in the space)
InspectSpace(Slice<'a>),
InspectSpace(Ident<'a>),
/// DDL query to inspect a model (returns the model definition)
InspectModel(Entity<'a>),
/// DDL query to inspect all spaces (returns a list of spaces in the database)
@ -578,7 +571,7 @@ pub fn compile<'a, Qd: QueryData<'a>>(tok: &'a [Token], d: Qd) -> LangResult<Sta
_ => compiler::cold_rerr(LangError::UnknownAlterStatement),
},
Token![drop] if state.remaining() >= 2 => ddl::drop::parse_drop(&mut state),
Token::Ident(id) if id.eq_ignore_ascii_case(b"inspect") => {
Token::Ident(id) if id.eq_ignore_ascii_case("inspect") => {
ddl::ins::parse_inspect(&mut state)
}
// DML

@ -37,7 +37,10 @@
extern crate test;
use {crate::engine::ql::tests::lex_insecure, test::Bencher};
use {
crate::engine::ql::{lex::Ident, tests::lex_insecure},
test::Bencher,
};
mod lexer {
use {
@ -85,7 +88,7 @@ mod ast {
};
#[bench]
fn parse_entity_single(b: &mut Bencher) {
let e = Entity::Single(b"user");
let e = Entity::Single(Ident::from("user"));
b.iter(|| {
let src = lex_insecure(b"user").unwrap();
let mut state = State::new(&src, InplaceData::new());
@ -96,7 +99,7 @@ mod ast {
}
#[bench]
fn parse_entity_double(b: &mut Bencher) {
let e = Entity::Full(b"tweeter", b"user");
let e = Entity::Full(Ident::from("tweeter"), Ident::from("user"));
b.iter(|| {
let src = lex_insecure(b"tweeter.user").unwrap();
let mut state = State::new(&src, InplaceData::new());
@ -107,7 +110,7 @@ mod ast {
}
#[bench]
fn parse_entity_partial(b: &mut Bencher) {
let e = Entity::Partial(b"user");
let e = Entity::Partial(Ident::from("user"));
b.iter(|| {
let src = lex_insecure(b":user").unwrap();
let mut i = 0;
@ -130,7 +133,7 @@ mod ddl_queries {
#[bench]
fn use_space(b: &mut Bencher) {
let src = b"use myspace";
let expected = Statement::Use(Entity::Single(b"myspace"));
let expected = Statement::Use(Entity::Single(Ident::from("myspace")));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -139,7 +142,8 @@ mod ddl_queries {
#[bench]
fn use_model(b: &mut Bencher) {
let src = b"use myspace.mymodel";
let expected = Statement::Use(Entity::Full(b"myspace", b"mymodel"));
let expected =
Statement::Use(Entity::Full(Ident::from("myspace"), Ident::from("mymodel")));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -151,7 +155,7 @@ mod ddl_queries {
#[bench]
fn inspect_space(b: &mut Bencher) {
let src = b"inspect space myspace";
let expected = Statement::InspectSpace(b"myspace");
let expected = Statement::InspectSpace(Ident::from("myspace"));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -160,7 +164,7 @@ mod ddl_queries {
#[bench]
fn inspect_model_single_entity(b: &mut Bencher) {
let src = b"inspect model mymodel";
let expected = Statement::InspectModel(Entity::Single(b"mymodel"));
let expected = Statement::InspectModel(Entity::Single(Ident::from("mymodel")));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -169,7 +173,10 @@ mod ddl_queries {
#[bench]
fn inspect_model_full_entity(b: &mut Bencher) {
let src = b"inspect model myspace.mymodel";
let expected = Statement::InspectModel(Entity::Full(b"myspace", b"mymodel"));
let expected = Statement::InspectModel(Entity::Full(
Ident::from("myspace"),
Ident::from("mymodel"),
));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -193,7 +200,7 @@ mod ddl_queries {
#[bench]
fn drop_space(b: &mut Bencher) {
let src = b"drop space myspace";
let expected = Statement::DropSpace(DropSpace::new(b"myspace", false));
let expected = Statement::DropSpace(DropSpace::new(Ident::from("myspace"), false));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -202,7 +209,7 @@ mod ddl_queries {
#[bench]
fn drop_space_force(b: &mut Bencher) {
let src = b"drop space myspace force";
let expected = Statement::DropSpace(DropSpace::new(b"myspace", true));
let expected = Statement::DropSpace(DropSpace::new(Ident::from("myspace"), true));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -211,7 +218,10 @@ mod ddl_queries {
#[bench]
fn drop_model_single(b: &mut Bencher) {
let src = b"drop model mymodel";
let expected = Statement::DropModel(DropModel::new(Entity::Single(b"mymodel"), false));
let expected = Statement::DropModel(DropModel::new(
Entity::Single(Ident::from("mymodel")),
false,
));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -220,7 +230,8 @@ mod ddl_queries {
#[bench]
fn drop_model_single_force(b: &mut Bencher) {
let src = b"drop model mymodel force";
let expected = Statement::DropModel(DropModel::new(Entity::Single(b"mymodel"), true));
let expected =
Statement::DropModel(DropModel::new(Entity::Single(Ident::from("mymodel")), true));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -229,8 +240,10 @@ mod ddl_queries {
#[bench]
fn drop_model_full(b: &mut Bencher) {
let src = b"drop model myspace.mymodel";
let expected =
Statement::DropModel(DropModel::new(Entity::Full(b"myspace", b"mymodel"), false));
let expected = Statement::DropModel(DropModel::new(
Entity::Full(Ident::from("myspace"), Ident::from("mymodel")),
false,
));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);
@ -239,8 +252,10 @@ mod ddl_queries {
#[bench]
fn drop_model_full_force(b: &mut Bencher) {
let src = b"drop model myspace.mymodel force";
let expected =
Statement::DropModel(DropModel::new(Entity::Full(b"myspace", b"mymodel"), true));
let expected = Statement::DropModel(DropModel::new(
Entity::Full(Ident::from("myspace"), Ident::from("mymodel")),
true,
));
b.iter(|| {
let lexed = InsecureLexer::lex(src).unwrap();
assert_eq!(compile(&lexed, InplaceData::new()).unwrap(), expected);

@ -29,7 +29,7 @@ use {
crate::{
engine::ql::{
ast::{QueryData, State},
lex::{Slice, Token},
lex::{Ident, Token},
LangError, LangResult,
},
util::compiler,
@ -39,12 +39,12 @@ use {
#[derive(Debug, PartialEq)]
/// An alter space query with corresponding data
pub struct AlterSpace<'a> {
space_name: Slice<'a>,
space_name: Ident<'a>,
updated_props: Dict,
}
impl<'a> AlterSpace<'a> {
pub fn new(space_name: Slice<'a>, updated_props: Dict) -> Self {
pub fn new(space_name: Ident<'a>, updated_props: Dict) -> Self {
Self {
space_name,
updated_props,
@ -82,13 +82,13 @@ impl<'a> AlterSpace<'a> {
#[derive(Debug, PartialEq)]
pub struct AlterModel<'a> {
model: Slice<'a>,
model: Ident<'a>,
kind: AlterKind<'a>,
}
impl<'a> AlterModel<'a> {
#[inline(always)]
pub fn new(model: Slice<'a>, kind: AlterKind<'a>) -> Self {
pub fn new(model: Ident<'a>, kind: AlterKind<'a>) -> Self {
Self { model, kind }
}
}
@ -97,7 +97,7 @@ impl<'a> AlterModel<'a> {
/// The alter operation kind
pub enum AlterKind<'a> {
Add(Box<[ExpandedField<'a>]>),
Remove(Box<[Slice<'a>]>),
Remove(Box<[Ident<'a>]>),
Update(Box<[ExpandedField<'a>]>),
}

@ -29,7 +29,7 @@ use {
crate::{
engine::ql::{
ast::{QueryData, State},
lex::{Slice, Token},
lex::{Ident, Token},
LangError, LangResult,
},
util::compiler,
@ -40,7 +40,7 @@ use {
/// A space
pub struct CreateSpace<'a> {
/// the space name
pub(super) space_name: Slice<'a>,
pub(super) space_name: Ident<'a>,
/// properties
pub(super) props: Dict,
}
@ -79,7 +79,7 @@ impl<'a> CreateSpace<'a> {
/// A model definition
pub struct CreateModel<'a> {
/// the model name
model_name: Slice<'a>,
model_name: Ident<'a>,
/// the fields
fields: Vec<Field<'a>>,
/// properties
@ -94,7 +94,7 @@ pub struct CreateModel<'a> {
*/
impl<'a> CreateModel<'a> {
pub fn new(model_name: Slice<'a>, fields: Vec<Field<'a>>, props: Dict) -> Self {
pub fn new(model_name: Ident<'a>, fields: Vec<Field<'a>>, props: Dict) -> Self {
Self {
model_name,
fields,

@ -26,28 +26,28 @@
use crate::engine::ql::{
ast::{Entity, QueryData, State, Statement},
lex::{Slice, Token},
lex::{Ident, Token},
LangError, LangResult,
};
#[derive(Debug, PartialEq)]
/// A generic representation of `drop` query
pub struct DropSpace<'a> {
pub(super) space: Slice<'a>,
pub(super) space: Ident<'a>,
pub(super) force: bool,
}
impl<'a> DropSpace<'a> {
#[inline(always)]
/// Instantiate
pub const fn new(space: Slice<'a>, force: bool) -> Self {
pub const fn new(space: Ident<'a>, force: bool) -> Self {
Self { space, force }
}
fn parse<Qd: QueryData<'a>>(state: &mut State<'a, Qd>) -> LangResult<DropSpace<'a>> {
if state.cursor_is_ident() {
let ident = state.fw_read();
// should we force drop?
let force = state.cursor_rounded_eq(Token::Ident(b"force"));
let force = state.cursor_rounded_eq(Token::Ident(Ident::from("force")));
state.cursor_ahead_if(force);
// either `force` or nothing
if state.exhausted() {
@ -77,7 +77,7 @@ impl<'a> DropModel<'a> {
}
fn parse<Qd: QueryData<'a>>(state: &mut State<'a, Qd>) -> LangResult<Self> {
let e = Entity::attempt_process_entity_result(state)?;
let force = state.cursor_rounded_eq(Token::Ident(b"force"));
let force = state.cursor_rounded_eq(Token::Ident(Ident::from("force")));
state.cursor_ahead_if(force);
if state.exhausted() {
return Ok(DropModel::new(e, force));

@ -53,10 +53,10 @@ pub fn parse_inspect<'a, Qd: QueryData<'a>>(
Token![space] if state.cursor_has_ident_rounded() => {
Ok(Statement::InspectSpace(unsafe {
// UNSAFE(@ohsayan): Safe because of the match predicate
extract!(state.fw_read(), Token::Ident(ref space) => space)
extract!(state.fw_read(), Token::Ident(ref space) => *space)
}))
}
Token::Ident(id) if id.eq_ignore_ascii_case(b"spaces") && state.exhausted() => {
Token::Ident(id) if id.eq_ignore_ascii_case("spaces") && state.exhausted() => {
Ok(Statement::InspectSpaces)
}
_ => {

@ -48,12 +48,12 @@ use {
crate::{
engine::ql::{
ast::{QueryData, State},
lex::{LitIR, LitIROwned, Slice, Token},
lex::{Ident, LitIR, LitIROwned, Token},
LangError, LangResult,
},
util::{compiler, MaybeInit},
},
std::{collections::HashMap, str},
std::collections::HashMap,
};
#[derive(Debug, PartialEq)]
@ -163,7 +163,7 @@ where
break;
}
(Token::Ident(id), DictFoldState::CB_OR_IDENT) => {
key = MaybeInit::new(unsafe { str::from_utf8_unchecked(id) });
key = MaybeInit::new(*id);
// found a key, now expect colon
mstate = DictFoldState::COLON;
}
@ -241,13 +241,13 @@ pub(super) fn rfold_tymeta<'a, Qd: QueryData<'a>>(
#[derive(Debug, PartialEq)]
/// A layer contains a type and corresponding metadata
pub struct Layer<'a> {
ty: Slice<'a>,
ty: Ident<'a>,
props: Dict,
}
impl<'a> Layer<'a> {
//// Create a new layer
pub const fn new(ty: Slice<'a>, props: Dict) -> Self {
pub const fn new(ty: Ident<'a>, props: Dict) -> Self {
Self { ty, props }
}
}
@ -332,7 +332,7 @@ fn rfold_layers<'a, Qd: QueryData<'a>>(
/// A field definition
pub struct Field<'a> {
/// the field name
field_name: Slice<'a>,
field_name: Ident<'a>,
/// layers
layers: Vec<Layer<'a>>,
/// is null
@ -342,7 +342,7 @@ pub struct Field<'a> {
}
impl<'a> Field<'a> {
pub fn new(field_name: Slice<'a>, layers: Vec<Layer<'a>>, null: bool, primary: bool) -> Self {
pub fn new(field_name: Ident<'a>, layers: Vec<Layer<'a>>, null: bool, primary: bool) -> Self {
Self {
field_name,
layers,
@ -386,13 +386,13 @@ impl<'a> Field<'a> {
#[derive(Debug, PartialEq)]
/// An [`ExpandedField`] is a full field definition with advanced metadata
pub struct ExpandedField<'a> {
field_name: Slice<'a>,
field_name: Ident<'a>,
layers: Vec<Layer<'a>>,
props: Dict,
}
impl<'a> ExpandedField<'a> {
pub fn new(field_name: Slice<'a>, layers: Vec<Layer<'a>>, props: Dict) -> Self {
pub fn new(field_name: Ident<'a>, layers: Vec<Layer<'a>>, props: Dict) -> Self {
Self {
field_name,
layers,

@ -31,7 +31,7 @@ use {
core::DataType,
ql::{
ast::{Entity, QueryData, State},
lex::Token,
lex::{Ident, Token},
LangError, LangResult,
},
},
@ -115,7 +115,8 @@ fn hashp(key: &[u8]) -> u32 {
% PRODUCER_G.len() as u32
}
#[inline(always)]
fn ldfunc(func: &[u8]) -> Option<ProducerFn> {
fn ldfunc(func: Ident<'_>) -> Option<ProducerFn> {
let func = func.as_bytes();
let ph = hashp(func) as usize;
let min = cmp::min(ph, PRODUCER_F.len() - 1);
let data = PRODUCER_F[min as usize];
@ -126,7 +127,7 @@ fn ldfunc(func: &[u8]) -> Option<ProducerFn> {
}
}
#[inline(always)]
fn ldfunc_exists(func: &[u8]) -> bool {
fn ldfunc_exists(func: Ident<'_>) -> bool {
ldfunc(func).is_some()
}
#[inline(always)]
@ -258,7 +259,7 @@ pub(super) fn parse_data_tuple_syntax<'a, Qd: QueryData<'a>>(
/// Panics if tt is empty
pub(super) fn parse_data_map_syntax<'a, Qd: QueryData<'a>>(
state: &mut State<'a, Qd>,
) -> HashMap<&'a [u8], Option<DataType>> {
) -> HashMap<Ident<'a>, Option<DataType>> {
let mut stop = state.cursor_eq(Token![close {}]);
state.cursor_ahead_if(stop);
let mut data = HashMap::with_capacity(2);
@ -313,7 +314,7 @@ pub(super) fn parse_data_map_syntax<'a, Qd: QueryData<'a>>(
#[derive(Debug, PartialEq)]
pub enum InsertData<'a> {
Ordered(Vec<Option<DataType>>),
Map(HashMap<&'a [u8], Option<DataType>>),
Map(HashMap<Ident<'a>, Option<DataType>>),
}
impl<'a> From<Vec<Option<DataType>>> for InsertData<'a> {
@ -322,8 +323,8 @@ impl<'a> From<Vec<Option<DataType>>> for InsertData<'a> {
}
}
impl<'a> From<HashMap<&'static [u8], Option<DataType>>> for InsertData<'a> {
fn from(m: HashMap<&'static [u8], Option<DataType>>) -> Self {
impl<'a> From<HashMap<Ident<'static>, Option<DataType>>> for InsertData<'a> {
fn from(m: HashMap<Ident<'static>, Option<DataType>>) -> Self {
Self::Map(m)
}
}
@ -445,12 +446,7 @@ mod impls {
let r = parse_data_map_syntax(state);
Ok(Self(
r.into_iter()
.map(|(ident, val)| {
(
String::from_utf8_lossy(ident).to_string().into_boxed_str(),
val,
)
})
.map(|(ident, val)| (ident.to_string().into_boxed_str(), val))
.collect(),
))
}

@ -37,15 +37,15 @@ pub mod upd;
use {
super::{
ast::{QueryData, State},
lex::{LitIR, Token},
lex::{Ident, LitIR, Token},
},
crate::util::compiler,
std::collections::HashMap,
};
#[inline(always)]
unsafe fn read_ident<'a>(tok: &'a Token<'a>) -> &'a [u8] {
extract!(tok, Token::Ident(ref tok) => tok)
unsafe fn read_ident<'a>(tok: &'a Token<'a>) -> Ident<'a> {
extract!(tok, Token::Ident(ref tok) => *tok)
}
#[inline(always)]
@ -63,14 +63,14 @@ fn u(b: bool) -> u8 {
#[derive(Debug, PartialEq)]
pub struct RelationalExpr<'a> {
pub(super) lhs: &'a [u8],
pub(super) lhs: Ident<'a>,
pub(super) rhs: LitIR<'a>,
pub(super) opc: u8,
}
impl<'a> RelationalExpr<'a> {
#[inline(always)]
pub(super) fn new(lhs: &'a [u8], rhs: LitIR<'a>, opc: u8) -> RelationalExpr<'a> {
pub(super) fn new(lhs: Ident<'a>, rhs: LitIR<'a>, opc: u8) -> RelationalExpr<'a> {
Self { lhs, rhs, opc }
}
pub(super) const OP_EQ: u8 = 1;
@ -123,7 +123,7 @@ pub struct WhereClause<'a> {
c: WhereClauseCollection<'a>,
}
type WhereClauseCollection<'a> = HashMap<&'a [u8], RelationalExpr<'a>>;
type WhereClauseCollection<'a> = HashMap<Ident<'a>, RelationalExpr<'a>>;
impl<'a> WhereClause<'a> {
#[inline(always)]

@ -29,7 +29,7 @@ use {
crate::{
engine::ql::{
ast::{Entity, QueryData, State},
lex::Token,
lex::{Ident, Token},
LangError, LangResult,
},
util::{compiler, MaybeInit},
@ -45,7 +45,7 @@ pub struct SelectStatement<'a> {
/// the entity
pub(super) entity: Entity<'a>,
/// fields in order of querying. will be zero when wildcard is set
pub(super) fields: Vec<&'a [u8]>,
pub(super) fields: Vec<Ident<'a>>,
/// whether a wildcard was passed
pub(super) wildcard: bool,
/// where clause
@ -56,7 +56,7 @@ impl<'a> SelectStatement<'a> {
#[inline(always)]
pub(crate) fn new_test(
entity: Entity<'a>,
fields: Vec<&'a [u8]>,
fields: Vec<Ident<'a>>,
wildcard: bool,
clauses: WhereClauseCollection<'a>,
) -> SelectStatement<'a> {
@ -65,7 +65,7 @@ impl<'a> SelectStatement<'a> {
#[inline(always)]
fn new(
entity: Entity<'a>,
fields: Vec<&'a [u8]>,
fields: Vec<Ident<'a>>,
wildcard: bool,
clauses: WhereClauseCollection<'a>,
) -> SelectStatement<'a> {

@ -31,7 +31,7 @@ use {
crate::{
engine::ql::{
ast::{Entity, QueryData, State},
lex::LitIR,
lex::{Ident, LitIR},
LangError, LangResult,
},
util::{compiler, MaybeInit},
@ -64,7 +64,7 @@ static OPERATOR: [Operator; 6] = [
#[derive(Debug, PartialEq)]
pub struct AssignmentExpression<'a> {
/// the LHS ident
pub(super) lhs: &'a [u8],
pub(super) lhs: Ident<'a>,
/// the RHS lit
pub(super) rhs: LitIR<'a>,
/// operator
@ -72,7 +72,7 @@ pub struct AssignmentExpression<'a> {
}
impl<'a> AssignmentExpression<'a> {
pub fn new(lhs: &'a [u8], rhs: LitIR<'a>, operator_fn: Operator) -> Self {
pub fn new(lhs: Ident<'a>, rhs: LitIR<'a>, operator_fn: Operator) -> Self {
Self {
lhs,
rhs,

@ -33,7 +33,7 @@ use {
core::{cmp, fmt, ops::BitOr, slice, str},
};
pub use self::raw::{Keyword, Lit, LitIR, LitIROwned, Symbol, Token};
pub use self::raw::{Ident, Keyword, Lit, LitIR, LitIROwned, Symbol, Token};
pub type Slice<'a> = &'a [u8];
/*

@ -24,13 +24,96 @@
*
*/
use {super::Slice, crate::engine::ql::LangError, core::slice};
use {
super::Slice,
crate::engine::ql::LangError,
core::{borrow::Borrow, fmt, ops::Deref, slice, str},
};
#[repr(transparent)]
#[derive(PartialEq, Eq, Clone, Copy, Hash)]
pub struct Ident<'a>(&'a [u8]);
impl<'a> Ident<'a> {
pub const unsafe fn new(v: &'a [u8]) -> Self {
Self(v)
}
pub const fn new_str(v: &'a str) -> Self {
Self(v.as_bytes())
}
pub fn as_slice(&self) -> &'a [u8] {
self.0
}
pub fn as_str(&self) -> &'a str {
unsafe { str::from_utf8_unchecked(self.0) }
}
}
impl<'a> fmt::Debug for Ident<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl<'a> Deref for Ident<'a> {
type Target = str;
fn deref(&self) -> &Self::Target {
self.as_str()
}
}
impl<'a> PartialEq<[u8]> for Ident<'a> {
fn eq(&self, other: &[u8]) -> bool {
self.0 == other
}
}
impl<'a> PartialEq<Ident<'a>> for [u8] {
fn eq(&self, other: &Ident<'a>) -> bool {
self == other.as_bytes()
}
}
impl<'a> PartialEq<str> for Ident<'a> {
fn eq(&self, other: &str) -> bool {
self.0 == other.as_bytes()
}
}
impl<'a> PartialEq<Ident<'a>> for str {
fn eq(&self, other: &Ident<'a>) -> bool {
self == other.as_str()
}
}
impl<'a> From<&'a str> for Ident<'a> {
fn from(s: &'a str) -> Self {
Self::new_str(s)
}
}
impl<'a> AsRef<[u8]> for Ident<'a> {
fn as_ref(&self) -> &'a [u8] {
self.0
}
}
impl<'a> AsRef<str> for Ident<'a> {
fn as_ref(&self) -> &'a str {
self.as_str()
}
}
impl<'a> Default for Ident<'a> {
fn default() -> Self {
Self::new_str("")
}
}
impl<'a> Borrow<[u8]> for Ident<'a> {
fn borrow(&self) -> &[u8] {
self.0
}
}
impl<'a> Borrow<str> for Ident<'a> {
fn borrow(&self) -> &'a str {
self.as_str()
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum Token<'a> {
Symbol(Symbol),
Keyword(Keyword),
Ident(Slice<'a>),
Ident(Ident<'a>),
#[cfg(test)]
/// A comma that can be ignored (used for fuzzing)
IgnorableComma,
@ -42,7 +125,7 @@ impl<'a> ToString for Token<'a> {
match self {
Self::Symbol(s) => s.to_string(),
Self::Keyword(k) => k.to_string(),
Self::Ident(id) => String::from_utf8_lossy(id).to_string(),
Self::Ident(id) => id.to_string(),
Self::Lit(l) => l.to_string(),
#[cfg(test)]
Self::IgnorableComma => "[IGNORE_COMMA]".to_owned(),
@ -489,7 +572,10 @@ impl<'a> RawLexer<'a> {
Some(kw) => self.tokens.push(kw.into()),
// FIXME(@ohsayan): Uh, mind fixing this? The only advantage is that I can keep the graph *memory* footprint small
None if st == b"true" || st == b"false" => self.push_token(Lit::Bool(st == b"true")),
None => self.tokens.push(Token::Ident(s)),
None => self.tokens.push(unsafe {
// UNSAFE(@ohsayan): scan_ident only returns a valid ident which is always a string
Token::Ident(Ident::new(s))
}),
}
}
#[inline(always)]

@ -397,6 +397,7 @@ mod stmt_insert {
crate::engine::ql::{
ast::{parse_ast_node_full, Entity},
dml::{self, ins::InsertStatement},
lex::Ident,
},
};
@ -410,7 +411,7 @@ mod stmt_insert {
.unwrap();
let r = parse_ast_node_full::<InsertStatement>(&x[1..]).unwrap();
let e = InsertStatement::new(
Entity::Full(b"twitter", b"users"),
Entity::Full(Ident::from("twitter"), Ident::from("users")),
into_array_nullable!["sayan"].to_vec().into(),
);
assert_eq!(e, r);
@ -432,7 +433,7 @@ mod stmt_insert {
.unwrap();
let r = parse_ast_node_full::<InsertStatement>(&x[1..]).unwrap();
let e = InsertStatement::new(
Entity::Full(b"twitter", b"users"),
Entity::Full(Ident::from("twitter"), Ident::from("users")),
into_array_nullable!["sayan", "Sayan", "sayan@example.com", true, 12345, 67890]
.to_vec()
.into(),
@ -459,7 +460,7 @@ mod stmt_insert {
.unwrap();
let r = parse_ast_node_full::<InsertStatement>(&x[1..]).unwrap();
let e = InsertStatement::new(
Entity::Full(b"twitter", b"users"),
Entity::Full(Ident::from("twitter"), Ident::from("users")),
into_array_nullable![
"sayan",
"Sayan",
@ -486,9 +487,9 @@ mod stmt_insert {
.unwrap();
let r = parse_ast_node_full::<InsertStatement>(&tok[1..]).unwrap();
let e = InsertStatement::new(
Entity::Full(b"jotsy", b"app"),
Entity::Full(Ident::from("jotsy"), Ident::from("app")),
dict_nullable! {
"username".as_bytes() => "sayan"
Ident::from("username") => "sayan"
}
.into(),
);
@ -511,14 +512,14 @@ mod stmt_insert {
.unwrap();
let r = parse_ast_node_full::<InsertStatement>(&tok[1..]).unwrap();
let e = InsertStatement::new(
Entity::Full(b"jotsy", b"app"),
Entity::Full(Ident::from("jotsy"), Ident::from("app")),
dict_nullable! {
"username".as_bytes() => "sayan",
"name".as_bytes() => "Sayan",
"email".as_bytes() => "sayan@example.com",
"verified".as_bytes() => true,
"following".as_bytes() => 12345,
"followers".as_bytes() => 67890
Ident::from("username") => "sayan",
Ident::from("name") => "Sayan",
Ident::from("email") => "sayan@example.com",
Ident::from("verified") => true,
Ident::from("following") => 12345,
Ident::from("followers") => 67890
}
.into(),
);
@ -544,17 +545,17 @@ mod stmt_insert {
.unwrap();
let r = parse_ast_node_full::<InsertStatement>(&tok[1..]).unwrap();
let e = InsertStatement::new(
Entity::Full(b"jotsy", b"app"),
Entity::Full(Ident::from("jotsy"), Ident::from("app")),
dict_nullable! {
"username".as_bytes() => "sayan",
"password".as_bytes() => "pass123",
"email".as_bytes() => "sayan@example.com",
"verified".as_bytes() => true,
"following".as_bytes() => 12345,
"followers".as_bytes() => 67890,
"linked_smart_devices".as_bytes() => Null,
"bookmarks".as_bytes() => 12345,
"other_linked_accounts".as_bytes() => Null
Ident::from("username") => "sayan",
"password" => "pass123",
"email" => "sayan@example.com",
"verified" => true,
"following" => 12345,
"followers" => 67890,
"linked_smart_devices" => Null,
"bookmarks" => 12345,
"other_linked_accounts" => Null
}
.into(),
);
@ -566,7 +567,7 @@ mod stmt_insert {
lex_insecure(br#"insert into jotsy.app(@uuidstr(), "sayan", @timesec())"#).unwrap();
let ret = parse_ast_node_full::<InsertStatement>(&tok[1..]).unwrap();
let expected = InsertStatement::new(
Entity::Full(b"jotsy", b"app"),
Entity::Full(Ident::from("jotsy"), Ident::from("app")),
into_array_nullable![dml::ins::T_UUIDSTR, "sayan", dml::ins::T_TIMESEC]
.to_vec()
.into(),
@ -580,11 +581,11 @@ mod stmt_insert {
).unwrap();
let ret = parse_ast_node_full::<InsertStatement>(&tok[1..]).unwrap();
let expected = InsertStatement::new(
Entity::Full(b"jotsy", b"app"),
Entity::Full(Ident::from("jotsy"), Ident::from("app")),
dict_nullable! {
"uuid".as_bytes() => dml::ins::T_UUIDSTR,
"username".as_bytes() => "sayan",
"signup_time".as_bytes() => dml::ins::T_TIMESEC,
"uuid" => dml::ins::T_UUIDSTR,
Ident::from("username") => "sayan",
"signup_time" => dml::ins::T_TIMESEC,
}
.into(),
);
@ -598,7 +599,7 @@ mod stmt_select {
crate::engine::ql::{
ast::{parse_ast_node_full, Entity},
dml::{sel::SelectStatement, RelationalExpr},
lex::LitIR,
lex::{Ident, LitIR},
},
};
#[test]
@ -611,12 +612,12 @@ mod stmt_select {
.unwrap();
let r = parse_ast_node_full::<SelectStatement>(&tok[1..]).unwrap();
let e = SelectStatement::new_test(
Entity::Single(b"users"),
Entity::Single(Ident::from("users")),
[].to_vec(),
true,
dict! {
"username".as_bytes() => RelationalExpr::new(
"username".as_bytes(), LitIR::Str("sayan"), RelationalExpr::OP_EQ
Ident::from("username") => RelationalExpr::new(
Ident::from("username"), LitIR::Str("sayan"), RelationalExpr::OP_EQ
),
},
);
@ -632,12 +633,12 @@ mod stmt_select {
.unwrap();
let r = parse_ast_node_full::<SelectStatement>(&tok[1..]).unwrap();
let e = SelectStatement::new_test(
Entity::Single(b"users"),
[b"field1".as_slice()].to_vec(),
Entity::Single(Ident::from("users")),
[Ident::from("field1")].to_vec(),
false,
dict! {
"username".as_bytes() => RelationalExpr::new(
"username".as_bytes(), LitIR::Str("sayan"), RelationalExpr::OP_EQ
Ident::from("username") => RelationalExpr::new(
Ident::from("username"), LitIR::Str("sayan"), RelationalExpr::OP_EQ
),
},
);
@ -653,12 +654,12 @@ mod stmt_select {
.unwrap();
let r = parse_ast_node_full::<SelectStatement>(&tok[1..]).unwrap();
let e = SelectStatement::new_test(
Entity::Full(b"twitter", b"users"),
[b"field1".as_slice()].to_vec(),
Entity::Full(Ident::from("twitter"), Ident::from("users")),
[Ident::from("field1")].to_vec(),
false,
dict! {
"username".as_bytes() => RelationalExpr::new(
"username".as_bytes(), LitIR::Str("sayan"), RelationalExpr::OP_EQ
Ident::from("username") => RelationalExpr::new(
Ident::from("username"), LitIR::Str("sayan"), RelationalExpr::OP_EQ
),
},
);
@ -674,12 +675,12 @@ mod stmt_select {
.unwrap();
let r = parse_ast_node_full::<SelectStatement>(&tok[1..]).unwrap();
let e = SelectStatement::new_test(
Entity::Full(b"twitter", b"users"),
[b"field1".as_slice(), b"field2".as_slice()].to_vec(),
Entity::Full(Ident::from("twitter"), Ident::from("users")),
[Ident::from("field1"), Ident::from("field2")].to_vec(),
false,
dict! {
"username".as_bytes() => RelationalExpr::new(
"username".as_bytes(), LitIR::Str("sayan"), RelationalExpr::OP_EQ
Ident::from("username") => RelationalExpr::new(
Ident::from("username"), LitIR::Str("sayan"), RelationalExpr::OP_EQ
),
},
);
@ -692,7 +693,7 @@ mod expression_tests {
crate::engine::ql::{
ast::parse_ast_node_full,
dml::upd::{AssignmentExpression, Operator},
lex::LitIR,
lex::{Ident, LitIR},
},
};
#[test]
@ -701,7 +702,11 @@ mod expression_tests {
let r = parse_ast_node_full::<AssignmentExpression>(&src).unwrap();
assert_eq!(
r,
AssignmentExpression::new(b"username", LitIR::Str("sayan"), Operator::Assign)
AssignmentExpression::new(
Ident::from("username"),
LitIR::Str("sayan"),
Operator::Assign
)
);
}
#[test]
@ -710,7 +715,11 @@ mod expression_tests {
let r = parse_ast_node_full::<AssignmentExpression>(&src).unwrap();
assert_eq!(
r,
AssignmentExpression::new(b"followers", LitIR::UInt(100), Operator::AddAssign)
AssignmentExpression::new(
Ident::from("followers"),
LitIR::UInt(100),
Operator::AddAssign
)
);
}
#[test]
@ -719,7 +728,11 @@ mod expression_tests {
let r = parse_ast_node_full::<AssignmentExpression>(&src).unwrap();
assert_eq!(
r,
AssignmentExpression::new(b"following", LitIR::UInt(150), Operator::SubAssign)
AssignmentExpression::new(
Ident::from("following"),
LitIR::UInt(150),
Operator::SubAssign
)
);
}
#[test]
@ -728,7 +741,11 @@ mod expression_tests {
let r = parse_ast_node_full::<AssignmentExpression>(&src).unwrap();
assert_eq!(
r,
AssignmentExpression::new(b"product_qty", LitIR::UInt(2), Operator::MulAssign)
AssignmentExpression::new(
Ident::from("product_qty"),
LitIR::UInt(2),
Operator::MulAssign
)
);
}
#[test]
@ -737,7 +754,11 @@ mod expression_tests {
let r = parse_ast_node_full::<AssignmentExpression>(&src).unwrap();
assert_eq!(
r,
AssignmentExpression::new(b"image_crop_factor", LitIR::UInt(2), Operator::DivAssign)
AssignmentExpression::new(
Ident::from("image_crop_factor"),
LitIR::UInt(2),
Operator::DivAssign
)
);
}
}
@ -750,7 +771,7 @@ mod update_statement {
upd::{AssignmentExpression, Operator, UpdateStatement},
RelationalExpr, WhereClause,
},
lex::LitIR,
lex::{Ident, LitIR},
},
};
#[test]
@ -763,15 +784,15 @@ mod update_statement {
.unwrap();
let r = parse_ast_node_full::<UpdateStatement>(&tok[1..]).unwrap();
let e = UpdateStatement::new(
Entity::Single(b"app"),
Entity::Single(Ident::from("app")),
vec![AssignmentExpression::new(
b"notes",
Ident::from("notes"),
LitIR::Str("this is my new note"),
Operator::AddAssign,
)],
WhereClause::new(dict! {
"username".as_bytes() => RelationalExpr::new(
"username".as_bytes(),
Ident::from("username") => RelationalExpr::new(
Ident::from("username"),
LitIR::Str("sayan"),
RelationalExpr::OP_EQ
)
@ -795,22 +816,22 @@ mod update_statement {
.unwrap();
let r = parse_ast_node_full::<UpdateStatement>(&tok[1..]).unwrap();
let e = UpdateStatement::new(
Entity::Full(b"jotsy", b"app"),
Entity::Full(Ident::from("jotsy"), Ident::from("app")),
vec![
AssignmentExpression::new(
b"notes",
Ident::from("notes"),
LitIR::Str("this is my new note"),
Operator::AddAssign,
),
AssignmentExpression::new(
b"email",
Ident::from("email"),
LitIR::Str("sayan@example.com"),
Operator::Assign,
),
],
WhereClause::new(dict! {
"username".as_bytes() => RelationalExpr::new(
"username".as_bytes(),
Ident::from("username") => RelationalExpr::new(
Ident::from("username"),
LitIR::Str("sayan"),
RelationalExpr::OP_EQ
)
@ -825,7 +846,7 @@ mod delete_stmt {
crate::engine::ql::{
ast::{parse_ast_node_full, Entity},
dml::{del::DeleteStatement, RelationalExpr},
lex::LitIR,
lex::{Ident, LitIR},
},
};
@ -838,10 +859,10 @@ mod delete_stmt {
)
.unwrap();
let e = DeleteStatement::new_test(
Entity::Single(b"users"),
Entity::Single(Ident::from("users")),
dict! {
"username".as_bytes() => RelationalExpr::new(
"username".as_bytes(),
Ident::from("username") => RelationalExpr::new(
Ident::from("username"),
LitIR::Str("sayan"),
RelationalExpr::OP_EQ
)
@ -861,10 +882,10 @@ mod delete_stmt {
)
.unwrap();
let e = DeleteStatement::new_test(
Entity::Full(b"twitter", b"users"),
Entity::Full(Ident::from("twitter"), Ident::from("users")),
dict! {
"username".as_bytes() => RelationalExpr::new(
"username".as_bytes(),
Ident::from("username") => RelationalExpr::new(
Ident::from("username"),
LitIR::Str("sayan"),
RelationalExpr::OP_EQ
)
@ -879,7 +900,11 @@ mod delete_stmt {
mod relational_expr {
use {
super::*,
crate::engine::ql::{ast::parse_ast_node_full, dml::RelationalExpr, lex::LitIR},
crate::engine::ql::{
ast::parse_ast_node_full,
dml::RelationalExpr,
lex::{Ident, LitIR},
},
};
#[test]
@ -890,7 +915,7 @@ mod relational_expr {
r,
RelationalExpr {
rhs: LitIR::UInt(10),
lhs: "primary_key".as_bytes(),
lhs: Ident::from("primary_key"),
opc: RelationalExpr::OP_EQ
}
);
@ -903,7 +928,7 @@ mod relational_expr {
r,
RelationalExpr {
rhs: LitIR::UInt(10),
lhs: "primary_key".as_bytes(),
lhs: Ident::from("primary_key"),
opc: RelationalExpr::OP_NE
}
);
@ -916,7 +941,7 @@ mod relational_expr {
r,
RelationalExpr {
rhs: LitIR::UInt(10),
lhs: "primary_key".as_bytes(),
lhs: Ident::from("primary_key"),
opc: RelationalExpr::OP_GT
}
);
@ -929,7 +954,7 @@ mod relational_expr {
r,
RelationalExpr {
rhs: LitIR::UInt(10),
lhs: "primary_key".as_bytes(),
lhs: Ident::from("primary_key"),
opc: RelationalExpr::OP_GE
}
);
@ -942,7 +967,7 @@ mod relational_expr {
r,
RelationalExpr {
rhs: LitIR::UInt(10),
lhs: "primary_key".as_bytes(),
lhs: Ident::from("primary_key"),
opc: RelationalExpr::OP_LT
}
);
@ -954,7 +979,7 @@ mod relational_expr {
assert_eq!(
r,
RelationalExpr::new(
"primary_key".as_bytes(),
Ident::from("primary_key"),
LitIR::UInt(10),
RelationalExpr::OP_LE
)
@ -967,7 +992,7 @@ mod where_clause {
crate::engine::ql::{
ast::parse_ast_node_full,
dml::{RelationalExpr, WhereClause},
lex::LitIR,
lex::{Ident, LitIR},
},
};
#[test]
@ -979,8 +1004,8 @@ mod where_clause {
)
.unwrap();
let expected = WhereClause::new(dict! {
"x".as_bytes() => RelationalExpr::new(
"x".as_bytes(),
Ident::from("x") => RelationalExpr::new(
Ident::from("x"),
LitIR::UInt(100),
RelationalExpr::OP_EQ
)
@ -996,13 +1021,13 @@ mod where_clause {
)
.unwrap();
let expected = WhereClause::new(dict! {
"userid".as_bytes() => RelationalExpr::new(
"userid".as_bytes(),
Ident::from("userid") => RelationalExpr::new(
Ident::from("userid"),
LitIR::UInt(100),
RelationalExpr::OP_EQ
),
"pass".as_bytes() => RelationalExpr::new(
"pass".as_bytes(),
Ident::from("pass") => RelationalExpr::new(
Ident::from("pass"),
LitIR::Str("password"),
RelationalExpr::OP_EQ
)

@ -25,22 +25,22 @@
*/
use super::*;
use crate::engine::ql::ast::Entity;
use crate::engine::ql::{ast::Entity, lex::Ident};
#[test]
fn entity_current() {
let t = lex_insecure(b"hello").unwrap();
let r = Entity::parse_from_tokens(&t, &mut 0).unwrap();
assert_eq!(r, Entity::Single(b"hello"))
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(b"hello"))
assert_eq!(r, Entity::Partial(Ident::from("hello")))
}
#[test]
fn entity_full() {
let t = lex_insecure(b"hello.world").unwrap();
let r = Entity::parse_from_tokens(&t, &mut 0).unwrap();
assert_eq!(r, Entity::Full(b"hello", b"world"))
assert_eq!(r, Entity::Full(Ident::from("hello"), Ident::from("world")))
}

@ -26,7 +26,7 @@
use {
super::{
super::lex::{Lit, Token},
super::lex::{Ident, Lit, Token},
lex_insecure,
},
crate::engine::ql::LangError,
@ -44,7 +44,10 @@ macro_rules! v(
#[test]
fn lex_ident() {
let src = v!("hello");
assert_eq!(lex_insecure(&src).unwrap(), vec![Token::Ident(b"hello")]);
assert_eq!(
lex_insecure(&src).unwrap(),
vec![Token::Ident(Ident::from("hello"))]
);
}
// literals
@ -416,7 +419,7 @@ mod safequery_params {
}
mod safequery_full_param {
use crate::engine::ql::lex::{LitIR, SafeQueryData, Token};
use crate::engine::ql::lex::{Ident, LitIR, SafeQueryData, Token};
#[test]
fn p_mini() {
let query = b"select * from myapp where username = ?";
@ -430,9 +433,9 @@ mod safequery_full_param {
Token![select],
Token![*],
Token![from],
Token::Ident(b"myapp"),
Token::Ident(Ident::from("myapp")),
Token![where],
Token::Ident(b"username"),
Token::Ident(Ident::from("username")),
Token![=],
Token![?]
]
@ -452,13 +455,13 @@ mod safequery_full_param {
Token![select],
Token![*],
Token![from],
Token::Ident(b"myapp"),
Token::Ident(Ident::from("myapp")),
Token![where],
Token::Ident(b"username"),
Token::Ident(Ident::from("username")),
Token![=],
Token![?],
Token![and],
Token::Ident(b"pass"),
Token::Ident(Ident::from("pass")),
Token![=],
Token![?]
]
@ -482,19 +485,19 @@ mod safequery_full_param {
vec![
Token![select],
Token![$],
Token::Ident(b"notes"),
Token::Ident(Ident::from("notes")),
Token![open []],
Token![~],
Token![?],
Token![close []],
Token![from],
Token::Ident(b"myapp"),
Token::Ident(Ident::from("myapp")),
Token![where],
Token::Ident(b"username"),
Token::Ident(Ident::from("username")),
Token![=],
Token![?],
Token![and],
Token::Ident(b"pass"),
Token::Ident(Ident::from("pass")),
Token![=],
Token![?]
]

@ -25,7 +25,7 @@
*/
use super::{
super::lex::{Lit, Token},
super::lex::{Ident, Lit},
lex_insecure, *,
};
mod inspect {
@ -41,7 +41,7 @@ mod inspect {
let tok = lex_insecure(b"inspect space myspace").unwrap();
assert_eq!(
parse_ast_node_full::<InspectStatementAST>(&tok[1..]).unwrap(),
Statement::InspectSpace(b"myspace")
Statement::InspectSpace(Ident::from("myspace"))
);
}
#[test]
@ -49,12 +49,12 @@ mod inspect {
let tok = lex_insecure(b"inspect model users").unwrap();
assert_eq!(
parse_ast_node_full::<InspectStatementAST>(&tok[1..]).unwrap(),
Statement::InspectModel(Entity::Single(b"users"))
Statement::InspectModel(Entity::Single(Ident::from("users")))
);
let tok = lex_insecure(b"inspect model tweeter.users").unwrap();
assert_eq!(
parse_ast_node_full::<InspectStatementAST>(&tok[1..]).unwrap(),
Statement::InspectModel(Entity::Full(b"tweeter", b"users"))
Statement::InspectModel(Entity::Full(Ident::from("tweeter"), Ident::from("users")))
);
}
#[test]
@ -76,7 +76,7 @@ mod alter_space {
fn alter_space_mini() {
let tok = lex_insecure(b"alter model mymodel with {}").unwrap();
let r = parse_ast_node_full::<AlterSpace>(&tok[2..]).unwrap();
assert_eq!(r, AlterSpace::new(b"mymodel", null_dict! {}));
assert_eq!(r, AlterSpace::new(Ident::from("mymodel"), null_dict! {}));
}
#[test]
fn alter_space() {
@ -93,7 +93,7 @@ mod alter_space {
assert_eq!(
r,
AlterSpace::new(
b"mymodel",
Ident::from("mymodel"),
null_dict! {
"max_entry" => Lit::UnsignedInt(1000),
"driver" => Lit::Str("ts-0.8".into())
@ -142,7 +142,7 @@ mod tymeta {
let tymeta: DictTypeMeta = ASTNode::from_state(&mut state).unwrap();
assert_eq!(state.cursor(), 6);
assert!(Token![:].eq(state.fw_read()));
assert!(Token::Ident(b"string").eq(state.fw_read()));
assert!(Token::Ident(Ident::from("string")).eq(state.fw_read()));
assert!(Token![,].eq(state.fw_read()));
let tymeta2: DictTypeMetaSplit = ASTNode::from_state(&mut state).unwrap();
assert!(state.exhausted());
@ -167,7 +167,7 @@ mod tymeta {
let tymeta: DictTypeMeta = ASTNode::from_state(&mut state).unwrap();
assert_eq!(state.cursor(), 14);
assert!(Token![:].eq(state.fw_read()));
assert!(Token::Ident(b"string").eq(state.fw_read()));
assert!(Token::Ident(Ident::from("string")).eq(state.fw_read()));
assert!(Token![,].eq(state.fw_read()));
let tymeta2: DictTypeMetaSplit = ASTNode::from_state(&mut state).unwrap();
assert!(state.exhausted());
@ -192,7 +192,10 @@ mod layer {
fn layer_mini() {
let tok = lex_insecure(b"string").unwrap();
let layers = parse_ast_node_multiple_full::<Layer>(&tok).unwrap();
assert_eq!(layers, vec![Layer::new(b"string", null_dict! {})]);
assert_eq!(
layers,
vec![Layer::new(Ident::from("string"), null_dict! {})]
);
}
#[test]
fn layer() {
@ -201,7 +204,7 @@ mod layer {
assert_eq!(
layers,
vec![Layer::new(
b"string",
Ident::from("string"),
null_dict! {
"maxlen" => Lit::UnsignedInt(100)
}
@ -215,8 +218,8 @@ mod layer {
assert_eq!(
layers,
vec![
Layer::new(b"string", null_dict! {}),
Layer::new(b"list", null_dict! {})
Layer::new(Ident::from("string"), null_dict! {}),
Layer::new(Ident::from("list"), null_dict! {})
]
);
}
@ -227,9 +230,9 @@ mod layer {
assert_eq!(
layers,
vec![
Layer::new(b"string", null_dict! {}),
Layer::new(Ident::from("string"), null_dict! {}),
Layer::new(
b"list",
Ident::from("list"),
null_dict! {
"unique" => Lit::Bool(true),
"maxlen" => Lit::UnsignedInt(10),
@ -249,14 +252,14 @@ mod layer {
layers,
vec![
Layer::new(
b"string",
Ident::from("string"),
null_dict! {
"ascii_only" => Lit::Bool(true),
"maxlen" => Lit::UnsignedInt(255)
}
),
Layer::new(
b"list",
Ident::from("list"),
null_dict! {
"unique" => Lit::Bool(true),
"maxlen" => Lit::UnsignedInt(10),
@ -278,14 +281,14 @@ mod layer {
}
";
let expected = vec![
Layer::new(b"string", null_dict!()),
Layer::new(Ident::from("string"), null_dict!()),
Layer::new(
b"list",
Ident::from("list"),
null_dict! {
"maxlen" => Lit::UnsignedInt(100),
},
),
Layer::new(b"list", null_dict!("unique" => Lit::Bool(true))),
Layer::new(Ident::from("list"), null_dict!("unique" => Lit::Bool(true))),
];
fuzz_tokens(tok.as_slice(), |should_pass, new_tok| {
let layers = parse_ast_node_multiple_full::<Layer>(&new_tok);
@ -303,6 +306,7 @@ mod fields {
crate::engine::ql::{
ast::parse_ast_node_full,
ddl::syn::{Field, Layer},
lex::Ident,
},
};
#[test]
@ -312,8 +316,8 @@ mod fields {
assert_eq!(
f,
Field::new(
b"username",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("username"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
false,
false
)
@ -326,8 +330,8 @@ mod fields {
assert_eq!(
f,
Field::new(
b"username",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("username"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
false,
true
)
@ -348,9 +352,9 @@ mod fields {
assert_eq!(
f,
Field::new(
b"username",
Ident::from("username"),
[Layer::new(
b"string",
Ident::from("string"),
null_dict! {
"maxlen" => Lit::UnsignedInt(10),
"ascii_only" => Lit::Bool(true),
@ -380,17 +384,17 @@ mod fields {
assert_eq!(
f,
Field::new(
b"notes",
Ident::from("notes"),
[
Layer::new(
b"string",
Ident::from("string"),
null_dict! {
"maxlen" => Lit::UnsignedInt(255),
"ascii_only" => Lit::Bool(true),
}
),
Layer::new(
b"list",
Ident::from("list"),
null_dict! {
"unique" => Lit::Bool(true)
}
@ -431,17 +435,17 @@ mod schemas {
assert_eq!(
model,
CreateModel::new(
b"mymodel",
Ident::from("mymodel"),
vec![
Field::new(
b"username",
vec![Layer::new(b"string", null_dict! {})],
Ident::from("username"),
vec![Layer::new(Ident::from("string"), null_dict! {})],
false,
true,
),
Field::new(
b"password",
vec![Layer::new(b"binary", null_dict! {})],
Ident::from("password"),
vec![Layer::new(Ident::from("binary"), null_dict! {})],
false,
false,
)
@ -470,23 +474,23 @@ mod schemas {
assert_eq!(
model,
CreateModel::new(
b"mymodel",
Ident::from("mymodel"),
vec![
Field::new(
b"username",
vec![Layer::new(b"string", null_dict! {})],
Ident::from("username"),
vec![Layer::new(Ident::from("string"), null_dict! {})],
false,
true,
),
Field::new(
b"password",
vec![Layer::new(b"binary", null_dict! {})],
Ident::from("password"),
vec![Layer::new(Ident::from("binary"), null_dict! {})],
false,
false,
),
Field::new(
b"profile_pic",
vec![Layer::new(b"binary", null_dict! {})],
Ident::from("profile_pic"),
vec![Layer::new(Ident::from("binary"), null_dict! {})],
true,
false,
)
@ -520,32 +524,32 @@ mod schemas {
assert_eq!(
model,
CreateModel::new(
b"mymodel",
Ident::from("mymodel"),
vec![
Field::new(
b"username",
vec![Layer::new(b"string", null_dict! {})],
Ident::from("username"),
vec![Layer::new(Ident::from("string"), null_dict! {})],
false,
true
),
Field::new(
b"password",
vec![Layer::new(b"binary", null_dict! {})],
Ident::from("password"),
vec![Layer::new(Ident::from("binary"), null_dict! {})],
false,
false
),
Field::new(
b"profile_pic",
vec![Layer::new(b"binary", null_dict! {})],
Ident::from("profile_pic"),
vec![Layer::new(Ident::from("binary"), null_dict! {})],
true,
false
),
Field::new(
b"notes",
Ident::from("notes"),
vec![
Layer::new(b"string", null_dict! {}),
Layer::new(Ident::from("string"), null_dict! {}),
Layer::new(
b"list",
Ident::from("list"),
null_dict! {
"unique" => Lit::Bool(true)
}
@ -589,32 +593,32 @@ mod schemas {
assert_eq!(
model,
CreateModel::new(
b"mymodel",
Ident::from("mymodel"),
vec![
Field::new(
b"username",
vec![Layer::new(b"string", null_dict! {})],
Ident::from("username"),
vec![Layer::new(Ident::from("string"), null_dict! {})],
false,
true
),
Field::new(
b"password",
vec![Layer::new(b"binary", null_dict! {})],
Ident::from("password"),
vec![Layer::new(Ident::from("binary"), null_dict! {})],
false,
false
),
Field::new(
b"profile_pic",
vec![Layer::new(b"binary", null_dict! {})],
Ident::from("profile_pic"),
vec![Layer::new(Ident::from("binary"), null_dict! {})],
true,
false
),
Field::new(
b"notes",
Ident::from("notes"),
vec![
Layer::new(b"string", null_dict! {}),
Layer::new(Ident::from("string"), null_dict! {}),
Layer::new(
b"list",
Ident::from("list"),
null_dict! {
"unique" => Lit::Bool(true)
}
@ -647,8 +651,8 @@ mod dict_field_syntax {
assert_eq!(
ef,
ExpandedField::new(
b"username",
vec![Layer::new(b"string", null_dict! {})],
Ident::from("username"),
vec![Layer::new(Ident::from("string"), null_dict! {})],
null_dict! {}
)
)
@ -668,8 +672,8 @@ mod dict_field_syntax {
assert_eq!(
ef,
ExpandedField::new(
b"username",
vec![Layer::new(b"string", null_dict! {})],
Ident::from("username"),
vec![Layer::new(Ident::from("string"), null_dict! {})],
null_dict! {
"nullable" => Lit::Bool(false),
},
@ -695,9 +699,9 @@ mod dict_field_syntax {
assert_eq!(
ef,
ExpandedField::new(
b"username",
Ident::from("username"),
vec![Layer::new(
b"string",
Ident::from("string"),
null_dict! {
"minlen" => Lit::UnsignedInt(6),
"maxlen" => Lit::UnsignedInt(255),
@ -731,16 +735,16 @@ mod dict_field_syntax {
assert_eq!(
ef,
ExpandedField::new(
b"notes",
Ident::from("notes"),
vec![
Layer::new(
b"string",
Ident::from("string"),
null_dict! {
"ascii_only" => Lit::Bool(true),
}
),
Layer::new(
b"list",
Ident::from("list"),
null_dict! {
"unique" => Lit::Bool(true),
}
@ -759,6 +763,7 @@ mod alter_model_remove {
use crate::engine::ql::{
ast::parse_ast_node_full,
ddl::alt::{AlterKind, AlterModel},
lex::Ident,
};
#[test]
fn alter_mini() {
@ -767,8 +772,8 @@ mod alter_model_remove {
assert_eq!(
remove,
AlterModel::new(
b"mymodel",
AlterKind::Remove(Box::from([b"myfield".as_slice()]))
Ident::from("mymodel"),
AlterKind::Remove(Box::from([Ident::from("myfield")]))
)
);
}
@ -779,8 +784,8 @@ mod alter_model_remove {
assert_eq!(
remove,
AlterModel::new(
b"mymodel",
AlterKind::Remove(Box::from([b"myfield".as_slice()]))
Ident::from("mymodel"),
AlterKind::Remove(Box::from([Ident::from("myfield")]))
)
);
}
@ -793,12 +798,12 @@ mod alter_model_remove {
assert_eq!(
remove,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Remove(Box::from([
b"myfield1".as_slice(),
b"myfield2".as_slice(),
b"myfield3".as_slice(),
b"myfield4".as_slice(),
Ident::from("myfield1"),
Ident::from("myfield2"),
Ident::from("myfield3"),
Ident::from("myfield4"),
]))
)
);
@ -824,11 +829,11 @@ mod alter_model_add {
assert_eq!(
parse_ast_node_full::<AlterModel>(&tok[2..]).unwrap(),
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Add(
[ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {},
)]
.into()
@ -848,11 +853,11 @@ mod alter_model_add {
assert_eq!(
r,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Add(
[ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {
"nullable" => Lit::Bool(true)
},
@ -874,11 +879,11 @@ mod alter_model_add {
assert_eq!(
r,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Add(
[ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {
"nullable" => Lit::Bool(true)
},
@ -914,27 +919,27 @@ mod alter_model_add {
assert_eq!(
r,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Add(
[
ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {
"nullable" => Lit::Bool(true)
},
),
ExpandedField::new(
b"another",
Ident::from("another"),
[
Layer::new(
b"string",
Ident::from("string"),
null_dict! {
"maxlen" => Lit::UnsignedInt(255)
}
),
Layer::new(
b"list",
Ident::from("list"),
null_dict! {
"unique" => Lit::Bool(true)
},
@ -974,11 +979,11 @@ mod alter_model_update {
assert_eq!(
r,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Update(
[ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {},
)]
.into()
@ -998,11 +1003,11 @@ mod alter_model_update {
assert_eq!(
r,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Update(
[ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {},
)]
.into()
@ -1027,11 +1032,11 @@ mod alter_model_update {
assert_eq!(
r,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Update(
[ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {
"nullable" => Lit::Bool(true)
},
@ -1061,19 +1066,19 @@ mod alter_model_update {
assert_eq!(
r,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Update(
[
ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {
"nullable" => Lit::Bool(true)
},
),
ExpandedField::new(
b"myfield2",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield2"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {},
)
]
@ -1104,20 +1109,20 @@ mod alter_model_update {
assert_eq!(
r,
AlterModel::new(
b"mymodel",
Ident::from("mymodel"),
AlterKind::Update(
[
ExpandedField::new(
b"myfield",
[Layer::new(b"string", null_dict! {})].into(),
Ident::from("myfield"),
[Layer::new(Ident::from("string"), null_dict! {})].into(),
null_dict! {
"nullable" => Lit::Bool(true)
},
),
ExpandedField::new(
b"myfield2",
Ident::from("myfield2"),
[Layer::new(
b"string",
Ident::from("string"),
null_dict! {"maxlen" => Lit::UnsignedInt(255)}
)]
.into(),
@ -1137,6 +1142,7 @@ mod ddl_other_query_tests {
crate::engine::ql::{
ast::{parse_ast_node_full, Entity, Statement},
ddl::drop::{DropModel, DropSpace, DropStatementAST},
lex::Ident,
},
};
#[test]
@ -1144,7 +1150,7 @@ mod ddl_other_query_tests {
let src = lex_insecure(br"drop space myspace").unwrap();
assert_eq!(
parse_ast_node_full::<DropStatementAST>(&src[1..]).unwrap(),
Statement::DropSpace(DropSpace::new(b"myspace", false))
Statement::DropSpace(DropSpace::new(Ident::from("myspace"), false))
);
}
#[test]
@ -1152,7 +1158,7 @@ mod ddl_other_query_tests {
let src = lex_insecure(br"drop space myspace force").unwrap();
assert_eq!(
parse_ast_node_full::<DropStatementAST>(&src[1..]).unwrap(),
Statement::DropSpace(DropSpace::new(b"myspace", true))
Statement::DropSpace(DropSpace::new(Ident::from("myspace"), true))
);
}
#[test]
@ -1160,7 +1166,10 @@ mod ddl_other_query_tests {
let src = lex_insecure(br"drop model mymodel").unwrap();
assert_eq!(
parse_ast_node_full::<DropStatementAST>(&src[1..]).unwrap(),
Statement::DropModel(DropModel::new(Entity::Single(b"mymodel"), false))
Statement::DropModel(DropModel::new(
Entity::Single(Ident::from("mymodel")),
false
))
);
}
#[test]
@ -1168,7 +1177,7 @@ mod ddl_other_query_tests {
let src = lex_insecure(br"drop model mymodel force").unwrap();
assert_eq!(
parse_ast_node_full::<DropStatementAST>(&src[1..]).unwrap(),
Statement::DropModel(DropModel::new(Entity::Single(b"mymodel"), true))
Statement::DropModel(DropModel::new(Entity::Single(Ident::from("mymodel")), true))
);
}
}

@ -32,13 +32,13 @@ mod macros;
mod auth;
mod ddl_tests;
mod inspect_tests;
mod issue_tests;
mod kvengine;
mod kvengine_encoding;
mod kvengine_list;
mod persist;
mod pipeline;
mod snapshot;
mod issue_tests;
mod tls {
use skytable::{query, Element};

@ -251,9 +251,7 @@ pub fn run_bench(servercfg: &ServerConfig, matches: ArgMatches) -> BResult<()> {
binfo!("Finished benchmarks. Cleaning up ...");
let r: Element = misc_connection.run_query(Query::from("drop model default.tmpbench force"))?;
if r != Element::RespCode(RespCode::Okay) {
return Err(Error::Runtime(
"failed to clean up after benchmarks".into(),
));
return Err(Error::Runtime("failed to clean up after benchmarks".into()));
}
if config::should_output_messages() {

Loading…
Cancel
Save