diff --git a/python/PyQt6/core/auto_generated/qgsfieldconstraints.sip.in b/python/PyQt6/core/auto_generated/qgsfieldconstraints.sip.in index e96ba5a1d631..8c27d2e82162 100644 --- a/python/PyQt6/core/auto_generated/qgsfieldconstraints.sip.in +++ b/python/PyQt6/core/auto_generated/qgsfieldconstraints.sip.in @@ -72,7 +72,8 @@ is not present on this field. ConstraintStrength constraintStrength( Constraint constraint ) const; %Docstring Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint -is not present on this field. +is not present on this field. If the strength is not set returns ConstraintStrengthNotSet +for anything but ConstraintExpression when returns ConstraintStrengthHard. .. seealso:: :py:func:`constraints` diff --git a/python/core/auto_generated/qgsfieldconstraints.sip.in b/python/core/auto_generated/qgsfieldconstraints.sip.in index 51ef4a9b8ba8..f26ffa6f6e28 100644 --- a/python/core/auto_generated/qgsfieldconstraints.sip.in +++ b/python/core/auto_generated/qgsfieldconstraints.sip.in @@ -72,7 +72,8 @@ is not present on this field. ConstraintStrength constraintStrength( Constraint constraint ) const; %Docstring Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint -is not present on this field. +is not present on this field. If the strength is not set returns ConstraintStrengthNotSet +for anything but ConstraintExpression when returns ConstraintStrengthHard. .. seealso:: :py:func:`constraints` diff --git a/src/core/qgsfieldconstraints.cpp b/src/core/qgsfieldconstraints.cpp index 371ea825b199..4954916497a3 100644 --- a/src/core/qgsfieldconstraints.cpp +++ b/src/core/qgsfieldconstraints.cpp @@ -29,8 +29,8 @@ QgsFieldConstraints::ConstraintStrength QgsFieldConstraints::constraintStrength( if ( !( mConstraints & constraint ) ) return ConstraintStrengthNotSet; - // defaults to not set - return mConstraintStrengths.value( constraint, ConstraintStrengthNotSet ); + // defaults to not set for all but expressions (which does not use strength) + return mConstraintStrengths.value( constraint, constraint == ConstraintExpression ? ConstraintStrengthHard : ConstraintStrengthNotSet ); } void QgsFieldConstraints::setConstraintStrength( QgsFieldConstraints::Constraint constraint, QgsFieldConstraints::ConstraintStrength strength ) diff --git a/src/core/qgsfieldconstraints.h b/src/core/qgsfieldconstraints.h index a5e0ee5752a8..f23b4cc5005a 100644 --- a/src/core/qgsfieldconstraints.h +++ b/src/core/qgsfieldconstraints.h @@ -89,7 +89,8 @@ class CORE_EXPORT QgsFieldConstraints /** * Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint - * is not present on this field. + * is not present on this field. If the strength is not set returns ConstraintStrengthNotSet + * for anything but ConstraintExpression when returns ConstraintStrengthHard. * \see constraints() * \see setConstraintStrength() */