Move Column into schema.rs

This commit is contained in:
Yuriy Dupyn 2024-01-28 18:40:34 +01:00
parent 0ec02eeef8
commit a2180a3e32
9 changed files with 23 additions and 24 deletions

View file

@ -1,7 +1,7 @@
use async_trait::async_trait;
use minisql::restricted_row::RestrictedRow;
use minisql::schema::TableSchema;
use minisql::type_system::{Value};
use minisql::schema::{Column, TableSchema};
use minisql::type_system::Value;
use proto::message::backend::{BackendMessage, ColumnDescription, CommandCompleteData, DataRowData, ErrorResponseData, ReadyForQueryData, RowDescriptionData};
use proto::message::primitive::pglist::PgList;
use proto::writer::backend::BackendProtoWriter;
@ -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(|(column, value)| value_to_column_description(table_schema, value, *column))
.collect::<anyhow::Result<Vec<ColumnDescription>>>()?;
self.write_proto(RowDescriptionData { columns: columns.into() }.into()).await?;
@ -84,7 +84,7 @@ impl<W> ServerProto for W where W: BackendProtoWriter + Send {
}
}
fn value_to_column_description(schema: &TableSchema, value: &Value, index: usize) -> anyhow::Result<ColumnDescription> {
fn value_to_column_description(schema: &TableSchema, value: &Value, index: Column) -> anyhow::Result<ColumnDescription> {
let name = schema.column_name_from_column(index);
let table_oid = schema.table_name().as_bytes().as_ptr() as i32;