web aliasing of accounting and others
This commit is contained in:
@@ -17,8 +17,8 @@ use crate::{
|
||||
};
|
||||
|
||||
/// The compound type that also brings a system column with it. Which columns
|
||||
/// it generates is the catalog's answer; the account foreign key is not one of
|
||||
/// them, and [`TableDraft::preview_rows`] is where that is explained.
|
||||
/// it generates is the catalog's answer; the physical `account_id` is not one
|
||||
/// of them, and [`TableDraft::preview_rows`] is where that is explained.
|
||||
pub(crate) const ACCOUNTING_FIELD_TYPE: &str = "accounting";
|
||||
|
||||
/// The compound type whose connectors remain tied to their backend names.
|
||||
@@ -237,13 +237,19 @@ impl TableDraft {
|
||||
if column.data_type == ACCOUNTING_TRANSFER_FIELD_TYPE {
|
||||
continue;
|
||||
}
|
||||
names.extend(
|
||||
self.columns
|
||||
.generated_columns_of(index)
|
||||
.iter()
|
||||
.map(|generated| generated.name.clone()),
|
||||
);
|
||||
if column.data_type == ACCOUNTING_FIELD_TYPE {
|
||||
let generated: Vec<String> = self
|
||||
.columns
|
||||
.generated_columns_of(index)
|
||||
.iter()
|
||||
.map(|generated| generated.name.clone())
|
||||
.collect();
|
||||
// A backend that reports `account` with the rest of ACCOUNTING's
|
||||
// companions has already named it here; offering it a second time
|
||||
// for the foreign key would put two fields on one column, and only
|
||||
// the first of the two would be read.
|
||||
let account_reported = generated.iter().any(|name| name == ACCOUNT_API_COLUMN);
|
||||
names.extend(generated);
|
||||
if column.data_type == ACCOUNTING_FIELD_TYPE && !account_reported {
|
||||
names.push(ACCOUNT_API_COLUMN.to_string());
|
||||
}
|
||||
}
|
||||
@@ -831,8 +837,10 @@ mod tests {
|
||||
"tax_point_date",
|
||||
"debit",
|
||||
"credit",
|
||||
// The account foreign key, which the catalog does not report
|
||||
// because it is a system column rather than a generated one.
|
||||
// The foreign key to the profile's accounts, once as the
|
||||
// column the backend reports and once as the physical column
|
||||
// it is stored in.
|
||||
"account",
|
||||
"account_id",
|
||||
"created_at",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user