Lightweight 0.20260921.0
Loading...
Searching...
No Matches
Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable > Class Template Reference

Represents the many-to-one side of a foreign-key relationship. More...

#include <BelongsTo.hpp>

Public Types

using ReferencedRecord = MemberClassType< decltype(TheReferencedField)>
 Represents the record type of the other field.
 
using BaseType = std::remove_cvref_t< decltype(std::declval< ReferencedRecord >().*ReferencedField)>::ValueType
 Represents the base column type of the foreign key, matching the primary key of the other record.
 
using ValueType = std::conditional_t< Nullable==SqlNullable::Null, std::optional< BaseType >, BaseType >
 

Public Member Functions

template<typename... S>
requires std::constructible_from<ValueType, S...>
constexpr BelongsTo (S &&... value) noexcept
 Constructs a new BelongsTo with the given value(s) forwarded to the underlying value type.
 
constexpr BelongsTo (ReferencedRecord const &other) noexcept
 Constructs a new BelongsTo from the given referenced record, copying its primary key.
 
constexpr BelongsTo (BelongsTo const &other) noexcept
 Copy constructor.
 
constexpr BelongsTo (BelongsTo &&other) noexcept
 Move constructor.
 
BelongsTo & operator= (SqlNullType) noexcept
 Assigns NULL to the relationship, clearing the loaded record.
 
template<typename S >
requires (std::constructible_from<ValueType, S> && !std::same_as<std::remove_cvref_t<S>, BelongsTo> && !std::same_as<std::remove_cvref_t<S>, ReferencedRecord> && !std::same_as<std::remove_cvref_t<S>, SqlNullType>)
constexpr BelongsTo & operator= (S &&value) noexcept
 
BelongsTo & operator= (ReferencedRecord &other)
 Assigns a referenced record, updating the foreign key and loaded state.
 
BelongsTo & operator= (BelongsTo const &other)
 Copy assignment operator.
 
BelongsTo & operator= (BelongsTo &&other) noexcept
 Move assignment operator.
 
LIGHTWEIGHT_FORCE_INLINE constexpr void SetModified (bool value) noexcept
 Marks the field as modified or unmodified.
 
LIGHTWEIGHT_FORCE_INLINE constexpr bool IsModified () const noexcept
 Checks if the field is modified.
 
LIGHTWEIGHT_FORCE_INLINE constexpr ValueType const & Value () const noexcept
 Retrieves the reference to the value of the field.
 
LIGHTWEIGHT_FORCE_INLINE constexpr ValueType & MutableValue () noexcept
 Retrieves the mutable reference to the value of the field.
 
template<typename Self >
requires (IsMandatory)
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord const & Record (this Self &&self)
 Retrieves a record from the relationship. When the record is not optional.
 
template<typename Self >
requires (IsOptional)
LIGHTWEIGHT_FORCE_INLINE constexpr decltype(auto) Record (this Self &&self)
 
template<typename Self >
requires (IsMandatory)
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord & operator* (this Self &&self) noexcept
 
template<typename Self >
requires (IsMandatory)
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord * operator-> (this Self &&self)
 
LIGHTWEIGHT_FORCE_INLINE constexpr bool operator! () const noexcept
 Checks if the field value is NULL.
 
LIGHTWEIGHT_FORCE_INLINE constexpr operator bool () const noexcept
 Checks if the field value is not NULL.
 
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord * LoadedRecord () noexcept
 Returns the already-loaded referenced record, or nullptr when none is loaded.
 
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord const * LoadedRecord () const noexcept
 Returns the already-loaded referenced record, or nullptr when none is loaded.
 
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord & EmplaceRecord ()
 Emplaces a record into the relationship. This will mark the relationship as loaded.
 
LIGHTWEIGHT_FORCE_INLINE void AdoptFetchedRecord (std::optional< ReferencedRecord > record)
 
template<typename Stmt >
LIGHTWEIGHT_FORCE_INLINE void BindOutputColumn (SQLSMALLINT outputIndex, Stmt &stmt)
 Binds the foreign key value to the given output column index on the statement.
 
std::weak_ordering operator<=> (BelongsTo const &other) const noexcept
 Three-way comparison operator.
 
template<detail::FieldElementType T, PrimaryKey IsPrimaryKeyValue = PrimaryKey::No>
std::weak_ordering operator<=> (Field< T, IsPrimaryKeyValue > const &other) const noexcept
 Three-way comparison operator with a Field.
 
bool operator== (BelongsTo const &other) const noexcept
 Equality comparison operator.
 
bool operator!= (BelongsTo const &other) const noexcept
 Inequality comparison operator.
 
template<detail::FieldElementType T, PrimaryKey IsPrimaryKeyValue = PrimaryKey::No>
bool operator== (Field< T, IsPrimaryKeyValue > const &other) const noexcept
 Equality comparison operator with a Field.
 
template<detail::FieldElementType T, PrimaryKey IsPrimaryKeyValue = PrimaryKey::No>
bool operator!= (Field< T, IsPrimaryKeyValue > const &other) const noexcept
 Inequality comparison operator with a Field.
 
void SetAutoLoader (Loader loader) noexcept
 Used internally to configure on-demand loading of the record.
 

Static Public Attributes

static constexpr auto ReferencedField = TheReferencedField
 The field in the other record that references the current record.
 
static constexpr std::string_view ColumnNameOverride
 If not an empty string, this value will be used as the column name in the database.
 
static constexpr auto IsOptional = Nullable == SqlNullable::Null
 Indicates whether this relationship is optional (nullable).
 
static constexpr auto IsMandatory = !IsOptional
 Indicates whether this relationship is mandatory (non-nullable).
 
static constexpr auto IsPrimaryKey = false
 Indicates that a BelongsTo field is never a primary key.
 
static constexpr auto IsAutoIncrementPrimaryKey = false
 Indicates that a BelongsTo field is never an auto-increment primary key.
 

Detailed Description

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
class Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >

Represents the many-to-one side of a foreign-key relationship.

This is the record that owns the foreign-key column: many records holding a BelongsTo may reference the same target record. For a one-to-one relation through a join table, see HasOneThrough; for the inverse (one-to-many) side, see HasMany.

The TheReferencedField parameter is the field in the other record that references the current record, in the form of &OtherRecord::Field. Other Field must be a primary key.

Template Parameters
TheReferencedFieldThe field in the other record that references the current record.
ColumnNameOverrideStringIf not an empty string, this value will be used as the column name in the database.
struct User {
};
struct Email {
// Also possible to customize the column name
BelongsTo<&User::id, SqlRealName<"the_user_id">, SqlNullable::Null> maybe_user;
};
Represents the many-to-one side of a foreign-key relationship.
Definition BelongsTo.hpp:61
Represents a single column in a table.
Definition Field.hpp:84
Helper class, used to represent a real SQL column names as template arguments.

Definition at line 60 of file BelongsTo.hpp.

Member Typedef Documentation

◆ ReferencedRecord

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
using Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::ReferencedRecord = MemberClassType<decltype(TheReferencedField)>

Represents the record type of the other field.

Definition at line 85 of file BelongsTo.hpp.

◆ BaseType

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
using Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::BaseType = std::remove_cvref_t<decltype(std::declval<ReferencedRecord>().*ReferencedField)>::ValueType

Represents the base column type of the foreign key, matching the primary key of the other record.

Definition at line 91 of file BelongsTo.hpp.

◆ ValueType

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
using Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::ValueType = std::conditional_t<Nullable == SqlNullable::Null, std::optional<BaseType>, BaseType>

Represents the value type of the foreign key, which can be either an optional or a non-optional type of the referenced field,

Definition at line 96 of file BelongsTo.hpp.

Constructor & Destructor Documentation

◆ BelongsTo() [1/4]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<typename... S>
requires std::constructible_from<ValueType, S...>
constexpr Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::BelongsTo ( S &&...  value)
inlineconstexprnoexcept

Constructs a new BelongsTo with the given value(s) forwarded to the underlying value type.

Definition at line 110 of file BelongsTo.hpp.

◆ BelongsTo() [2/4]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::BelongsTo ( ReferencedRecord const &  other)
inlineconstexprnoexcept

◆ BelongsTo() [3/4]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::BelongsTo ( BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable > const &  other)
inlineconstexprnoexcept

Copy constructor.

Definition at line 128 of file BelongsTo.hpp.

◆ BelongsTo() [4/4]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::BelongsTo ( BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable > &&  other)
inlineconstexprnoexcept

Move constructor.

Definition at line 138 of file BelongsTo.hpp.

Member Function Documentation

◆ operator=() [1/5]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
BelongsTo & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator= ( SqlNullType  )
inlinenoexcept

Assigns NULL to the relationship, clearing the loaded record.

Definition at line 148 of file BelongsTo.hpp.

◆ operator=() [2/5]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<typename S >
requires (std::constructible_from<ValueType, S> && !std::same_as<std::remove_cvref_t<S>, BelongsTo> && !std::same_as<std::remove_cvref_t<S>, ReferencedRecord> && !std::same_as<std::remove_cvref_t<S>, SqlNullType>)
constexpr BelongsTo & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator= ( S &&  value)
inlineconstexprnoexcept

Assigns a bare foreign-key value, updating the foreign key and marking the field modified.

This is the sibling of Field<T>::operator=(S&&). Without it, record.fk = someKeyValue would bind to the converting constructor plus move-assignment, and the temporary's default-constructed _modified (false) would be copied over this field — leaving the change invisible to DataMapper::Update(), which gates its SET clause on IsModified().

Any previously loaded record is dropped, since it no longer corresponds to the new key.

Parameters
valueThe referenced record's primary-key value to point at.
Returns
Reference to this field.

Definition at line 174 of file BelongsTo.hpp.

◆ operator=() [3/5]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
BelongsTo & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator= ( ReferencedRecord &  other)
inline

◆ operator=() [4/5]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
BelongsTo & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator= ( BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable > const &  other)
inline

Copy assignment operator.

Definition at line 204 of file BelongsTo.hpp.

◆ operator=() [5/5]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
BelongsTo & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator= ( BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable > &&  other)
inlinenoexcept

Move assignment operator.

Definition at line 219 of file BelongsTo.hpp.

◆ SetModified()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr void Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::SetModified ( bool  value)
inlineconstexprnoexcept

Marks the field as modified or unmodified.

Definition at line 235 of file BelongsTo.hpp.

◆ IsModified()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr bool Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::IsModified ( ) const
inlineconstexprnoexcept

Checks if the field is modified.

Definition at line 241 of file BelongsTo.hpp.

◆ Value()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr ValueType const & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::Value ( ) const
inlineconstexprnoexcept

◆ MutableValue()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr ValueType & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::MutableValue ( )
inlineconstexprnoexcept

Retrieves the mutable reference to the value of the field.

Definition at line 253 of file BelongsTo.hpp.

◆ Record() [1/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<typename Self >
requires (IsMandatory)
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord const & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::Record ( this Self &&  self)
inlineconstexpr

Retrieves a record from the relationship. When the record is not optional.

Definition at line 262 of file BelongsTo.hpp.

◆ Record() [2/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<typename Self >
requires (IsOptional)
LIGHTWEIGHT_FORCE_INLINE constexpr decltype(auto) Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::Record ( this Self &&  self)
inlineconstexpr

Retrieves a record from the relationship. When the record is optional we return object similar to std::optional<ReferencedRecord&>

Definition at line 272 of file BelongsTo.hpp.

◆ operator*()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<typename Self >
requires (IsMandatory)
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator* ( this Self &&  self)
inlineconstexprnoexcept

Retrieves the record from the relationship. Only available when the relationship is mandatory.

Definition at line 288 of file BelongsTo.hpp.

◆ operator->()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<typename Self >
requires (IsMandatory)
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord * Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator-> ( this Self &&  self)
inlineconstexpr

Retrieves the record from the relationship. Only available when the relationship is mandatory.

Definition at line 298 of file BelongsTo.hpp.

◆ operator!()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr bool Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator! ( ) const
inlineconstexprnoexcept

Checks if the field value is NULL.

Definition at line 308 of file BelongsTo.hpp.

◆ operator bool()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Checks if the field value is not NULL.

Definition at line 314 of file BelongsTo.hpp.

◆ LoadedRecord() [1/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord * Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::LoadedRecord ( )
inlineconstexprnoexcept

Returns the already-loaded referenced record, or nullptr when none is loaded.

Unlike Record(), this never runs the on-demand loader: it reports what is present right now. That is what lets the batched relation loading walk one level deeper (With<A, B>()) without turning the walk itself into the N+1 it exists to remove.

Returns
Pointer to the loaded record, or nullptr if the relation is unloaded or NULL.

Definition at line 326 of file BelongsTo.hpp.

◆ LoadedRecord() [2/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord const * Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::LoadedRecord ( ) const
inlineconstexprnoexcept

Returns the already-loaded referenced record, or nullptr when none is loaded.

Unlike Record(), this never runs the on-demand loader: it reports what is present right now. That is what lets the batched relation loading walk one level deeper (With<A, B>()) without turning the walk itself into the N+1 it exists to remove.

Returns
Pointer to the loaded record, or nullptr if the relation is unloaded or NULL.

Definition at line 332 of file BelongsTo.hpp.

◆ EmplaceRecord()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE constexpr ReferencedRecord & Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::EmplaceRecord ( )
inlineconstexpr

Emplaces a record into the relationship. This will mark the relationship as loaded.

Definition at line 338 of file BelongsTo.hpp.

◆ AdoptFetchedRecord()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
LIGHTWEIGHT_FORCE_INLINE void Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::AdoptFetchedRecord ( std::optional< ReferencedRecord >  record)
inline

Adopts an eagerly fetched referenced record, marking the relationship loaded.

This is the sink for a record that was already read from the database, as opposed to operator=(ReferencedRecord&), which establishes the relationship and therefore rewrites the foreign key and sets the modified flag. Here the foreign key is already whatever the row said it was, so it is deliberately left untouched and the field stays unmodified - adopting a fetched value is not a pending change to be written back.

An empty record leaves the relationship unloaded rather than clearing the foreign key: a mandatory relationship whose target row is missing is a data-integrity problem to be surfaced by the accessor, not silently turned into NULL.

Parameters
recordThe fetched record, or std::nullopt if the referenced row was absent.

Definition at line 358 of file BelongsTo.hpp.

◆ BindOutputColumn()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<typename Stmt >
LIGHTWEIGHT_FORCE_INLINE void Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::BindOutputColumn ( SQLSMALLINT  outputIndex,
Stmt &  stmt 
)
inline

Binds the foreign key value to the given output column index on the statement.

Definition at line 369 of file BelongsTo.hpp.

◆ operator<=>() [1/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
std::weak_ordering Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator<=> ( BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable > const &  other) const
inlinenoexcept

Three-way comparison operator.

Definition at line 375 of file BelongsTo.hpp.

◆ operator<=>() [2/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<detail::FieldElementType T, PrimaryKey IsPrimaryKeyValue = PrimaryKey::No>
std::weak_ordering Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator<=> ( Field< T, IsPrimaryKeyValue > const &  other) const
inlinenoexcept

Three-way comparison operator with a Field.

Definition at line 382 of file BelongsTo.hpp.

◆ operator==() [1/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
bool Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator== ( BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable > const &  other) const
inlinenoexcept

Equality comparison operator.

Definition at line 388 of file BelongsTo.hpp.

◆ operator!=() [1/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
bool Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator!= ( BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable > const &  other) const
inlinenoexcept

Inequality comparison operator.

Definition at line 394 of file BelongsTo.hpp.

◆ operator==() [2/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<detail::FieldElementType T, PrimaryKey IsPrimaryKeyValue = PrimaryKey::No>
bool Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator== ( Field< T, IsPrimaryKeyValue > const &  other) const
inlinenoexcept

Equality comparison operator with a Field.

Definition at line 401 of file BelongsTo.hpp.

◆ operator!=() [2/2]

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
template<detail::FieldElementType T, PrimaryKey IsPrimaryKeyValue = PrimaryKey::No>
bool Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::operator!= ( Field< T, IsPrimaryKeyValue > const &  other) const
inlinenoexcept

Inequality comparison operator with a Field.

Definition at line 408 of file BelongsTo.hpp.

◆ SetAutoLoader()

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
void Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::SetAutoLoader ( Loader  loader)
inlinenoexcept

Used internally to configure on-demand loading of the record.

Definition at line 419 of file BelongsTo.hpp.

Member Data Documentation

◆ ReferencedField

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr auto Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::ReferencedField = TheReferencedField
staticconstexpr

◆ ColumnNameOverride

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr std::string_view Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::ColumnNameOverride
staticconstexpr
Initial value:
= []() consteval {
if constexpr (!std::same_as<decltype(ColumnNameOverrideString), std::nullopt_t>)
return std::string_view { ColumnNameOverrideString };
else
return std::string_view {};
}()

If not an empty string, this value will be used as the column name in the database.

Definition at line 67 of file BelongsTo.hpp.

◆ IsOptional

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr auto Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::IsOptional = Nullable == SqlNullable::Null
staticconstexpr

Indicates whether this relationship is optional (nullable).

Definition at line 99 of file BelongsTo.hpp.

◆ IsMandatory

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr auto Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::IsMandatory = !IsOptional
staticconstexpr

Indicates whether this relationship is mandatory (non-nullable).

Definition at line 101 of file BelongsTo.hpp.

◆ IsPrimaryKey

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr auto Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::IsPrimaryKey = false
staticconstexpr

Indicates that a BelongsTo field is never a primary key.

Definition at line 103 of file BelongsTo.hpp.

◆ IsAutoIncrementPrimaryKey

template<auto TheReferencedField, auto ColumnNameOverrideString = std::nullopt, SqlNullable Nullable = SqlNullable::NotNull>
constexpr auto Lightweight::BelongsTo< TheReferencedField, ColumnNameOverrideString, Nullable >::IsAutoIncrementPrimaryKey = false
staticconstexpr

Indicates that a BelongsTo field is never an auto-increment primary key.

Definition at line 105 of file BelongsTo.hpp.


The documentation for this class was generated from the following file: