Skip to content

Commit

Permalink
Exception for constraint expression
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Oct 8, 2024
1 parent 6ab87a1 commit e67e777
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion python/PyQt6/core/auto_generated/qgsfieldconstraints.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
3 changes: 2 additions & 1 deletion python/core/auto_generated/qgsfieldconstraints.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsfieldconstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsfieldconstraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
*/
Expand Down

0 comments on commit e67e777

Please sign in to comment.