Skip to content

Commit

Permalink
fix #4227
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 26, 2012
1 parent 956995c commit cfcfa08
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -354,7 +354,7 @@ bool QgsOgrProvider::setSubsetString( QString theSQL, bool updateFeatureCount )
.arg( quotedIdentifier( FROM8( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) ) ) ) )
.arg( mSubsetString );
QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) );
ogrLayer = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, NULL );
ogrLayer = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).constData(), NULL, NULL );

if ( !ogrLayer )
{
Expand Down Expand Up @@ -871,7 +871,7 @@ QgsRectangle QgsOgrProvider::extent()

void QgsOgrProvider::updateExtents()
{
if( extent_ )
if ( extent_ )
{
free( extent_ );
extent_ = 0;
Expand Down Expand Up @@ -1279,7 +1279,7 @@ bool QgsOgrProvider::createSpatialIndex()

QString sql = QString( "CREATE SPATIAL INDEX ON %1" ).arg( quotedIdentifier( layerName ) ); // quote the layer name so spaces are handled
QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) );
OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "" );
OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "" );

QFileInfo fi( mFilePath ); // to get the base name
//find out, if the .qix file is there
Expand All @@ -1291,9 +1291,9 @@ bool QgsOgrProvider::createAttributeIndex( int field )
{
QString layerName = OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) );
QString dropSql = QString( "DROP INDEX ON %1" ).arg( quotedIdentifier( layerName ) );
OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( dropSql ).constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
QString createSql = QString( "CREATE INDEX ON %1 USING %2" ).arg( quotedIdentifier( layerName ) ).arg( fields()[field].name() );
OGR_DS_ExecuteSQL( ogrDataSource, TO8( dropSql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
OGR_DS_ExecuteSQL( ogrDataSource, TO8( createSql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( createSql ).constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );

QFileInfo fi( mFilePath ); // to get the base name
//find out, if the .idm file is there
Expand Down Expand Up @@ -1323,7 +1323,7 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds & id )

QString sql = QString( "REPACK %1" ).arg( layerName ); // don't quote the layer name as it works with spaces in the name and won't work if the name is quoted
QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) );
OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, NULL );
OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).constData(), NULL, NULL );

recalculateFeatureCount();

Expand Down Expand Up @@ -2144,7 +2144,7 @@ void QgsOgrProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, int
sql += QString( " ORDER BY %1 ASC" ).arg( fld.name() ); // quoting of fieldname produces a syntax error

QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) );
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" );
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).constData(), NULL, "SQL" );
if ( l == 0 )
return QgsVectorDataProvider::uniqueValues( index, uniqueValues, limit );

Expand Down Expand Up @@ -2181,7 +2181,7 @@ QVariant QgsOgrProvider::minimumValue( int index )
sql += QString( " WHERE %1" ).arg( mSubsetString );
}

OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" );
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).constData(), NULL, "SQL" );

if ( l == 0 )
return QgsVectorDataProvider::minimumValue( index );
Expand Down Expand Up @@ -2221,7 +2221,7 @@ QVariant QgsOgrProvider::maximumValue( int index )
sql += QString( " WHERE %1" ).arg( mSubsetString );
}

OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" );
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).constData(), NULL, "SQL" );
if ( l == 0 )
return QgsVectorDataProvider::maximumValue( index );

Expand Down

0 comments on commit cfcfa08

Please sign in to comment.