From 4a0ec1207cb6bc4133fa8a4c0de99f37215ff9c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= <andres@androbtech.com>
Date: Sun, 3 Nov 2019 03:49:06 -0500
Subject: [PATCH] Preserve anchored meta data for all get queries in the
 pipeline

---
 src/commands/get.rs | 12 +++++++++---
 src/data/meta.rs    | 21 +++++++++++----------
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/commands/get.rs b/src/commands/get.rs
index cda637495e..0176b215dc 100644
--- a/src/commands/get.rs
+++ b/src/commands/get.rs
@@ -97,7 +97,7 @@ pub fn get_column_path(
 
     let res = match value {
         Ok(fetched) => match fetched {
-            Some(Tagged { item: v, tag }) => Ok((v.clone()).tagged(&tag)),
+            Some(Tagged { item: v, .. }) => Ok((v.clone()).tagged(&obj.tag)),
             None => match obj {
                 // If its None check for certain values.
                 Tagged {
@@ -147,8 +147,14 @@ pub fn get(
                             item: Value::Table(rows),
                             ..
                         } => {
-                            for item in rows {
-                                result.push_back(ReturnSuccess::value(item.clone()));
+                            for row in rows {
+                                result.push_back(ReturnSuccess::value(
+                                    Tagged {
+                                        item: row.item,
+                                        tag: Tag::from(&item.tag),
+                                    }
+                                    .map_anchored(&item.tag.anchor),
+                                ))
                             }
                         }
                         other => result
diff --git a/src/data/meta.rs b/src/data/meta.rs
index 2017558cd2..6c9294c573 100644
--- a/src/data/meta.rs
+++ b/src/data/meta.rs
@@ -105,6 +105,17 @@ impl<T> Tagged<T> {
         mapped.tagged(tag)
     }
 
+    pub fn map_anchored(self, anchor: &Option<AnchorLocation>) -> Tagged<T> {
+        let mut tag = self.tag;
+
+        tag.anchor = anchor.clone();
+
+        Tagged {
+            item: self.item,
+            tag: tag,
+        }
+    }
+
     pub fn tag(&self) -> Tag {
         self.tag.clone()
     }
@@ -418,16 +429,6 @@ impl Span {
         self.slice(source).to_string().spanned(*self)
     }
 
-    /*
-    pub fn unknown_with_uuid(uuid: Uuid) -> Span {
-        Span {
-            start: 0,
-            end: 0,
-            source: Some(uuid),
-        }
-    }
-    */
-
     pub fn start(&self) -> usize {
         self.start
     }