pub trait Key {
type Entity;
fn columns() -> Vec<String>;
fn default_inverse_columns() -> Vec<String>;
fn params(&self) -> Vec<SqlArg>;
fn unaliased_predicate_expr(&self) -> SqlExpr { ... }
}
Expand description
Trait to provide the entity type for a key. This is only used for ergonomics of the api.
Required Associated Types
Required Methods
fn default_inverse_columns() -> Vec<String>
fn default_inverse_columns() -> Vec<String>
Return foreign key columns that match the primary keys for a given entity. This is only needed to merge entities. The names are calculated and do not necessarily match the actual foreign keys on the other table. The translation rules are (for snake case column format):
Type | Guessing rule | Example |
---|---|---|
Normal fields | tablename + normal field | id -> user_id , access_code -> user_access_code |
Joins | No change | language_id -> language_id |
If the automatic generated names are not correct, the user is required to correct them by attributing the relevant field with
#[toql( merge( columns( self = "id", other = "user_code")))]