@@ -246,7 +246,7 @@ bool QgsOgrProvider::setSubsetString( QString theSQL, bool updateFeatureCount )
246
246
.arg ( quotedIdentifier ( OGR_FD_GetName ( OGR_L_GetLayerDefn ( ogrOrigLayer ) ) ) )
247
247
.arg ( mSubsetString );
248
248
QgsDebugMsg ( QString ( " SQL: %1" ).arg ( sql ) );
249
- ogrLayer = OGR_DS_ExecuteSQL ( ogrDataSource, mEncoding -> fromUnicode ( sql ). constData ( ), NULL , NULL );
249
+ ogrLayer = OGR_DS_ExecuteSQL ( ogrDataSource, TO8 ( sql ), NULL , NULL );
250
250
251
251
if ( !ogrLayer )
252
252
{
@@ -921,7 +921,7 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
921
921
continue ;
922
922
}
923
923
924
- OGRFieldDefnH fielddefn = OGR_Fld_Create ( mEncoding -> fromUnicode ( iter->name () ). data ( ), type );
924
+ OGRFieldDefnH fielddefn = OGR_Fld_Create ( TO8 ( iter->name () ), type );
925
925
OGR_Fld_SetWidth ( fielddefn, iter->length () );
926
926
OGR_Fld_SetPrecision ( fielddefn, iter->precision () );
927
927
@@ -1074,7 +1074,7 @@ bool QgsOgrProvider::createSpatialIndex()
1074
1074
1075
1075
QString sql = QString ( " CREATE SPATIAL INDEX ON %1" ).arg ( quotedIdentifier ( layerName ) ); // quote the layer name so spaces are handled
1076
1076
QgsDebugMsg ( QString ( " SQL: %1" ).arg ( sql ) );
1077
- OGR_DS_ExecuteSQL ( ogrDataSource, mEncoding -> fromUnicode ( sql ). data ( ), OGR_L_GetSpatialFilter ( ogrOrigLayer ), " " );
1077
+ OGR_DS_ExecuteSQL ( ogrDataSource, TO8 ( sql ), OGR_L_GetSpatialFilter ( ogrOrigLayer ), " " );
1078
1078
1079
1079
QFileInfo fi ( mFilePath ); // to get the base name
1080
1080
// find out, if the .qix file is there
@@ -1087,8 +1087,8 @@ bool QgsOgrProvider::createAttributeIndex( int field )
1087
1087
QString layerName = OGR_FD_GetName ( OGR_L_GetLayerDefn ( ogrOrigLayer ) );
1088
1088
QString dropSql = QString ( " DROP INDEX ON %1" ).arg ( quotedIdentifier ( layerName ) );
1089
1089
QString createSql = QString ( " CREATE INDEX ON %1 USING %2" ).arg ( quotedIdentifier ( layerName ) ).arg ( fields ()[field].name () );
1090
- OGR_DS_ExecuteSQL ( ogrDataSource, mEncoding -> fromUnicode ( dropSql ). data ( ), OGR_L_GetSpatialFilter ( ogrOrigLayer ), " SQL" );
1091
- OGR_DS_ExecuteSQL ( ogrDataSource, mEncoding -> fromUnicode ( createSql ). data ( ), OGR_L_GetSpatialFilter ( ogrOrigLayer ), " SQL" );
1090
+ OGR_DS_ExecuteSQL ( ogrDataSource, TO8 ( dropSql ), OGR_L_GetSpatialFilter ( ogrOrigLayer ), " SQL" );
1091
+ OGR_DS_ExecuteSQL ( ogrDataSource, TO8 ( createSql ), OGR_L_GetSpatialFilter ( ogrOrigLayer ), " SQL" );
1092
1092
1093
1093
QFileInfo fi ( mFilePath ); // to get the base name
1094
1094
// find out, if the .idm file is there
@@ -1118,7 +1118,7 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds & id )
1118
1118
1119
1119
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
1120
1120
QgsDebugMsg ( QString ( " SQL: %1" ).arg ( sql ) );
1121
- OGR_DS_ExecuteSQL ( ogrDataSource, mEncoding -> fromUnicode ( sql ). data ( ), NULL , NULL );
1121
+ OGR_DS_ExecuteSQL ( ogrDataSource, TO8 ( sql ), NULL , NULL );
1122
1122
1123
1123
recalculateFeatureCount ();
1124
1124
@@ -1747,7 +1747,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
1747
1747
if ( precision < 0 )
1748
1748
precision = 3 ;
1749
1749
1750
- field = OGR_Fld_Create ( codec-> fromUnicode ( it->first ). data ( ), OFTReal );
1750
+ field = OGR_Fld_Create ( TO8 ( it->first ), OFTReal );
1751
1751
OGR_Fld_SetWidth ( field, width );
1752
1752
OGR_Fld_SetPrecision ( field, precision );
1753
1753
}
@@ -1756,7 +1756,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
1756
1756
if ( width < 0 || width > 10 )
1757
1757
width = 10 ;
1758
1758
1759
- field = OGR_Fld_Create ( codec-> fromUnicode ( it->first ). data ( ), OFTInteger );
1759
+ field = OGR_Fld_Create ( TO8 ( it->first ), OFTInteger );
1760
1760
// limit to 10. otherwise OGR sets it to 11 and recognizes as OFTDouble later
1761
1761
OGR_Fld_SetWidth ( field, width );
1762
1762
}
@@ -1765,7 +1765,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
1765
1765
if ( width < 0 || width > 255 )
1766
1766
width = 255 ;
1767
1767
1768
- field = OGR_Fld_Create ( codec-> fromUnicode ( it->first ). data ( ), OFTString );
1768
+ field = OGR_Fld_Create ( TO8 ( it->first ), OFTString );
1769
1769
OGR_Fld_SetWidth ( field, width );
1770
1770
}
1771
1771
else
@@ -1880,10 +1880,10 @@ void QgsOgrProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, int
1880
1880
sql += QString ( " WHERE %1" ).arg ( mSubsetString );
1881
1881
}
1882
1882
1883
- sql += QString ( " ORDER BY %1" ).arg ( fld.name () );
1883
+ sql += QString ( " ORDER BY %1" ).arg ( quotedIdentifier ( fld.name () ) );
1884
1884
1885
1885
QgsDebugMsg ( QString ( " SQL: %1" ).arg ( sql ) );
1886
- OGRLayerH l = OGR_DS_ExecuteSQL ( ogrDataSource, mEncoding -> fromUnicode ( sql ). data ( ), NULL , " SQL" );
1886
+ OGRLayerH l = OGR_DS_ExecuteSQL ( ogrDataSource, TO8 ( sql ), NULL , " SQL" );
1887
1887
if ( l == 0 )
1888
1888
return QgsVectorDataProvider::uniqueValues ( index , uniqueValues, limit );
1889
1889
@@ -1914,7 +1914,7 @@ QVariant QgsOgrProvider::minimumValue( int index )
1914
1914
sql += QString ( " WHERE %1" ).arg ( mSubsetString );
1915
1915
}
1916
1916
1917
- OGRLayerH l = OGR_DS_ExecuteSQL ( ogrDataSource, mEncoding -> fromUnicode ( sql ). data ( ), NULL , " SQL" );
1917
+ OGRLayerH l = OGR_DS_ExecuteSQL ( ogrDataSource, TO8 ( sql ), NULL , " SQL" );
1918
1918
1919
1919
if ( l == 0 )
1920
1920
return QgsVectorDataProvider::minimumValue ( index );
@@ -1948,7 +1948,7 @@ QVariant QgsOgrProvider::maximumValue( int index )
1948
1948
sql += QString ( " WHERE %1" ).arg ( mSubsetString );
1949
1949
}
1950
1950
1951
- OGRLayerH l = OGR_DS_ExecuteSQL ( ogrDataSource, mEncoding -> fromUnicode ( sql ). data ( ), NULL , " SQL" );
1951
+ OGRLayerH l = OGR_DS_ExecuteSQL ( ogrDataSource, TO8 ( sql ), NULL , " SQL" );
1952
1952
if ( l == 0 )
1953
1953
return QgsVectorDataProvider::maximumValue ( index );
1954
1954
0 commit comments