@@ -138,6 +138,7 @@ pub type Attribute = String;
138138pub const BYTES_SCALAR : & str = "Bytes" ;
139139pub const BIG_INT_SCALAR : & str = "BigInt" ;
140140pub const BIG_DECIMAL_SCALAR : & str = "BigDecimal" ;
141+ pub const INT8_SCALAR : & str = "Int8" ;
141142
142143#[ derive( Clone , Debug , PartialEq ) ]
143144pub enum ValueType {
@@ -146,6 +147,7 @@ pub enum ValueType {
146147 Bytes ,
147148 BigDecimal ,
148149 Int ,
150+ Int8 ,
149151 String ,
150152}
151153
@@ -159,6 +161,7 @@ impl FromStr for ValueType {
159161 "Bytes" => Ok ( ValueType :: Bytes ) ,
160162 "BigDecimal" => Ok ( ValueType :: BigDecimal ) ,
161163 "Int" => Ok ( ValueType :: Int ) ,
164+ "Int8" => Ok ( ValueType :: Int8 ) ,
162165 "String" | "ID" => Ok ( ValueType :: String ) ,
163166 s => Err ( anyhow ! ( "Type not available in this context: {}" , s) ) ,
164167 }
@@ -180,6 +183,7 @@ impl ValueType {
180183pub enum Value {
181184 String ( String ) ,
182185 Int ( i32 ) ,
186+ Int8 ( i64 ) ,
183187 BigDecimal ( scalar:: BigDecimal ) ,
184188 Bool ( bool ) ,
185189 List ( Vec < Value > ) ,
@@ -217,6 +221,9 @@ impl stable_hash_legacy::StableHash for Value {
217221 Int ( inner) => {
218222 stable_hash_legacy:: StableHash :: stable_hash ( inner, sequence_number, state)
219223 }
224+ Int8 ( inner) => {
225+ stable_hash_legacy:: StableHash :: stable_hash ( inner, sequence_number, state)
226+ }
220227 BigDecimal ( inner) => {
221228 stable_hash_legacy:: StableHash :: stable_hash ( inner, sequence_number, state)
222229 }
@@ -275,6 +282,10 @@ impl StableHash for Value {
275282 inner. stable_hash ( field_address. child ( 0 ) , state) ;
276283 7
277284 }
285+ Int8 ( inner) => {
286+ inner. stable_hash ( field_address. child ( 0 ) , state) ;
287+ 8
288+ }
278289 } ;
279290
280291 state. write ( field_address, & [ variant] )
@@ -318,6 +329,9 @@ impl Value {
318329 QueryExecutionError :: ValueParseError ( "BigInt" . to_string ( ) , format ! ( "{}" , e) )
319330 } ) ?) ,
320331 BIG_DECIMAL_SCALAR => Value :: BigDecimal ( scalar:: BigDecimal :: from_str ( s) ?) ,
332+ INT8_SCALAR => Value :: Int8 ( s. parse :: < i64 > ( ) . map_err ( |_| {
333+ QueryExecutionError :: ValueParseError ( "Int8" . to_string ( ) , format ! ( "{}" , s) )
334+ } ) ?) ,
321335 _ => Value :: String ( s. clone ( ) ) ,
322336 }
323337 }
@@ -409,6 +423,7 @@ impl Value {
409423 Value :: Bool ( _) => "Boolean" . to_owned ( ) ,
410424 Value :: Bytes ( _) => "Bytes" . to_owned ( ) ,
411425 Value :: Int ( _) => "Int" . to_owned ( ) ,
426+ Value :: Int8 ( _) => "Int8" . to_owned ( ) ,
412427 Value :: List ( values) => {
413428 if let Some ( v) = values. first ( ) {
414429 format ! ( "[{}]" , v. type_name( ) )
@@ -429,6 +444,7 @@ impl Value {
429444 | ( Value :: Bool ( _) , ValueType :: Boolean )
430445 | ( Value :: Bytes ( _) , ValueType :: Bytes )
431446 | ( Value :: Int ( _) , ValueType :: Int )
447+ | ( Value :: Int8 ( _) , ValueType :: Int8 )
432448 | ( Value :: Null , _) => true ,
433449 ( Value :: List ( values) , _) if is_list => values
434450 . iter ( )
@@ -450,6 +466,7 @@ impl fmt::Display for Value {
450466 match self {
451467 Value :: String ( s) => s. to_string( ) ,
452468 Value :: Int ( i) => i. to_string( ) ,
469+ Value :: Int8 ( i) => i. to_string( ) ,
453470 Value :: BigDecimal ( d) => d. to_string( ) ,
454471 Value :: Bool ( b) => b. to_string( ) ,
455472 Value :: Null => "null" . to_string( ) ,
@@ -467,6 +484,7 @@ impl fmt::Debug for Value {
467484 match self {
468485 Self :: String ( s) => f. debug_tuple ( "String" ) . field ( s) . finish ( ) ,
469486 Self :: Int ( i) => f. debug_tuple ( "Int" ) . field ( i) . finish ( ) ,
487+ Self :: Int8 ( i) => f. debug_tuple ( "Int8" ) . field ( i) . finish ( ) ,
470488 Self :: BigDecimal ( d) => d. fmt ( f) ,
471489 Self :: Bool ( arg0) => f. debug_tuple ( "Bool" ) . field ( arg0) . finish ( ) ,
472490 Self :: List ( arg0) => f. debug_tuple ( "List" ) . field ( arg0) . finish ( ) ,
@@ -482,6 +500,7 @@ impl From<Value> for q::Value {
482500 match value {
483501 Value :: String ( s) => q:: Value :: String ( s) ,
484502 Value :: Int ( i) => q:: Value :: Int ( q:: Number :: from ( i) ) ,
503+ Value :: Int8 ( i) => q:: Value :: String ( i. to_string ( ) ) ,
485504 Value :: BigDecimal ( d) => q:: Value :: String ( d. to_string ( ) ) ,
486505 Value :: Bool ( b) => q:: Value :: Boolean ( b) ,
487506 Value :: Null => q:: Value :: Null ,
@@ -499,6 +518,7 @@ impl From<Value> for r::Value {
499518 match value {
500519 Value :: String ( s) => r:: Value :: String ( s) ,
501520 Value :: Int ( i) => r:: Value :: Int ( i as i64 ) ,
521+ Value :: Int8 ( i) => r:: Value :: String ( i. to_string ( ) ) ,
502522 Value :: BigDecimal ( d) => r:: Value :: String ( d. to_string ( ) ) ,
503523 Value :: Bool ( b) => r:: Value :: Boolean ( b) ,
504524 Value :: Null => r:: Value :: Null ,
@@ -565,6 +585,12 @@ impl From<u64> for Value {
565585 }
566586}
567587
588+ impl From < i64 > for Value {
589+ fn from ( value : i64 ) -> Value {
590+ Value :: Int8 ( value. into ( ) )
591+ }
592+ }
593+
568594impl TryFrom < Value > for Option < scalar:: BigInt > {
569595 type Error = Error ;
570596
0 commit comments