Skip to content
Permalink
Browse files

Merge pull request #8302 from elpaso/bugfix-20200-pg-sequence-in-forms

Check if we have a numeric value before stripping the group separator
  • Loading branch information
elpaso committed Oct 24, 2018
2 parents 9cb4d57 + 797911e commit 4f0a8003f17b26e6425c59e045014402b3381f98
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/gui/editorwidgets/qgstexteditwrapper.cpp
@@ -229,8 +229,13 @@ void QgsTextEditWrapper::setWidgetValue( const QVariant &val )
// For numbers, remove the group separator that might cause validation errors
// when the user is editing the field value.
// We are checking for editable layer because in the form field context we do not
// want to strip the separator unless the layer is editable
if ( layer() && layer()->isEditable() && ! QLocale().groupSeparator().isNull() && field().isNumeric() )
// want to strip the separator unless the layer is editable.
// Also check that we have something like a number in the value to avoid
// stripping out dots from nextval when we have a schema: see https://issues.qgis.org/issues/20200
// "Wrong sequence detection with Postgres"
bool canConvertToDouble;
QLocale().toDouble( v, &canConvertToDouble );
if ( canConvertToDouble && layer() && layer()->isEditable() && ! QLocale().groupSeparator().isNull() && field().isNumeric() )
{
v = v.remove( QLocale().groupSeparator() );
}

0 comments on commit 4f0a800

Please sign in to comment.
You can’t perform that action at this time.