Skip to content
Permalink
Browse files

QgsVectorDataProvider::supportedType(): use -1 as the value for unspe…

…cified length/width (this is the default in QgsField constructor and QgsVectorDataProvider::NativeType())
  • Loading branch information
rouault authored and slarosa committed Jun 1, 2018
1 parent 1a8f06e commit 00c301e5b28f03c5f87e6c93ae272fe9f2387ea1
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/core/qgsvectordataprovider.cpp
@@ -309,10 +309,10 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
if ( field.type() != nativeType.mType )
continue;

if ( field.length() == -1 )
if ( field.length() <= 0 )
{
// source length unlimited
if ( nativeType.mMinLen > -1 || nativeType.mMaxLen > -1 )
if ( nativeType.mMinLen > 0 || nativeType.mMaxLen > 0 )
{
// destination limited
continue;
@@ -321,18 +321,18 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
else
{
// source length limited
if ( nativeType.mMinLen > -1 && nativeType.mMaxLen > -1 &&
( field.length() < nativeType.mMinLen || field.length() > nativeType.mMaxLen ) )
if ( ( nativeType.mMinLen > 0 && field.length() < nativeType.mMinLen ) ||
( nativeType.mMaxLen > 0 && field.length() > nativeType.mMaxLen ) )
{
// source length exceeds destination limits
continue;
}
}

if ( field.precision() == -1 )
if ( field.precision() <= 0 )
{
// source precision unlimited / n/a
if ( nativeType.mMinPrec > -1 || nativeType.mMaxPrec > -1 )
if ( nativeType.mMinPrec > 0 || nativeType.mMaxPrec > 0 )
{
// destination limited
continue;
@@ -341,8 +341,8 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
else
{
// source precision unlimited / n/a
if ( nativeType.mMinPrec > -1 && nativeType.mMaxPrec > -1 &&
( field.precision() < nativeType.mMinPrec || field.precision() > nativeType.mMaxPrec ) )
if ( ( nativeType.mMinPrec > 0 && field.precision() < nativeType.mMinPrec ) ||
( nativeType.mMaxPrec > 0 && field.precision() > nativeType.mMaxPrec ) )
{
// source precision exceeds destination limits
continue;

0 comments on commit 00c301e

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