From 683c1adbd42ebefcb0e116ce1e81b3a8d417efee Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sat, 1 Apr 2023 19:28:44 +0100 Subject: [PATCH] Ensure `DEFINE TOKEN ON SCOPE` statments are included in database export --- lib/src/kvs/tx.rs | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/src/kvs/tx.rs b/lib/src/kvs/tx.rs index c8a82fcb..8c24b3b4 100644 --- a/lib/src/kvs/tx.rs +++ b/lib/src/kvs/tx.rs @@ -1571,20 +1571,6 @@ impl Transaction { chn.send(bytes!("")).await?; } } - // Output SCOPES - { - let scs = self.all_sc(ns, db).await?; - if !scs.is_empty() { - chn.send(bytes!("-- ------------------------------")).await?; - chn.send(bytes!("-- SCOPES")).await?; - chn.send(bytes!("-- ------------------------------")).await?; - chn.send(bytes!("")).await?; - for sc in scs.iter() { - chn.send(bytes!(format!("{sc};"))).await?; - } - chn.send(bytes!("")).await?; - } - } // Output PARAMS { let pas = self.all_pa(ns, db).await?; @@ -1599,6 +1585,31 @@ impl Transaction { chn.send(bytes!("")).await?; } } + // Output SCOPES + { + let scs = self.all_sc(ns, db).await?; + if !scs.is_empty() { + chn.send(bytes!("-- ------------------------------")).await?; + chn.send(bytes!("-- SCOPES")).await?; + chn.send(bytes!("-- ------------------------------")).await?; + chn.send(bytes!("")).await?; + for sc in scs.iter() { + // Output SCOPE + chn.send(bytes!(format!("{sc};"))).await?; + // Output TOKENS + { + let sts = self.all_st(ns, db, &sc.name).await?; + if !sts.is_empty() { + for st in sts.iter() { + chn.send(bytes!(format!("{st};"))).await?; + } + chn.send(bytes!("")).await?; + } + } + } + chn.send(bytes!("")).await?; + } + } // Output TABLES { let tbs = self.all_tb(ns, db).await?;