mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-08 09:59:23 -05:00
drivers added SqlField::isNullColumn()
This commit is contained in:
@@ -101,7 +101,10 @@ namespace Orm::Drivers
|
||||
/*! Set the field QVariant value metatype (for invalid values only). */
|
||||
void setMetaType(QMetaType metaType);
|
||||
|
||||
/*! Determine whether a field is required. */
|
||||
/*! Determine whether a field is SQL nullable (NULL in the table definition). */
|
||||
inline bool isNullColumn() const noexcept;
|
||||
|
||||
/*! Determine whether a field is required (!NULL in the table definition). */
|
||||
inline bool isRequired() const noexcept;
|
||||
/*! Set the required field status. */
|
||||
inline void setRequired(bool required) noexcept;
|
||||
@@ -251,6 +254,12 @@ namespace Orm::Drivers
|
||||
return m_metaType;
|
||||
}
|
||||
|
||||
bool SqlField::isNullColumn() const noexcept
|
||||
{
|
||||
// Very confusing, I can't do anything about it to have compatible API 😔
|
||||
return m_requiredStatus == Optional;
|
||||
}
|
||||
|
||||
bool SqlField::isRequired() const noexcept
|
||||
{
|
||||
return m_requiredStatus == Required;
|
||||
|
||||
@@ -66,6 +66,11 @@ namespace Orm::Drivers
|
||||
/*! Set the value of the field with the field name to the given value. */
|
||||
void setValue(const QString &name, QVariant &&value);
|
||||
|
||||
/*! Determine whether a field is SQL nullable (NULL in the table definition). */
|
||||
bool isNullColumn(size_type index) const;
|
||||
/*! Determine whether a field is SQL nullable (NULL in the table definition). */
|
||||
bool isNullColumn(const QString &name) const;
|
||||
|
||||
/*! Determine whether the field at the given index is NULL. */
|
||||
bool isNull(size_type index) const;
|
||||
/*! Determine whether the field with the given field name is NULL. */
|
||||
|
||||
@@ -93,6 +93,19 @@ void SqlRecord::setValue(const QString &name, QVariant &&value)
|
||||
setValue(indexOf(name), std::move(value));
|
||||
}
|
||||
|
||||
bool SqlRecord::isNullColumn(const size_type index) const
|
||||
{
|
||||
// Throw the OutOfRangeError exception if the record doesn't contain an index
|
||||
throwIfNotContains(index);
|
||||
|
||||
return m_fields[index].isNullColumn();
|
||||
}
|
||||
|
||||
bool SqlRecord::isNullColumn(const QString &name) const
|
||||
{
|
||||
return isNullColumn(indexOf(name));
|
||||
}
|
||||
|
||||
bool SqlRecord::isNull(const size_type index) const
|
||||
{
|
||||
// Throw the OutOfRangeError exception if the record doesn't contain an index
|
||||
|
||||
Reference in New Issue
Block a user