multirow FK

This commit is contained in:
Priec
2026-08-07 22:39:59 +02:00
parent c47e236713
commit 0d78556428
10 changed files with 46 additions and 216 deletions

View File

@@ -157,10 +157,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
".komp_ac.table_definition.ColumnDefinition",
"#[derive(serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
".komp_ac.table_definition.TableLink",
"#[derive(serde::Serialize, serde::Deserialize)]"
)
.type_attribute(
".komp_ac.table_definition.PostTableDefinitionRequest",
"#[derive(serde::Serialize, serde::Deserialize)]",

View File

@@ -48,19 +48,6 @@ service TableDefinition {
rpc DeleteTable(DeleteTableRequest) returns (DeleteTableResponse);
}
// A single link to another table within the same profile (schema).
message TableLink {
// Name of an existing table within the same profile to link to.
// For each link, a "<linked>_id" column is created on the new table.
// That column references "<linked>"(id) and adds an index automatically.
string linked_table_name = 1;
// If true, the generated foreign key column is NOT NULL.
// Otherwise the column allows NULL.
// Duplicate links to the same target table in one request are rejected.
bool required = 2;
}
// Defines the input for creating a new table definition.
message PostTableDefinitionRequest {
// Table name to create inside the target profile.
@@ -69,10 +56,6 @@ message PostTableDefinitionRequest {
// Forbidden names: "id", "deleted", "created_at", "row_revision", or ending in "_id".
string table_name = 1;
// List of links (foreign keys) to existing tables in the same profile.
// Each will automatically get a "<linked>_id" column and an index.
repeated TableLink links = 2;
// List of user-defined columns (adds to system/id/fk columns).
repeated ColumnDefinition columns = 3;
@@ -187,6 +170,9 @@ message ColumnDefinition {
// DURATION
// PERIOD
// DECIMAL(p,s) → NUMERIC(p,s)
// LINK(table) → BIGINT referencing that table in the same profile, indexed
// automatically. A table may hold several links to the same
// target as long as the columns are named differently.
// DECIMAL args must be integers (no sign, no dot, no leading zeros);
// s ≤ p and p ≥ 1.
string field_type = 2;
@@ -371,6 +357,12 @@ enum ColumnTypeSpelling {
// at least 1 and scale no greater than precision; neither may carry a sign,
// a decimal point, or leading zeros.
COLUMN_TYPE_SPELLING_DECIMAL = 1;
// The name takes the name of another table in the same profile:
// "link(adresar)". The column holds that table's id, and the server creates
// the foreign key and its index. A picker offers the profile's other tables
// as the argument.
COLUMN_TYPE_SPELLING_LINK = 2;
}
// Response describing the whole column-type vocabulary.

Binary file not shown.

View File

@@ -1,19 +1,4 @@
// This file is @generated by prost-build.
/// A single link to another table within the same profile (schema).
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TableLink {
/// Name of an existing table within the same profile to link to.
/// For each link, a "<linked>\_id" column is created on the new table.
/// That column references "<linked>"(id) and adds an index automatically.
#[prost(string, tag = "1")]
pub linked_table_name: ::prost::alloc::string::String,
/// If true, the generated foreign key column is NOT NULL.
/// Otherwise the column allows NULL.
/// Duplicate links to the same target table in one request are rejected.
#[prost(bool, tag = "2")]
pub required: bool,
}
/// Defines the input for creating a new table definition.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
@@ -24,10 +9,6 @@ pub struct PostTableDefinitionRequest {
/// Forbidden names: "id", "deleted", "created_at", "row_revision", or ending in "\_id".
#[prost(string, tag = "1")]
pub table_name: ::prost::alloc::string::String,
/// List of links (foreign keys) to existing tables in the same profile.
/// Each will automatically get a "<linked>\_id" column and an index.
#[prost(message, repeated, tag = "2")]
pub links: ::prost::alloc::vec::Vec<TableLink>,
/// List of user-defined columns (adds to system/id/fk columns).
#[prost(message, repeated, tag = "3")]
pub columns: ::prost::alloc::vec::Vec<ColumnDefinition>,
@@ -153,6 +134,9 @@ pub struct ColumnDefinition {
/// DURATION
/// PERIOD
/// DECIMAL(p,s) → NUMERIC(p,s)
/// LINK(table) → BIGINT referencing that table in the same profile, indexed
/// automatically. A table may hold several links to the same
/// target as long as the columns are named differently.
/// DECIMAL args must be integers (no sign, no dot, no leading zeros);
/// s ≤ p and p ≥ 1.
#[prost(string, tag = "2")]
@@ -486,6 +470,11 @@ pub enum ColumnTypeSpelling {
/// at least 1 and scale no greater than precision; neither may carry a sign,
/// a decimal point, or leading zeros.
Decimal = 1,
/// The name takes the name of another table in the same profile:
/// "link(adresar)". The column holds that table's id, and the server creates
/// the foreign key and its index. A picker offers the profile's other tables
/// as the argument.
Link = 2,
}
impl ColumnTypeSpelling {
/// String value of the enum field names used in the ProtoBuf definition.
@@ -496,6 +485,7 @@ impl ColumnTypeSpelling {
match self {
Self::Bare => "COLUMN_TYPE_SPELLING_BARE",
Self::Decimal => "COLUMN_TYPE_SPELLING_DECIMAL",
Self::Link => "COLUMN_TYPE_SPELLING_LINK",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -503,6 +493,7 @@ impl ColumnTypeSpelling {
match value {
"COLUMN_TYPE_SPELLING_BARE" => Some(Self::Bare),
"COLUMN_TYPE_SPELLING_DECIMAL" => Some(Self::Decimal),
"COLUMN_TYPE_SPELLING_LINK" => Some(Self::Link),
_ => None,
}
}