@@ -25,7 +25,7 @@ use graph::data::schema::SCHEMA_TYPE_NAME;
2525use graph:: prelude:: {
2626 format_err, trace, BlockNumber , Entity , EntityChange , EntityChangeOperation , EntityCollection ,
2727 EntityFilter , EntityKey , EntityOrder , EntityRange , Logger , QueryExecutionError , StoreError ,
28- StoreEvent , SubgraphDeploymentId , ValueType ,
28+ StoreEvent , SubgraphDeploymentId , Value , ValueType ,
2929} ;
3030
3131use crate :: block_range:: { BLOCK_RANGE_COLUMN , BLOCK_UNVERSIONED } ;
@@ -472,7 +472,7 @@ impl Layout {
472472 Ok ( ( ) )
473473 }
474474
475- pub fn update_unversioned (
475+ pub fn update_metadata (
476476 & self ,
477477 conn : & PgConnection ,
478478 key : & EntityKey ,
@@ -483,6 +483,24 @@ impl Layout {
483483 Ok ( query. execute ( conn) ?)
484484 }
485485
486+ pub fn overwrite_unversioned (
487+ & self ,
488+ conn : & PgConnection ,
489+ key : & EntityKey ,
490+ mut entity : Entity ,
491+ ) -> Result < usize , StoreError > {
492+ let table = self . table_for_entity ( & key. entity_type ) ?;
493+ // Set any attributes not mentioned in the entity to
494+ // their default (NULL)
495+ for column in table. columns . iter ( ) {
496+ if !entity. contains_key ( & column. field ) {
497+ entity. insert ( column. field . clone ( ) , Value :: Null ) ;
498+ }
499+ }
500+ let query = UpdateQuery :: new ( table, key, & entity) ?;
501+ Ok ( query. execute ( conn) ?)
502+ }
503+
486504 pub fn delete (
487505 & self ,
488506 conn : & PgConnection ,
0 commit comments