aliasing now move column position also

This commit is contained in:
Priec
2026-08-14 21:23:14 +02:00
parent 5792a1f533
commit c3f5046c85
17 changed files with 164 additions and 86 deletions

Binary file not shown.

View File

@@ -54,12 +54,12 @@ pub struct PostTableDefinitionRequest {
/// is required to be named after its own type, and what it expands into is the
/// backend's to decide. The name is only ever a display name over a physical
/// column, though, so it is free to be anything: this is where that choice is
/// made, instead of a RenameColumnAlias call afterwards.
/// made, instead of a SetColumnPresentation call afterwards.
///
/// ACCOUNTING, PHONE and IBAN generated columns may be renamed: their
/// relationships are recorded by physical column, so the rest of the system can
/// find them without knowing their display names. ACCOUNTING_TRANSFER connectors
/// are the exception and are refused here exactly as RenameColumnAlias refuses
/// are the exception and are refused here exactly as SetColumnPresentation refuses
/// them.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
@@ -401,6 +401,9 @@ pub struct ColumnBehavior {
/// True when clients may offer this column in an alias rename picker.
#[prost(bool, tag = "4")]
pub renameable: bool,
/// Stable public identity used when updating this column's presentation.
#[prost(int64, tag = "5")]
pub column_id: i64,
}
/// A script that targets a specific column in a table.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
@@ -416,27 +419,37 @@ pub struct ScriptInfo {
#[prost(string, tag = "5")]
pub description: ::prost::alloc::string::String,
}
/// Request to rename one user-visible column alias in a table.
/// One column's desired public presentation. Its position in the containing
/// repeated field is its presentation order.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct RenameColumnAliasRequest {
pub struct ColumnPresentation {
/// Stable public identity of the table_definition_columns row.
#[prost(int64, tag = "1")]
pub column_id: i64,
#[prost(string, tag = "2")]
pub alias: ::prost::alloc::string::String,
}
/// Atomically replaces every user-visible column alias and their order.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetColumnPresentationRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub table_name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub old_column_name: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub new_column_name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub columns: ::prost::alloc::vec::Vec<ColumnPresentation>,
}
/// Response after renaming one column alias.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct RenameColumnAliasResponse {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetColumnPresentationResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub columns: ::prost::alloc::vec::Vec<ColumnPresentation>,
}
/// Request to delete one table definition entirely.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
@@ -987,12 +1000,13 @@ pub mod table_definition_client {
);
self.inner.unary(req, path, codec).await
}
/// Renames a user-visible column alias while keeping the physical column unchanged.
pub async fn rename_column_alias(
/// Atomically replaces the aliases and presentation order of a table's columns.
/// Physical column names and identities remain unchanged.
pub async fn set_column_presentation(
&mut self,
request: impl tonic::IntoRequest<super::RenameColumnAliasRequest>,
request: impl tonic::IntoRequest<super::SetColumnPresentationRequest>,
) -> std::result::Result<
tonic::Response<super::RenameColumnAliasResponse>,
tonic::Response<super::SetColumnPresentationResponse>,
tonic::Status,
> {
self.inner
@@ -1005,14 +1019,14 @@ pub mod table_definition_client {
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_definition.TableDefinition/RenameColumnAlias",
"/komp_ac.table_definition.TableDefinition/SetColumnPresentation",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_definition.TableDefinition",
"RenameColumnAlias",
"SetColumnPresentation",
),
);
self.inner.unary(req, path, codec).await
@@ -1143,12 +1157,13 @@ pub mod table_definition_server {
tonic::Response<super::GetColumnAliasRenameHistoryResponse>,
tonic::Status,
>;
/// Renames a user-visible column alias while keeping the physical column unchanged.
async fn rename_column_alias(
/// Atomically replaces the aliases and presentation order of a table's columns.
/// Physical column names and identities remain unchanged.
async fn set_column_presentation(
&self,
request: tonic::Request<super::RenameColumnAliasRequest>,
request: tonic::Request<super::SetColumnPresentationRequest>,
) -> std::result::Result<
tonic::Response<super::RenameColumnAliasResponse>,
tonic::Response<super::SetColumnPresentationResponse>,
tonic::Status,
>;
/// Drops a table and its metadata, then deletes the profile if it becomes empty.
@@ -1670,25 +1685,28 @@ pub mod table_definition_server {
};
Box::pin(fut)
}
"/komp_ac.table_definition.TableDefinition/RenameColumnAlias" => {
"/komp_ac.table_definition.TableDefinition/SetColumnPresentation" => {
#[allow(non_camel_case_types)]
struct RenameColumnAliasSvc<T: TableDefinition>(pub Arc<T>);
struct SetColumnPresentationSvc<T: TableDefinition>(pub Arc<T>);
impl<
T: TableDefinition,
> tonic::server::UnaryService<super::RenameColumnAliasRequest>
for RenameColumnAliasSvc<T> {
type Response = super::RenameColumnAliasResponse;
> tonic::server::UnaryService<super::SetColumnPresentationRequest>
for SetColumnPresentationSvc<T> {
type Response = super::SetColumnPresentationResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::RenameColumnAliasRequest>,
request: tonic::Request<super::SetColumnPresentationRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::rename_column_alias(&inner, request)
<T as TableDefinition>::set_column_presentation(
&inner,
request,
)
.await
};
Box::pin(fut)
@@ -1700,7 +1718,7 @@ pub mod table_definition_server {
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = RenameColumnAliasSvc(inner);
let method = SetColumnPresentationSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(

View File

@@ -70,6 +70,9 @@ pub struct TableColumn {
/// True when clients may offer this column in an alias rename picker.
#[prost(bool, tag = "9")]
pub renameable: bool,
/// Stable public identity of a managed user column. Zero for system columns.
#[prost(int64, tag = "10")]
pub column_id: i64,
}
/// Generated client implementations.
pub mod table_structure_service_client {