Skip to content

Commit

Permalink
Fix handling of longlong fields in memory provider
Browse files Browse the repository at this point in the history
(cherry-picked from 98a216e)
  • Loading branch information
nyalldawson committed Mar 4, 2016
1 parent c8950e2 commit 2f5c193
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/providers/memory/qgsmemoryprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ QgsMemoryProvider::QgsMemoryProvider( const QString& uri )
{
QList<QgsField> attributes;
QRegExp reFieldDef( "\\:"
"(int|integer|real|double|string|date|time|datetime)" // type
"(?:\\((\\d+)" // length
"(int|integer|long|int8|real|double|string|date|time|datetime)" // type
"(?:\\((\\-?\\d+)" // length
"(?:\\,(\\d+))?" // precision
"\\))?"
"$", Qt::CaseInsensitive );
Expand All @@ -131,7 +131,13 @@ QgsMemoryProvider::QgsMemoryProvider( const QString& uri )
{
type = QVariant::Int;
typeName = "integer";
length = 10;
length = -1;
}
else if ( typeName == "int8" || typeName == "long" )
{
type = QVariant::LongLong;
typeName = "int8";
length = -1;
}
else if ( typeName == "real" || typeName == "double" )
{
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_provider_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def testSaveFields(self):

# Add some fields to the layer
myFields = [QgsField('TestInt', QVariant.Int, 'integer', 2, 0),
QgsField('TestLong', QVariant.LongLong, 'long', -1, 0),
QgsField('TestDbl', QVariant.Double, 'double', 8, 6),
QgsField('TestString', QVariant.String, 'string', 50, 0),
QgsField('TestDate', QVariant.Date, 'date'),
Expand Down

0 comments on commit 2f5c193

Please sign in to comment.