Skip to content

Commit

Permalink
editoast: fix some typos
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Valais <[email protected]>
  • Loading branch information
leovalais committed Nov 14, 2024
1 parent 480ed39 commit f66200c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
6 changes: 3 additions & 3 deletions editoast/editoast_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn search(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
/// This derive provides the implementation the `SearchConfigStore` trait.
/// Each struct that derives `Search` will be saved and the struct deriving
/// `SearchConfigStore` will implement a `find(name: &str)` function that
/// given a seach object name, returns the `SearchConfig` of the search object
/// given a search object name, returns the `SearchConfig` of the search object
/// matching.
///
/// ```ignore
Expand Down Expand Up @@ -188,10 +188,10 @@ pub fn search_config_store(input: proc_macro::TokenStream) -> proc_macro::TokenS
///
/// * `#[model(table = crate::table::osrd_yourtable")]` (**REQUIRED**): the path to the diesel table
/// * `#[model(row(type_name = "YourRowType"))]`: the name of the row struct (defaults to `ModelRow`)
/// * `#[model(row(derive(ADDITIONAL_DERIVES*,)))]`: additional derives for the row struct (always implicitely derives `Queryable` and `QueryableByName`)
/// * `#[model(row(derive(ADDITIONAL_DERIVES*,)))]`: additional derives for the row struct (always implicitly derives `Queryable` and `QueryableByName`)
/// * `#[model(row(public))]`: make the row struct fields `pub` (private by default)
/// * `#[model(changeset(type_name = "YourChangesetType"))]`: the name of the changeset struct (defaults to `ModelChangeset`)
/// * `#[model(changeset(derive(ADDITIONAL_DERIVES*,)))]`: additional derives for the changeset struct (always implicitely derives `Default, Queryable, QueryableByName, AsChangeset, Insertable`)
/// * `#[model(changeset(derive(ADDITIONAL_DERIVES*,)))]`: additional derives for the changeset struct (always implicitly derives `Default, Queryable, QueryableByName, AsChangeset, Insertable`)
/// * `#[model(changeset(public))]`: make the changeset struct fields `pub` (private by default)
/// * `#[model(identifier = IDENTIFIER)]` (multiple): just like `#[model(identifier)]` for fields, but at the struct level.
/// `IDENTIFIER` can be a compound identifier with the syntax `(field1, field2, ...)` (e.g.: `#[model(identifier = (infra_id, obj_id))]`).
Expand Down
8 changes: 4 additions & 4 deletions editoast/editoast_derive/src/model/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl ModelConfig {
.collect();

// collect identifiers from struct-level annotations...
let mut raw_identfiers: HashSet<_> = options
let mut raw_identifiers: HashSet<_> = options
.identifiers
.iter()
.cloned()
Expand Down Expand Up @@ -116,10 +116,10 @@ impl ModelConfig {
}
};

raw_identfiers.insert(primary_field.clone());
raw_identfiers.insert(preferred_identifier.clone());
raw_identifiers.insert(primary_field.clone());
raw_identifiers.insert(preferred_identifier.clone());

let typed_identifiers = raw_identfiers
let typed_identifiers = raw_identifiers
.iter()
.cloned()
.map(|id| Identifier::new(id, &fields))
Expand Down
17 changes: 5 additions & 12 deletions editoast/src/models/prelude/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::Model;

/// A dynamic container for a filter setting in a [SelectionSettings] context
///
/// This struct is not meant to be initialized direclty but rather through the
/// This struct is not meant to be initialized directly but rather through the
/// [ModelField](super::ModelField) objects generated by the `Model` derive macro expansion.
pub struct FilterSetting<M: Model>(pub(in crate::models) DieselFilter<M::Table>);
type DieselFilter<Table> = Box<dyn diesel::BoxableExpression<Table, Pg, SqlType = Bool>>;
Expand All @@ -25,7 +25,6 @@ impl<M: Model> FilterSetting<M> {
/// both from a `Bool` and `Nullable<Bool>` query by `COALESCE`ing the expression
/// to `FALSE`. That way the `Model` derive macro doesn't have to infer the type
/// of each field (as `column.eq(value)` is a `Nullable<Bool>` if `column` is a `Nullable<T>`).
#[allow(unused)] // FIXME: rmove this attribute asap
pub(in crate::models) fn new<T, Q>(filter: Q) -> Self
where
Q: AsExpression<T>,
Expand All @@ -39,7 +38,7 @@ impl<M: Model> FilterSetting<M> {

/// A dynamic container for a sorting setting in a [SelectionSettings] context
///
/// This struct is not meant to be initialized direclty but rather through the
/// This struct is not meant to be initialized directly but rather through the
/// [ModelField](super::ModelField) objects generated by the `Model` derive macro expansion.
pub struct SortSetting<M: Model>(pub(in crate::models) DieselSort<M::Table>);
type DieselSort<Table> = Box<dyn diesel::BoxableExpression<Table, Pg, SqlType = NotSelectable>>;
Expand Down Expand Up @@ -83,7 +82,6 @@ impl<M: Model> Clone for SelectionSettings<M> {

impl<M: Model + 'static> SelectionSettings<M> {
/// Initializes a settings builder with no constraints
#[allow(unused)] // FIXME: rmove this attribute asap
pub fn new() -> Self {
Self::default()
}
Expand All @@ -94,7 +92,7 @@ impl<M: Model + 'static> SelectionSettings<M> {
///
/// This function will be called multiple times if the same settings object
/// is used for multiple queries (e.g. with [Count::count] or [List::list]).
/// It means that the funciton must be able to produce a valid filter multiple times,
/// It means that the function must be able to produce a valid filter multiple times,
/// so if `f` is a closure, its captured variables must be `Clone`d at each call.
/// Keep in mind that the function may also be called concurrently if the settings
/// object is shared between multiple concurrent tasks.
Expand All @@ -104,7 +102,6 @@ impl<M: Model + 'static> SelectionSettings<M> {
/// wraps `diesel::BoxableExpression` which is not `Clone`. To work around this, we
/// instead clone an `Arc` of functions that are able to produce a new filter every
/// time we need it.
#[allow(unused)] // FIXME: rmove this attribute asap
pub fn filter<F: Fn() -> FilterSetting<M> + Send + Sync + 'static>(mut self, f: F) -> Self {
self.filters.push(Arc::new(f));
self
Expand All @@ -118,7 +115,7 @@ impl<M: Model + 'static> SelectionSettings<M> {
///
/// This function will be called multiple times if the same settings object
/// is used for multiple queries (e.g. with [Count::count] or [List::list]).
/// It means that the funciton must be able to produce a valid sort multiple times,
/// It means that the function must be able to produce a valid sort multiple times,
/// so if `f` is a closure, its captured variables must be `Clone`d at each call.
/// Keep in mind that the function may also be called concurrently if the settings
/// object is shared between multiple concurrent tasks.
Expand All @@ -128,21 +125,18 @@ impl<M: Model + 'static> SelectionSettings<M> {
/// wraps `diesel::BoxableExpression` which is not `Clone`. To work around this, we
/// instead clone an `Arc` of functions that are able to produce a new sort every
/// time we need it.
#[allow(unused)] // FIXME: rmove this attribute asap
pub fn order_by<F: Fn() -> SortSetting<M> + Send + Sync + 'static>(mut self, f: F) -> Self {
self.sorts.push(Arc::new(f));
self
}

/// Limit the number of results
#[allow(unused)] // FIXME: rmove this attribute asap
pub fn limit(mut self, limit: u64) -> Self {
self.limit = Some(limit.try_into().expect("limit is too large"));
self
}

/// Offset the results by an amount
#[allow(unused)] // FIXME: rmove this attribute asap
pub fn offset(mut self, offset: u64) -> Self {
self.offset = Some(offset.try_into().expect("offset is too large"));
self
Expand All @@ -153,7 +147,6 @@ impl<M: Model + 'static> SelectionSettings<M> {
/// query.
///
/// Only useful if you are working with [Count::count].
#[allow(unused)] // FIXME: rmove this attribute asap
pub fn pagination_on_count(mut self, paginate: bool) -> Self {
self.paginate_counting = paginate;
self
Expand Down Expand Up @@ -196,7 +189,7 @@ pub trait List: Model {
) -> crate::error::Result<Vec<Self>>;
}

/// Describe how we can count the number of occurences of the [Model](super::Model)
/// Describe how we can count the number of occurrences of the [Model](super::Model)
/// that match the provided settings and constraints
///
/// You can implement this type manually but it is recommended to use the `Model`
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/models/prelude/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub type Changeset<M> = <M as Model>::Changeset;

/// A struct persisting the column and type information of each model field
///
/// This struct is instanciated by the `Model` derive macro and shouldn't be
/// This struct is instantiated by the `Model` derive macro and shouldn't be
/// used manually. The macro expansion also provides a few methods such as
/// `eq` or `asc` that can be used in conjunction with [SelectionSettings].
pub struct ModelField<M, T, Column>(PhantomData<(M, T, Column)>);
Expand Down

0 comments on commit f66200c

Please sign in to comment.