Skip to content

Commit

Permalink
note about Custom Pivot models and u_xyz members
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Sep 1, 2022
1 parent 97a12a9 commit a4cec6d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions include/orm/tiny/relations/basepivot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ namespace Orm::Tiny::Relations

/* AsPivot */

/* Custom Pivot models only:
Below is true, only during obtaining pivot records from the database during
the lazy or eager loading.
It's not true eg. if you call Tagged::create()/save()/update()/..., in all this
cases the Ignored u_xyz data members are taken into account normally❗
Ignored : u_connection, u_timestamps, CREATED_AT, UPDATED_AT
Accepted : u_attributes, u_dates, u_dateFormat, u_fillable, u_guarded,
u_incrementing, u_table
Notes : u_connection - inferred from the parent model
u_timestamps - true if attributes contain both CREATED_AT and UPDATED_AT
CREATED/UPDATED_AT - inferred from the parent model, can be overriden
using the withTimestamps() method
*/

// NOTE api different, passing down a pivot timestamps data silverqx
template<typename PivotModel>
template<typename Parent>
Expand Down
15 changes: 14 additions & 1 deletion tests/models/models/tagged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ class Tagged final : public BasePivot<Tagged>
/*! Indicates if the ID is auto-incrementing. */
// bool u_incrementing = true;

// FUTURE u_connection can't be overridden, the same is true in Eloquent, add support to be able to override these silveqx
/* Below is true, only during obtaining pivot records from the database during
the lazy or eager loading with the Custom Pivot models only.
It's not true eg. if you call Tagged::create()/save()/update()/..., in all this
cases the Ignored u_xyz data members are taken into account normally❗
Ignored : u_connection, u_timestamps, CREATED_AT, UPDATED_AT
Accepted : u_attributes, u_dates, u_dateFormat, u_fillable, u_guarded,
u_incrementing, u_table
Notes : u_connection - inferred from the parent model
u_timestamps - true if attributes contain both CREATED_AT and UPDATED_AT
CREATED/UPDATED_AT - inferred from the parent model, can be overriden
using the withTimestamps() method
*/
};

} // namespace Models
Expand Down

0 comments on commit a4cec6d

Please sign in to comment.