Skip to content

Commit 2f5c193

Browse files
committedMar 4, 2016
Fix handling of longlong fields in memory provider
(cherry-picked from 98a216e)
1 parent c8950e2 commit 2f5c193

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
 

‎src/providers/memory/qgsmemoryprovider.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ QgsMemoryProvider::QgsMemoryProvider( const QString& uri )
108108
{
109109
QList<QgsField> attributes;
110110
QRegExp reFieldDef( "\\:"
111-
"(int|integer|real|double|string|date|time|datetime)" // type
112-
"(?:\\((\\d+)" // length
111+
"(int|integer|long|int8|real|double|string|date|time|datetime)" // type
112+
"(?:\\((\\-?\\d+)" // length
113113
"(?:\\,(\\d+))?" // precision
114114
"\\))?"
115115
"$", Qt::CaseInsensitive );
@@ -131,7 +131,13 @@ QgsMemoryProvider::QgsMemoryProvider( const QString& uri )
131131
{
132132
type = QVariant::Int;
133133
typeName = "integer";
134-
length = 10;
134+
length = -1;
135+
}
136+
else if ( typeName == "int8" || typeName == "long" )
137+
{
138+
type = QVariant::LongLong;
139+
typeName = "int8";
140+
length = -1;
135141
}
136142
else if ( typeName == "real" || typeName == "double" )
137143
{

‎tests/src/python/test_provider_memory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def testSaveFields(self):
227227

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

0 commit comments

Comments
 (0)
Please sign in to comment.