Skip to content

Commit

Permalink
MSSQL: Fix for handling spatial tables with no FID columns (#7254)
Browse files Browse the repository at this point in the history
  • Loading branch information
szekerest committed Mar 1, 2013
1 parent 9dbd21a commit 2b52f49
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ QgsMssqlProvider::QgsMssqlProvider( QString uri )
mWkbType = QGis::WKBNoGeometry;
mSRId = 0;
}

if ( mFidColName.isEmpty() )
mValid = false;
}

//fill type names into sets
Expand Down Expand Up @@ -947,6 +944,9 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap & at
if ( attr_map.isEmpty() )
return true;

if ( mFidColName.isEmpty() )
return false;

for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
QgsFeatureId fid = it.key();
Expand Down Expand Up @@ -1055,6 +1055,9 @@ bool QgsMssqlProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
if ( geometry_map.isEmpty() )
return true;

if ( mFidColName.isEmpty() )
return false;

for ( QgsGeometryMap::iterator it = geometry_map.begin(); it != geometry_map.end(); ++it )
{
QgsFeatureId fid = it.key();
Expand Down Expand Up @@ -1125,6 +1128,9 @@ bool QgsMssqlProvider::changeGeometryValues( QgsGeometryMap & geometry_map )

bool QgsMssqlProvider::deleteFeatures( const QgsFeatureIds & id )
{
if ( mFidColName.isEmpty() )
return false;

QString featureIds;
for ( QgsFeatureIds::const_iterator it = id.begin(); it != id.end(); ++it )
{
Expand Down Expand Up @@ -1156,7 +1162,10 @@ bool QgsMssqlProvider::deleteFeatures( const QgsFeatureIds & id )

int QgsMssqlProvider::capabilities() const
{
return CreateSpatialIndex | CreateAttributeIndex | AddFeatures | DeleteFeatures |
if (mFidColName.isEmpty())
return CreateSpatialIndex | CreateAttributeIndex | AddFeatures | AddAttributes;
else
return CreateSpatialIndex | CreateAttributeIndex | AddFeatures | DeleteFeatures |
ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
}
Expand Down

0 comments on commit 2b52f49

Please sign in to comment.