@@ -264,13 +264,52 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
264
264
.arg ( mNativeTypes [i].mMaxLen )
265
265
.arg ( mNativeTypes [i].mMinPrec )
266
266
.arg ( mNativeTypes [i].mMaxPrec ), 2 );
267
- if ( field.type () == mNativeTypes [i].mType &&
268
- field.length () >= mNativeTypes [i].mMinLen && field.length () <= mNativeTypes [i].mMaxLen &&
269
- field.precision () >= mNativeTypes [i].mMinPrec && field.precision () <= mNativeTypes [i].mMaxPrec )
267
+
268
+ if ( field.type () != mNativeTypes [i].mType )
269
+ continue ;
270
+
271
+ if ( field.length () == -1 )
272
+ {
273
+ // source length unlimited
274
+ if ( mNativeTypes [i].mMinLen > -1 || mNativeTypes [i].mMaxLen > -1 )
275
+ {
276
+ // destination limited
277
+ continue ;
278
+ }
279
+ }
280
+ else
281
+ {
282
+ // source length limited
283
+ if ( mNativeTypes [i].mMinLen > -1 && mNativeTypes [i].mMaxLen > -1 &&
284
+ ( field.length () < mNativeTypes [i].mMinLen || field.length () < mNativeTypes [i].mMaxLen ) )
285
+ {
286
+ // source length exceeds destination limits
287
+ continue ;
288
+ }
289
+ }
290
+
291
+ if ( field.precision () == -1 )
292
+ {
293
+ // source precision unlimited / n/a
294
+ if ( mNativeTypes [i].mMinPrec > -1 || mNativeTypes [i].mMaxPrec > -1 )
295
+ {
296
+ // destination limited
297
+ continue ;
298
+ }
299
+ }
300
+ else
270
301
{
271
- QgsDebugMsg ( " native type matches" );
272
- return true ;
302
+ // source precision unlimited / n/a
303
+ if ( mNativeTypes [i].mMinPrec > -1 && mNativeTypes [i].mMaxPrec > -1 &&
304
+ ( field.precision () < mNativeTypes [i].mMinPrec || field.precision () < mNativeTypes [i].mMaxPrec ) )
305
+ {
306
+ // source precision exceeds destination limits
307
+ continue ;
308
+ }
273
309
}
310
+
311
+ QgsDebugMsg ( " native type matches" );
312
+ return true ;
274
313
}
275
314
276
315
QgsDebugMsg ( " no sufficient native type found" );
0 commit comments