File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,13 @@ bool QgsField::convertCompatible( QVariant &v ) const
281
281
return true ;
282
282
}
283
283
284
+ // Give it a chance to convert to double since we accept both comma and dot as decimal point
285
+ QVariant tmp ( v );
286
+ if ( d->type == QVariant::Double && !tmp.convert ( d->type ) )
287
+ {
288
+ v = v.toString ().replace ( ' ,' , ' .' );
289
+ }
290
+
284
291
if ( !v.convert ( d->type ) )
285
292
{
286
293
v = QVariant ( d->type );
Original file line number Diff line number Diff line change @@ -346,7 +346,6 @@ void TestQgsField::displayString()
346
346
QCOMPARE ( doubleFieldNoPrec.displayString ( 5.005005005 ), QString ( " 5,005005005" ) );
347
347
QCOMPARE ( doubleFieldNoPrec.displayString ( 599999898999.0 ), QString ( " 599.999.898.999" ) );
348
348
349
-
350
349
}
351
350
352
351
void TestQgsField::convertCompatible ()
@@ -475,6 +474,12 @@ void TestQgsField::convertCompatible()
475
474
QVERIFY ( !stringWithLen.convertCompatible ( stringVar ) );
476
475
QCOMPARE ( stringVar.type (), QVariant::String );
477
476
QCOMPARE ( stringVar.toString (), QString ( " lon" ) );
477
+
478
+ // double with ',' as decimal separator
479
+ QVariant doubleCommaVar ( " 1,2345" );
480
+ QVERIFY ( doubleField.convertCompatible ( doubleCommaVar ) );
481
+ QCOMPARE ( doubleCommaVar.type (), QVariant::Double );
482
+ QCOMPARE ( doubleCommaVar.toString (), QString ( " 1.2345" ) );
478
483
}
479
484
480
485
void TestQgsField::dataStream ()
You can’t perform that action at this time.
0 commit comments