Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
postgres provider: also cast field expressions to text (fixes #12346)
(cherry picked from commit 1acad42f48dcf7ce31512356c8dd609292f22899)
  • Loading branch information
jef-n committed Mar 10, 2015
1 parent e94ebd7 commit f04c40c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/providers/postgres/qgspostgresconn.cpp
Expand Up @@ -1183,15 +1183,15 @@ QString QgsPostgresConn::fieldExpression( const QgsField &fld, QString expr )
expr = expr.arg( quotedIdentifier( fld.name() ) );
if ( type == "money" )
{
return QString( "cash_out(%1)" ).arg( expr );
return QString( "cash_out(%1)::text" ).arg( expr );
}
else if ( type.startsWith( "_" ) )
{
return QString( "array_out(%1)" ).arg( expr );
return QString( "array_out(%1)::text" ).arg( expr );
}
else if ( type == "bool" )
{
return QString( "boolout(%1)" ).arg( expr );
return QString( "boolout(%1)::text" ).arg( expr );
}
else if ( type == "geometry" )
{
Expand Down
3 changes: 1 addition & 2 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -1270,8 +1270,7 @@ void QgsPostgresProvider::uniqueValues( int index, QList<QVariant> &uniqueValues
sql += QString( " WHERE %1" ).arg( mSqlWhereClause );
}

sql += QString( " ORDER BY %1" )
.arg( quotedIdentifier( fld.name() ) );
sql += QString( " ORDER BY %1" ).arg( connectionRO()->fieldExpression( fld ) );

if ( limit >= 0 )
{
Expand Down

0 comments on commit f04c40c

Please sign in to comment.