Skip to content

Commit e0f9d53

Browse files
author
ddehaan
committedOct 28, 2012
Fix int/integer datatype confusion in primary key identification for the sqlanywhere provider
1 parent 462d8a8 commit e0f9d53

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed
 

‎src/providers/sqlanywhere/qgssqlanywhereprovider.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ QgsSqlAnywhereProvider::findKeyColumn()
557557
"FROM SYSTABCOL "
558558
"WHERE table_id = %1 "
559559
"AND column_name = %2 "
560-
"AND base_type_str IN ( 'int', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) " )
560+
"AND base_type_str IN ( 'int', 'integer', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) " )
561561
.arg( mTableId )
562562
.arg( quotedValue( mKeyColumn ) );
563563
stmt = mConnRO->execute_direct( sql );
@@ -630,7 +630,7 @@ QgsSqlAnywhereProvider::findKeyColumn()
630630
"'SELECT * FROM %1', 1 ) dq1 "
631631
"WHERE is_key_column = 1 "
632632
"AND is_added_key_column = 0 "
633-
"AND domain_name IN ( 'int', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) "
633+
"AND domain_name IN ( 'int', 'integer', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) "
634634
"AND NOT EXISTS ( "
635635
"SELECT column_number "
636636
"FROM sa_describe_query( "
@@ -662,7 +662,7 @@ QgsSqlAnywhereProvider::findKeyColumn()
662662
"AND c.column_id = ic.column_id "
663663
"WHERE i.table_id = %1 "
664664
"AND i.\"unique\" IN ( 1, 2 ) "
665-
"AND c.base_type_str IN ( 'int', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) "
665+
"AND c.base_type_str IN ( 'int', 'integer', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) "
666666
"AND NOT EXISTS ( "
667667
"SELECT column_id "
668668
"FROM SYSIDXCOL ic2 "
@@ -686,7 +686,7 @@ QgsSqlAnywhereProvider::findKeyColumn()
686686
sql = QString( "SELECT column_name "
687687
"FROM SYSTABCOL "
688688
"WHERE table_id = %1 "
689-
"AND base_type_str IN ( 'int', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) " )
689+
"AND base_type_str IN ( 'int', 'integer', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) " )
690690
.arg( mTableId );
691691
stmt = mConnRO->execute_direct( sql );
692692
while ( stmt->isValid() && stmt->fetchNext() )
@@ -1018,6 +1018,7 @@ QgsSqlAnywhereProvider::uniqueValues( int index, QList < QVariant > &uniqueValue
10181018
}
10191019
} // QgsSqlAnywhereProvider::uniqueValues()
10201020

1021+
10211022
QString
10221023
QgsSqlAnywhereProvider::getDefaultValue( QString attrName )
10231024
{
@@ -1582,6 +1583,10 @@ QgsSqlAnywhereProvider::changeGeometryValues( QgsGeometryMap & gmap )
15821583
return ok;
15831584
} // QgsSqlAnywhereProvider::changeGeometryValues()
15841585

1586+
QgsAttributeList QgsSqlAnywhereProvider::attributeIndexes()
1587+
{
1588+
return mAttributeFields.keys();
1589+
}
15851590

15861591
bool
15871592
QgsSqlAnywhereProvider::ensureConnRO()

‎src/providers/sqlanywhere/qgssqlanywhereprovider.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,22 @@ class QgsSqlAnywhereProvider: public QgsVectorDataProvider
152152
* @param limit maximum number of values (added in 1.4) */
153153
virtual void uniqueValues( int index, QList < QVariant > &uniqueValues, int limit = -1 );
154154

155+
/** Returns the possible enum values of an attribute.
156+
* Returns an empty stringlist if a provider does not support enum types
157+
* or if the given attribute is not an enum type.
158+
* @param index the index of the attribute
159+
* @param enumList reference to the list to fill
160+
* @note: added in version 1.2
161+
* SQLAnywhere does not currently support enumerated types.
162+
*/
163+
//virtual void enumValues( int index, QStringList& enumList );
164+
155165
/**Returns true if layer is valid
156166
*/
157167
bool isValid() { return mValid; }
158168

169+
QgsAttributeList attributeIndexes();
170+
159171
/**Returns the default value for field specified by @c fieldId */
160172
QVariant defaultValue( int fieldId ) { return mAttributeDefaults[fieldId]; }
161173

0 commit comments

Comments
 (0)
Please sign in to comment.