reference a value from other linked table
This commit is contained in:
@@ -19,6 +19,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.type_attribute(".komp_ac.search", serde)
|
.type_attribute(".komp_ac.search", serde)
|
||||||
.type_attribute(".komp_ac.search2", serde)
|
.type_attribute(".komp_ac.search2", serde)
|
||||||
.type_attribute(".komp_ac.table_definition", serde)
|
.type_attribute(".komp_ac.table_definition", serde)
|
||||||
|
.type_attribute(
|
||||||
|
".komp_ac.table_definition.ColumnDefinition",
|
||||||
|
"#[serde(default)]",
|
||||||
|
)
|
||||||
.type_attribute(".komp_ac.table_script", serde)
|
.type_attribute(".komp_ac.table_script", serde)
|
||||||
.type_attribute(".komp_ac.table_structure", serde)
|
.type_attribute(".komp_ac.table_structure", serde)
|
||||||
.type_attribute(".komp_ac.table_validation", serde)
|
.type_attribute(".komp_ac.table_validation", serde)
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ message PostTableDefinitionRequest {
|
|||||||
// allowed.
|
// allowed.
|
||||||
string table_name = 1;
|
string table_name = 1;
|
||||||
|
|
||||||
// The table's columns, including its links and stored linked projections.
|
// The table's columns, including its links and stored linked values.
|
||||||
// A projection uses field_type FROM(link_column.source_column); its physical
|
// A linked value uses ColumnDefinition.linked_value; its physical type and
|
||||||
// type and money metadata are inferred from the linked source column.
|
// money metadata are inferred from the linked source column.
|
||||||
repeated ColumnDefinition columns = 3;
|
repeated ColumnDefinition columns = 3;
|
||||||
|
|
||||||
// Column names to index, matching names declared above. System columns
|
// Column names to index, matching names declared above. System columns
|
||||||
@@ -276,7 +276,7 @@ message AddTableColumnsRequest {
|
|||||||
string table_name = 2;
|
string table_name = 2;
|
||||||
|
|
||||||
// New user-defined columns only. Existing columns cannot be changed here.
|
// New user-defined columns only. Existing columns cannot be changed here.
|
||||||
// Stored linked projections use field_type FROM(link_column.source_column).
|
// Stored linked values use ColumnDefinition.linked_value.
|
||||||
repeated ColumnDefinition columns = 3;
|
repeated ColumnDefinition columns = 3;
|
||||||
|
|
||||||
// Optional indexes for the new columns only.
|
// Optional indexes for the new columns only.
|
||||||
@@ -359,9 +359,6 @@ message ColumnDefinition {
|
|||||||
// LINK(table) → BIGINT referencing that table in the same profile, indexed
|
// LINK(table) → BIGINT referencing that table in the same profile, indexed
|
||||||
// automatically. A table may hold several links to the same
|
// automatically. A table may hold several links to the same
|
||||||
// target as long as the columns are named differently.
|
// target as long as the columns are named differently.
|
||||||
// FROM(link.source) → stored, read-only copy of an atomic column reached
|
|
||||||
// through another column in this definition whose type is
|
|
||||||
// LINK(...). SQL type and money metadata are inferred.
|
|
||||||
string field_type = 2;
|
string field_type = 2;
|
||||||
|
|
||||||
// MONEY rounding applied before a value is stored.
|
// MONEY rounding applied before a value is stored.
|
||||||
@@ -381,6 +378,19 @@ message ColumnDefinition {
|
|||||||
// Enables a Boolean ledger on Boolean columns. ANY means
|
// Enables a Boolean ledger on Boolean columns. ANY means
|
||||||
// one true contribution wins; ALL means one false contribution wins.
|
// one true contribution wins; ALL means one false contribution wins.
|
||||||
BooleanLedgerOperator boolean_ledger = 7;
|
BooleanLedgerOperator boolean_ledger = 7;
|
||||||
|
|
||||||
|
// Defines this named column as a stored, read-only value copied through an
|
||||||
|
// existing LINK column. field_type and money metadata are inferred from the
|
||||||
|
// source column and must not be supplied by the caller.
|
||||||
|
optional LinkedValueDefinition linked_value = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LinkedValueDefinition {
|
||||||
|
// Exact display name of a LINK column in the table being defined.
|
||||||
|
string link_column = 1;
|
||||||
|
|
||||||
|
// Exact display name of an atomic column in the linked table.
|
||||||
|
string source_column = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum BooleanLedgerOperator {
|
enum BooleanLedgerOperator {
|
||||||
|
|||||||
Binary file not shown.
@@ -25,9 +25,9 @@ pub struct PostTableDefinitionRequest {
|
|||||||
/// allowed.
|
/// allowed.
|
||||||
#[prost(string, tag = "1")]
|
#[prost(string, tag = "1")]
|
||||||
pub table_name: ::prost::alloc::string::String,
|
pub table_name: ::prost::alloc::string::String,
|
||||||
/// The table's columns, including its links and stored linked projections.
|
/// The table's columns, including its links and stored linked values.
|
||||||
/// A projection uses field_type FROM(link_column.source_column); its physical
|
/// A linked value uses ColumnDefinition.linked_value; its physical type and
|
||||||
/// type and money metadata are inferred from the linked source column.
|
/// money metadata are inferred from the linked source column.
|
||||||
#[prost(message, repeated, tag = "3")]
|
#[prost(message, repeated, tag = "3")]
|
||||||
pub columns: ::prost::alloc::vec::Vec<ColumnDefinition>,
|
pub columns: ::prost::alloc::vec::Vec<ColumnDefinition>,
|
||||||
/// Column names to index, matching names declared above. System columns
|
/// Column names to index, matching names declared above. System columns
|
||||||
@@ -201,7 +201,7 @@ pub struct AddTableColumnsRequest {
|
|||||||
#[prost(string, tag = "2")]
|
#[prost(string, tag = "2")]
|
||||||
pub table_name: ::prost::alloc::string::String,
|
pub table_name: ::prost::alloc::string::String,
|
||||||
/// New user-defined columns only. Existing columns cannot be changed here.
|
/// New user-defined columns only. Existing columns cannot be changed here.
|
||||||
/// Stored linked projections use field_type FROM(link_column.source_column).
|
/// Stored linked values use ColumnDefinition.linked_value.
|
||||||
#[prost(message, repeated, tag = "3")]
|
#[prost(message, repeated, tag = "3")]
|
||||||
pub columns: ::prost::alloc::vec::Vec<ColumnDefinition>,
|
pub columns: ::prost::alloc::vec::Vec<ColumnDefinition>,
|
||||||
/// Optional indexes for the new columns only.
|
/// Optional indexes for the new columns only.
|
||||||
@@ -255,6 +255,7 @@ pub struct PutTableDefinitionResponse {
|
|||||||
}
|
}
|
||||||
/// Describes one user-defined column for a table.
|
/// Describes one user-defined column for a table.
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
pub struct ColumnDefinition {
|
pub struct ColumnDefinition {
|
||||||
/// Public display name for this column; the physical column uses a stable
|
/// Public display name for this column; the physical column uses a stable
|
||||||
@@ -292,9 +293,6 @@ pub struct ColumnDefinition {
|
|||||||
/// LINK(table) → BIGINT referencing that table in the same profile, indexed
|
/// LINK(table) → BIGINT referencing that table in the same profile, indexed
|
||||||
/// automatically. A table may hold several links to the same
|
/// automatically. A table may hold several links to the same
|
||||||
/// target as long as the columns are named differently.
|
/// target as long as the columns are named differently.
|
||||||
/// FROM(link.source) → stored, read-only copy of an atomic column reached
|
|
||||||
/// through another column in this definition whose type is
|
|
||||||
/// LINK(...). SQL type and money metadata are inferred.
|
|
||||||
#[prost(string, tag = "2")]
|
#[prost(string, tag = "2")]
|
||||||
pub field_type: ::prost::alloc::string::String,
|
pub field_type: ::prost::alloc::string::String,
|
||||||
/// MONEY rounding applied before a value is stored.
|
/// MONEY rounding applied before a value is stored.
|
||||||
@@ -316,6 +314,21 @@ pub struct ColumnDefinition {
|
|||||||
#[prost(enumeration = "BooleanLedgerOperator", tag = "7")]
|
#[prost(enumeration = "BooleanLedgerOperator", tag = "7")]
|
||||||
#[serde(default, alias = "boolean_ledger_operator")]
|
#[serde(default, alias = "boolean_ledger_operator")]
|
||||||
pub boolean_ledger: i32,
|
pub boolean_ledger: i32,
|
||||||
|
/// Defines this named column as a stored, read-only value copied through an
|
||||||
|
/// existing LINK column. field_type and money metadata are inferred from the
|
||||||
|
/// source column and must not be supplied by the caller.
|
||||||
|
#[prost(message, optional, tag = "8")]
|
||||||
|
pub linked_value: ::core::option::Option<LinkedValueDefinition>,
|
||||||
|
}
|
||||||
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
|
pub struct LinkedValueDefinition {
|
||||||
|
/// Exact display name of a LINK column in the table being defined.
|
||||||
|
#[prost(string, tag = "1")]
|
||||||
|
pub link_column: ::prost::alloc::string::String,
|
||||||
|
/// Exact display name of an atomic column in the linked table.
|
||||||
|
#[prost(string, tag = "2")]
|
||||||
|
pub source_column: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
/// Response after table creation (success + DDL preview).
|
/// Response after table creation (success + DDL preview).
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
|
|||||||
@@ -1273,6 +1273,7 @@ pub(crate) fn proto_columns(columns: &[ColumnDefinition]) -> Vec<ProtoColumnDefi
|
|||||||
boolean_ledger: 0,
|
boolean_ledger: 0,
|
||||||
currency: column.currency.clone(),
|
currency: column.currency.clone(),
|
||||||
required: column.required,
|
required: column.required,
|
||||||
|
linked_value: None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user