pub fn to_entity(self, layout: &Layout) -> Result<Entity, StoreError> {
        let table = layout.table_for_entity(&self.entity)?;

        use serde_json::Value as j;
        match self.data {
            j::Object(map) => {
                let mut entity = Entity::new();
                entity.insert(
                    "__typename".to_owned(),
                    graph::prelude::Value::from(self.entity),
                );
                for (key, json) in map {
                    // Simply ignore keys that do not have an underlying table
                    // column; those will be things like the block_range that
                    // is used internally for versioning
                    if key == "g$parent_id" {
                        let value = Self::value_from_json(&ColumnType::String, json)?;
                        entity.insert("g$parent_id".to_owned(), value);
                    } else if let Some(column) = table.column(&SqlName::from_snake_case(key)).ok() {
                        let value = Self::value_from_json(&column.column_type, json)?;
                        if value != Value::Null {
                            entity.insert(column.field.clone(), value);
                        }
                    }
                }
                Ok(entity)
            }
            _ => unreachable!(
                "we use `to_json` in our queries, and will therefore always get an object back"
            ),
        }
    }
/// Map the `EntityData` to an entity using the schema information
/// in `Layout`
Map the `EntityData` to an entity using the schema information
in `Layout`
Map the ` EntityData ` to an entity using the schema information in ` Layout `
pub fn to_entity(self, layout: &Layout) -> Result<Entity, StoreError> {
        let table = layout.table_for_entity(&self.entity)?;
        use serde_json::Value as j;
        match self.data {
            j::Object(map) => {
                let mut entity = Entity::new();
                entity.insert(
                    "__typename".to_owned(),
                    graph::prelude::Value::from(self.entity),
                );
                for (key, json) in map {
                    // Simply ignore keys that do not have an underlying table
                    // column; those will be things like the block_range that
                    // is used internally for versioning
                    if key == "g$parent_id" {
                        let value = Self::value_from_json(&ColumnType::String, json)?;
                        entity.insert("g$parent_id".to_owned(), value);
                    } else if let Some(column) = table.column(&SqlName::from_snake_case(key)).ok() {
                        let value = Self::value_from_json(&column.column_type, json)?;
                        if value != Value::Null {
                            entity.insert(column.field.clone(), value);
                        }
                    }
                }
                Ok(entity)
            }
            _ => unreachable!(
                "we use `to_json` in our queries, and will therefore always get an object back"
            ),
        }
    }
pub fn to_entity ( self , layout : & Layout ) -> Result < Entity , StoreError > { let table = layout . table_for_entity ( & self . entity ) ? ; use serde_json :: Value as j ; match self . data { j :: Object ( map ) => { let mut entity = Entity :: new ( ) ; entity . insert ( " " . to_owned ( ) , graph :: prelude :: Value :: from ( self . entity ) , ) ; for ( key , json ) in map { // Simply ignore keys that do not have an underlying table // column; those will be things like the block_range that // is used internally for versioning if key == " " { let value = Self :: value_from_json ( & ColumnType :: String , json ) ? ; entity . insert ( " " . to_owned ( ) , value ) ; } else if let Some ( column ) = table . column ( & SqlName :: from_snake_case ( key ) ) . ok ( ) { let value = Self :: value_from_json ( & column . column_type , json ) ? ; if value != Value :: Null { entity . insert ( column . field . clone ( ) , value ) ; } } } Ok ( entity ) } _ => unreachable ! ( " " ) , } }
Map the `EntityData` to an entity using the schema information
in `Layout`
Map the ` EntityData ` to an entity using the schema information in ` Layout `
self
layout
&Layout
self
layout
&Layout