use async_trait::async_trait;
use vantage_core::Result;
use vantage_dataset::prelude::{ReadableValueSet, WritableValueSet};
use vantage_expressions::AnyExpression;
use crate::{any::AnyTable, conditions::ConditionHandle, pagination::Pagination};
#[async_trait]
pub trait TableLike: ReadableValueSet + WritableValueSet + Send + Sync {
fn table_name(&self) -> &str;
fn table_alias(&self) -> &str;
fn column_names(&self) -> Vec<String>;
fn add_condition(&mut self, condition: Box<dyn std::any::Any + Send + Sync>) -> Result<()>;
fn temp_add_condition(&mut self, condition: AnyExpression) -> Result<ConditionHandle>;
fn temp_remove_condition(&mut self, handle: ConditionHandle) -> Result<()>;
fn search_expression(&self, search_value: &str) -> Result<AnyExpression>;
fn clone_box(&self) -> Box<dyn TableLike<Value = Self::Value, Id = Self::Id>>;
fn into_any(self: Box<Self>) -> Box<dyn std::any::Any>;
fn as_any_ref(&self) -> &dyn std::any::Any;
fn set_pagination(&mut self, pagination: Option<Pagination>);
fn get_pagination(&self) -> Option<&Pagination>;
async fn get_count(&self) -> Result<i64>;
fn get_ref(&self, _relation: &str) -> Result<AnyTable> {
Err(vantage_core::error!(
"get_ref not supported on this TableLike"
))
}
}