Skip to content
Permalink
Browse files
Default length/precision for double/real fields
  • Loading branch information
domi4484 committed Aug 17, 2021
1 parent 048e647 commit 75a4f28451501177ceb66cf11486b129512aadb2
Showing with 10 additions and 3 deletions.
  1. +9 −2 src/core/providers/memory/qgsmemoryprovider.cpp
  2. +1 −1 src/core/qgsfield.cpp
@@ -129,8 +129,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() )
@@ -179,6 +179,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 75a4f28

Please sign in to comment.