diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index 17b82281a64..5edbc50ba23 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -246,7 +246,7 @@ bool QgsOgrProvider::setSubsetString( QString theSQL, bool updateFeatureCount ) .arg( quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) ) ) ) .arg( mSubsetString ); QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) ); - ogrLayer = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).constData(), NULL, NULL ); + ogrLayer = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, NULL ); if ( !ogrLayer ) { @@ -921,7 +921,7 @@ bool QgsOgrProvider::addAttributes( const QList &attributes ) continue; } - OGRFieldDefnH fielddefn = OGR_Fld_Create( mEncoding->fromUnicode( iter->name() ).data(), type ); + OGRFieldDefnH fielddefn = OGR_Fld_Create( TO8( iter->name() ), type ); OGR_Fld_SetWidth( fielddefn, iter->length() ); OGR_Fld_SetPrecision( fielddefn, iter->precision() ); @@ -1074,7 +1074,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, mEncoding->fromUnicode( sql ).data(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "" ); + OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "" ); QFileInfo fi( mFilePath ); // to get the base name //find out, if the .qix file is there @@ -1087,8 +1087,8 @@ bool QgsOgrProvider::createAttributeIndex( int field ) QString layerName = OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) ); QString dropSql = QString( "DROP INDEX ON %1" ).arg( quotedIdentifier( layerName ) ); QString createSql = QString( "CREATE INDEX ON %1 USING %2" ).arg( quotedIdentifier( layerName ) ).arg( fields()[field].name() ); - OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( dropSql ).data(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" ); - OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( createSql ).data(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" ); + OGR_DS_ExecuteSQL( ogrDataSource, TO8( dropSql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" ); + OGR_DS_ExecuteSQL( ogrDataSource, TO8( createSql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" ); QFileInfo fi( mFilePath ); // to get the base name //find out, if the .idm file is there @@ -1118,7 +1118,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, mEncoding->fromUnicode( sql ).data(), NULL, NULL ); + OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, NULL ); recalculateFeatureCount(); @@ -1747,7 +1747,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri, if ( precision < 0 ) precision = 3; - field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTReal ); + field = OGR_Fld_Create( TO8( it->first ), OFTReal ); OGR_Fld_SetWidth( field, width ); OGR_Fld_SetPrecision( field, precision ); } @@ -1756,7 +1756,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri, if ( width < 0 || width > 10 ) width = 10; - field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTInteger ); + field = OGR_Fld_Create( TO8( it->first ), OFTInteger ); // limit to 10. otherwise OGR sets it to 11 and recognizes as OFTDouble later OGR_Fld_SetWidth( field, width ); } @@ -1765,7 +1765,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri, if ( width < 0 || width > 255 ) width = 255; - field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTString ); + field = OGR_Fld_Create( TO8( it->first ), OFTString ); OGR_Fld_SetWidth( field, width ); } else @@ -1880,10 +1880,10 @@ void QgsOgrProvider::uniqueValues( int index, QList &uniqueValues, int sql += QString( " WHERE %1" ).arg( mSubsetString ); } - sql += QString( " ORDER BY %1" ).arg( fld.name() ); + sql += QString( " ORDER BY %1" ).arg( quotedIdentifier( fld.name() ) ); QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) ); - OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, "SQL" ); + OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" ); if ( l == 0 ) return QgsVectorDataProvider::uniqueValues( index, uniqueValues, limit ); @@ -1914,7 +1914,7 @@ QVariant QgsOgrProvider::minimumValue( int index ) sql += QString( " WHERE %1" ).arg( mSubsetString ); } - OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, "SQL" ); + OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" ); if ( l == 0 ) return QgsVectorDataProvider::minimumValue( index ); @@ -1948,7 +1948,7 @@ QVariant QgsOgrProvider::maximumValue( int index ) sql += QString( " WHERE %1" ).arg( mSubsetString ); } - OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, "SQL" ); + OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" ); if ( l == 0 ) return QgsVectorDataProvider::maximumValue( index );