Skip to content

Commit 12cea37

Browse files
author
Zoran Cvetkov
committed
address review remarks
1 parent 640e7d1 commit 12cea37

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

graph/src/data/store/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
derive::CacheWeight,
44
prelude::{lazy_static, q, r, s, CacheWeight, QueryExecutionError},
55
runtime::gas::{Gas, GasSizeOf},
6-
schema::{EntityKey, EntityType},
6+
schema::{input::VID_FIELD, EntityKey, EntityType},
77
util::intern::{self, AtomPool},
88
util::intern::{Error as InternError, NullValue, Object},
99
};
@@ -913,21 +913,21 @@ impl Entity {
913913
/// Return the VID of this entity and if its missing or of a type different than
914914
/// i64 it panics.
915915
pub fn vid(&self) -> i64 {
916-
self.get("vid")
916+
self.get(VID_FIELD)
917917
.expect("the vid is set")
918918
.as_int8()
919919
.expect("the vid is set to a valid value")
920920
}
921921

922922
/// Sets the VID of the entity. The previous one is returned.
923923
pub fn set_vid(&mut self, value: i64) -> Result<Option<Value>, InternError> {
924-
self.0.insert("vid", value.into())
924+
self.0.insert(VID_FIELD, value.into())
925925
}
926926

927927
/// Sets the VID if it's not already set. Should be used only for tests.
928928
#[cfg(debug_assertions)]
929929
pub fn set_vid_if_empty(&mut self) {
930-
let vid = self.get("vid");
930+
let vid = self.get(VID_FIELD);
931931
if vid.is_none() {
932932
let _ = self.set_vid(100).expect("the vid should be set");
933933
}

graph/src/schema/input/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub(crate) const POI_OBJECT: &str = "Poi$";
3535
const POI_DIGEST: &str = "digest";
3636
/// The name of the PoI attribute for storing the block time
3737
const POI_BLOCK_TIME: &str = "blockTime";
38-
const VID_FIELD: &str = "vid";
38+
pub(crate) const VID_FIELD: &str = "vid";
3939

4040
pub mod kw {
4141
pub const ENTITY: &str = "entity";

graph/src/schema/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub mod ast;
2121
mod entity_key;
2222
mod entity_type;
2323
mod fulltext;
24-
mod input;
24+
pub(crate) mod input;
2525

2626
pub use api::{is_introspection_field, APISchemaError, INTROSPECTION_QUERY_TYPE};
2727

store/postgres/src/relational_queries.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use std::string::ToString;
3838
use crate::block_range::{BoundSide, EntityBlockRange};
3939
use crate::relational::{
4040
Column, ColumnType, Layout, SqlName, Table, BYTE_ARRAY_PREFIX_SIZE, PRIMARY_KEY_COLUMN,
41-
STRING_PREFIX_SIZE,
41+
STRING_PREFIX_SIZE, VID_COLUMN,
4242
};
4343
use crate::{
4444
block_range::{
@@ -539,11 +539,11 @@ impl EntityData {
539539
// table column; those will be things like the
540540
// block_range that `select *` pulls in but that we
541541
// don't care about here
542-
if key == "vid" {
542+
if key == VID_COLUMN {
543543
// VID is not in the input schema but we need it, so deserialize it too
544544
match T::Value::from_column_value(&ColumnType::Int8, json) {
545545
Ok(value) if value.is_null() => None,
546-
Ok(value) => Some(Ok((Word::from("vid"), value))),
546+
Ok(value) => Some(Ok((Word::from(VID_COLUMN), value))),
547547
Err(e) => Some(Err(e)),
548548
}
549549
} else if let Some(column) = table.column(&SqlName::verbatim(key)) {

0 commit comments

Comments
 (0)