diff --git a/tarantool/src/index.rs b/tarantool/src/index.rs index 7327d162..938cdcc0 100644 --- a/tarantool/src/index.rs +++ b/tarantool/src/index.rs @@ -19,6 +19,7 @@ use crate::tuple::{AsTuple, Tuple, TupleBuffer}; use crate::tuple_from_box_api; /// An index is a group of key values and pointers. +#[derive(Debug, Clone)] pub struct Index { space_id: u32, index_id: u32, @@ -151,7 +152,8 @@ pub enum IndexSequenceOption { } /// Type of index. -#[derive(Copy, Clone, Debug, Serialize)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all="lowercase")] pub enum IndexType { Hash, Tree, @@ -160,7 +162,8 @@ pub enum IndexType { } /// Type of index part. -#[derive(Copy, Clone, Debug, Serialize)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all="lowercase")] pub enum IndexFieldType { Unsigned, String, @@ -176,7 +179,7 @@ pub enum IndexFieldType { } /// Index part. -#[derive(Serialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct IndexPart { pub field_index: u32, pub field_type: IndexFieldType, diff --git a/tarantool/src/schema/space.rs b/tarantool/src/schema/space.rs index 8417f3a1..8e9b723c 100644 --- a/tarantool/src/schema/space.rs +++ b/tarantool/src/schema/space.rs @@ -130,6 +130,9 @@ fn insert_new_space( let mut field_format = Map::::new(); field_format.insert("name".to_string(), Value::String(ft.name.clone())); field_format.insert("type".to_string(), Value::String(ft.field_type.to_string())); + if let Some(is_nullable) = ft.is_nullable { + field_format.insert("is_nullable".to_string(), Value::Bool(is_nullable)); + } space_format.push(Value::Object(field_format)); } } diff --git a/tarantool/src/space.rs b/tarantool/src/space.rs index c6725933..6d646b7c 100644 --- a/tarantool/src/space.rs +++ b/tarantool/src/space.rs @@ -10,7 +10,7 @@ use std::fmt; use std::os::raw::c_char; use num_traits::ToPrimitive; -use serde::{Serialize, Serializer}; +use serde::{Serialize, Serializer, Deserialize, Deserializer}; use serde_json::{Map, Value}; use crate::error::{Error, TarantoolError}; @@ -93,7 +93,8 @@ impl Into for SystemSpace { } /// Type of engine, used by space. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Deserialize, PartialEq)] +#[serde(rename_all="lowercase")] pub enum SpaceEngineType { Memtx, Vinyl, @@ -144,11 +145,12 @@ impl Default for SpaceCreateOptions { } } -#[derive(Clone, Debug, Serialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct SpaceFieldFormat { pub name: String, #[serde(alias = "type")] pub field_type: SpaceFieldType, + pub is_nullable: Option, } impl SpaceFieldFormat { @@ -156,11 +158,13 @@ impl SpaceFieldFormat { return SpaceFieldFormat { name: name.to_string(), field_type: ft, + is_nullable: None, }; } } -#[derive(Copy, Clone, Debug, Serialize)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] +#[serde(rename_all="lowercase")] pub enum SpaceFieldType { Any, Unsigned, @@ -217,6 +221,7 @@ pub struct Privilege { impl AsTuple for Privilege {} +#[derive(Debug, Clone)] pub struct Space { id: u32, }