Add some tests for Validation

This commit is contained in:
Yuriy Dupyn 2024-01-28 15:09:27 +01:00
parent 10ba1dd3e4
commit 052236d892
8 changed files with 343 additions and 77 deletions

View file

@ -58,7 +58,7 @@ impl<W> ServerProto for W where W: BackendProtoWriter + Send {
async fn write_table_header(&mut self, table_schema: &TableSchema, row: &RestrictedRow) -> anyhow::Result<()> {
let columns = row.iter()
.map(|(index, value)| value_to_column_description(table_schema, value, index))
.map(|(index, value)| value_to_column_description(table_schema, value, *index))
.collect::<anyhow::Result<Vec<ColumnDescription>>>()?;
self.write_proto(RowDescriptionData { columns: columns.into() }.into()).await?;
@ -84,11 +84,11 @@ impl<W> ServerProto for W where W: BackendProtoWriter + Send {
}
}
fn value_to_column_description(schema: &TableSchema, value: &Value, index: &usize) -> anyhow::Result<ColumnDescription> {
let name = schema.column_name_from_column_position(*index)?;
fn value_to_column_description(schema: &TableSchema, value: &Value, index: usize) -> anyhow::Result<ColumnDescription> {
let name = schema.column_name_from_column(index);
let table_oid = schema.table_name().as_bytes().as_ptr() as i32;
let column_index = (*index).try_into()?;
let column_index = index.try_into()?;
let type_oid = value.type_oid();
let type_size = value.type_size();