From 2019290a0bb2fccc0cb7936d5169ee65ea5b3393 Mon Sep 17 00:00:00 2001 From: Finn Bear Date: Mon, 19 Jun 2023 15:35:08 -0700 Subject: [PATCH] Refactor - reduce redundancy in `Datastore::execute`. (#2095) --- lib/src/kvs/ds.rs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/lib/src/kvs/ds.rs b/lib/src/kvs/ds.rs index 5b6cadd6..fe293433 100644 --- a/lib/src/kvs/ds.rs +++ b/lib/src/kvs/ds.rs @@ -298,33 +298,10 @@ impl Datastore { vars: Variables, strict: bool, ) -> Result, Error> { - // Create a new query options - let mut opt = Options::default(); - // Create a new query executor - let mut exe = Executor::new(self); - // Create a default context - let mut ctx = Context::default(); - // Set the global query timeout - if let Some(timeout) = self.query_timeout { - ctx.add_timeout(timeout); - } - // Start an execution context - let ctx = sess.context(ctx); - // Store the query variables - let ctx = vars.attach(ctx)?; // Parse the SQL query text let ast = sql::parse(txt)?; - // Setup the auth options - opt.auth = sess.au.clone(); - // Setup the live options - opt.live = sess.rt; - // Set current NS and DB - opt.ns = sess.ns(); - opt.db = sess.db(); - // Set strict config - opt.strict = strict; - // Process all statements - exe.execute(ctx, opt, ast).await + // Process the AST + self.process(ast, sess, vars, strict).await } /// Execute a pre-parsed SQL query