Skip to content
Permalink
Browse files

Fix int/integer datatype confusion in primary key identification for …

…the sqlanywhere provider
  • Loading branch information
ddehaan
ddehaan committed Oct 28, 2012
1 parent 462d8a8 commit e0f9d53e637fbe84aba9822db1fabe4300d42ed7
@@ -557,7 +557,7 @@ QgsSqlAnywhereProvider::findKeyColumn()
"FROM SYSTABCOL "
"WHERE table_id = %1 "
"AND column_name = %2 "
"AND base_type_str IN ( 'int', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) " )
"AND base_type_str IN ( 'int', 'integer', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) " )
.arg( mTableId )
.arg( quotedValue( mKeyColumn ) );
stmt = mConnRO->execute_direct( sql );
@@ -630,7 +630,7 @@ QgsSqlAnywhereProvider::findKeyColumn()
"'SELECT * FROM %1', 1 ) dq1 "
"WHERE is_key_column = 1 "
"AND is_added_key_column = 0 "
"AND domain_name IN ( 'int', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) "
"AND domain_name IN ( 'int', 'integer', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) "
"AND NOT EXISTS ( "
"SELECT column_number "
"FROM sa_describe_query( "
@@ -662,7 +662,7 @@ QgsSqlAnywhereProvider::findKeyColumn()
"AND c.column_id = ic.column_id "
"WHERE i.table_id = %1 "
"AND i.\"unique\" IN ( 1, 2 ) "
"AND c.base_type_str IN ( 'int', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) "
"AND c.base_type_str IN ( 'int', 'integer', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) "
"AND NOT EXISTS ( "
"SELECT column_id "
"FROM SYSIDXCOL ic2 "
@@ -686,7 +686,7 @@ QgsSqlAnywhereProvider::findKeyColumn()
sql = QString( "SELECT column_name "
"FROM SYSTABCOL "
"WHERE table_id = %1 "
"AND base_type_str IN ( 'int', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) " )
"AND base_type_str IN ( 'int', 'integer', 'unsigned int', 'smallint', 'unsigned smallint', 'tinyint' ) " )
.arg( mTableId );
stmt = mConnRO->execute_direct( sql );
while ( stmt->isValid() && stmt->fetchNext() )
@@ -1018,6 +1018,7 @@ QgsSqlAnywhereProvider::uniqueValues( int index, QList < QVariant > &uniqueValue
}
} // QgsSqlAnywhereProvider::uniqueValues()


QString
QgsSqlAnywhereProvider::getDefaultValue( QString attrName )
{
@@ -1582,6 +1583,10 @@ QgsSqlAnywhereProvider::changeGeometryValues( QgsGeometryMap & gmap )
return ok;
} // QgsSqlAnywhereProvider::changeGeometryValues()

QgsAttributeList QgsSqlAnywhereProvider::attributeIndexes()
{
return mAttributeFields.keys();
}

bool
QgsSqlAnywhereProvider::ensureConnRO()
@@ -152,10 +152,22 @@ class QgsSqlAnywhereProvider: public QgsVectorDataProvider
* @param limit maximum number of values (added in 1.4) */
virtual void uniqueValues( int index, QList < QVariant > &uniqueValues, int limit = -1 );

/** Returns the possible enum values of an attribute.
* Returns an empty stringlist if a provider does not support enum types
* or if the given attribute is not an enum type.
* @param index the index of the attribute
* @param enumList reference to the list to fill
* @note: added in version 1.2
* SQLAnywhere does not currently support enumerated types.
*/
//virtual void enumValues( int index, QStringList& enumList );

/**Returns true if layer is valid
*/
bool isValid() { return mValid; }

QgsAttributeList attributeIndexes();

/**Returns the default value for field specified by @c fieldId */
QVariant defaultValue( int fieldId ) { return mAttributeDefaults[fieldId]; }

0 comments on commit e0f9d53

Please sign in to comment.
You can’t perform that action at this time.