Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 Jul 6, 2018
1 parent 1a8f06e commit 00c301e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/qgsvectordataprovider.cpp
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 00c301e

Please sign in to comment.