Skip to content

Commit

Permalink
postgres provider: also cast field expressions to text (fixes #12346)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Mar 10, 2015
1 parent a0a5822 commit 306a53b
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -1315,8 +1315,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 306a53b

Please sign in to comment.