Skip to content
Permalink
Browse files
Default length/precision for double/real fields
  • Loading branch information
domi4484 committed Jul 11, 2021
1 parent eaa9fa9 commit b2c28b03a401c037643150d272a38e0eea2bb59e
Showing with 10 additions and 3 deletions.
  1. +9 −2 src/core/providers/memory/qgsmemoryprovider.cpp
  2. +1 −1 src/core/qgsfield.cpp
@@ -135,8 +135,8 @@ QgsMemoryProvider::QgsMemoryProvider( const QString &uri, const ProviderOptions
// If no match -> use string as type
QVariant::Type type = QVariant::String;
QVariant::Type subType = QVariant::Invalid;
QString typeName = QStringLiteral( "string" );
int length = -1;
QString typeName( QStringLiteral( "string" ) );
int length = 255;
int precision = 0;

if ( regularExpressionMatch.hasMatch() )
@@ -185,6 +185,13 @@ QgsMemoryProvider::QgsMemoryProvider( const QString &uri, const ProviderOptions
}
}

// Set default length/precision for double/real
if ( typeName == QLatin1String( "real" ) || typeName == QLatin1String( "double" ) )
{
length = 20;
precision = 5;
}

if ( !regularExpressionMatch.captured( 2 ).isEmpty() )
length = regularExpressionMatch.captured( 2 ).toInt();

@@ -312,7 +312,7 @@ QString QgsField::displayString( const QVariant &v ) const
}
}
// Default for doubles with precision
else if ( d->type == QVariant::Double && d->precision > 0 )
else if ( d->precision > 0 )
{
if ( -1 < v.toDouble() && v.toDouble() < 1 )
{

0 comments on commit b2c28b0

Please sign in to comment.