Skip to content

Commit

Permalink
bugfix previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Nov 26, 2022
1 parent 796eb18 commit 4959f7d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions include/orm/tiny/concerns/hasattributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,17 +1436,21 @@ namespace Orm::Tiny::Concerns
// Throw if the given attribute can not be converted to the given cast type
throwIfCanNotCastAttribute(key, castType, metaType, value_, functionName);

/* Still check for the false value and log to the debug stream, but not if
the value_ is null, because converting null QVariant will always return
false and the QVariant type will be changed anyway. */
#ifdef TINYORM_DEBUG
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (!value_.convert(metaType) && !value_.isNull())
const auto &metaTypeId = metaType;
#else
if (!value_.convert(metaType.id()) && !value_.isNull())
const auto metaTypeId = metaType.id();
#endif

#ifdef TINYORM_DEBUG
/* Still check for the false value and log to the debug stream, but not if
the value_ is null, because converting null QVariant will always return
false and the QVariant type will be changed anyway. */
if (!value_.convert(metaTypeId) && !value_.isNull())
// Log if the QVariant::convert() for the given attribute failed
logIfConvertAttributeFailed(key, castType, metaType, functionName);
#else
value_.convert(metaTypeId);
#endif

return value_;
Expand Down

0 comments on commit 4959f7d

Please sign in to comment.