Skip to content

Commit 908f2ee

Browse files
author
jef
committed
ogr provider: use utf8 also for SQL statements with GDAL 1.8
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15354 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9047416 commit 908f2ee

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/providers/ogr/qgsogrprovider.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ bool QgsOgrProvider::setSubsetString( QString theSQL, bool updateFeatureCount )
246246
.arg( quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) ) ) )
247247
.arg( mSubsetString );
248248
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 );
250250

251251
if ( !ogrLayer )
252252
{
@@ -921,7 +921,7 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
921921
continue;
922922
}
923923

924-
OGRFieldDefnH fielddefn = OGR_Fld_Create( mEncoding->fromUnicode( iter->name() ).data(), type );
924+
OGRFieldDefnH fielddefn = OGR_Fld_Create( TO8( iter->name() ), type );
925925
OGR_Fld_SetWidth( fielddefn, iter->length() );
926926
OGR_Fld_SetPrecision( fielddefn, iter->precision() );
927927

@@ -1074,7 +1074,7 @@ bool QgsOgrProvider::createSpatialIndex()
10741074

10751075
QString sql = QString( "CREATE SPATIAL INDEX ON %1" ).arg( quotedIdentifier( layerName ) ); // quote the layer name so spaces are handled
10761076
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 ), "" );
10781078

10791079
QFileInfo fi( mFilePath ); // to get the base name
10801080
//find out, if the .qix file is there
@@ -1087,8 +1087,8 @@ bool QgsOgrProvider::createAttributeIndex( int field )
10871087
QString layerName = OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) );
10881088
QString dropSql = QString( "DROP INDEX ON %1" ).arg( quotedIdentifier( layerName ) );
10891089
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" );
10921092

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

11191119
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
11201120
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 );
11221122

11231123
recalculateFeatureCount();
11241124

@@ -1747,7 +1747,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
17471747
if ( precision < 0 )
17481748
precision = 3;
17491749

1750-
field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTReal );
1750+
field = OGR_Fld_Create( TO8( it->first ), OFTReal );
17511751
OGR_Fld_SetWidth( field, width );
17521752
OGR_Fld_SetPrecision( field, precision );
17531753
}
@@ -1756,7 +1756,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
17561756
if ( width < 0 || width > 10 )
17571757
width = 10;
17581758

1759-
field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTInteger );
1759+
field = OGR_Fld_Create( TO8( it->first ), OFTInteger );
17601760
// limit to 10. otherwise OGR sets it to 11 and recognizes as OFTDouble later
17611761
OGR_Fld_SetWidth( field, width );
17621762
}
@@ -1765,7 +1765,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
17651765
if ( width < 0 || width > 255 )
17661766
width = 255;
17671767

1768-
field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTString );
1768+
field = OGR_Fld_Create( TO8( it->first ), OFTString );
17691769
OGR_Fld_SetWidth( field, width );
17701770
}
17711771
else
@@ -1880,10 +1880,10 @@ void QgsOgrProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, int
18801880
sql += QString( " WHERE %1" ).arg( mSubsetString );
18811881
}
18821882

1883-
sql += QString( " ORDER BY %1" ).arg( fld.name() );
1883+
sql += QString( " ORDER BY %1" ).arg( quotedIdentifier( fld.name() ) );
18841884

18851885
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" );
18871887
if ( l == 0 )
18881888
return QgsVectorDataProvider::uniqueValues( index, uniqueValues, limit );
18891889

@@ -1914,7 +1914,7 @@ QVariant QgsOgrProvider::minimumValue( int index )
19141914
sql += QString( " WHERE %1" ).arg( mSubsetString );
19151915
}
19161916

1917-
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, "SQL" );
1917+
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" );
19181918

19191919
if ( l == 0 )
19201920
return QgsVectorDataProvider::minimumValue( index );
@@ -1948,7 +1948,7 @@ QVariant QgsOgrProvider::maximumValue( int index )
19481948
sql += QString( " WHERE %1" ).arg( mSubsetString );
19491949
}
19501950

1951-
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, "SQL" );
1951+
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" );
19521952
if ( l == 0 )
19531953
return QgsVectorDataProvider::maximumValue( index );
19541954

0 commit comments

Comments
 (0)