Skip to content

Commit f04c40c

Browse files
committedMar 10, 2015
postgres provider: also cast field expressions to text (fixes #12346)
(cherry picked from commit 1acad42f48dcf7ce31512356c8dd609292f22899)
1 parent e94ebd7 commit f04c40c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed
 

‎src/providers/postgres/qgspostgresconn.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,15 +1183,15 @@ QString QgsPostgresConn::fieldExpression( const QgsField &fld, QString expr )
11831183
expr = expr.arg( quotedIdentifier( fld.name() ) );
11841184
if ( type == "money" )
11851185
{
1186-
return QString( "cash_out(%1)" ).arg( expr );
1186+
return QString( "cash_out(%1)::text" ).arg( expr );
11871187
}
11881188
else if ( type.startsWith( "_" ) )
11891189
{
1190-
return QString( "array_out(%1)" ).arg( expr );
1190+
return QString( "array_out(%1)::text" ).arg( expr );
11911191
}
11921192
else if ( type == "bool" )
11931193
{
1194-
return QString( "boolout(%1)" ).arg( expr );
1194+
return QString( "boolout(%1)::text" ).arg( expr );
11951195
}
11961196
else if ( type == "geometry" )
11971197
{

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,8 +1270,7 @@ void QgsPostgresProvider::uniqueValues( int index, QList<QVariant> &uniqueValues
12701270
sql += QString( " WHERE %1" ).arg( mSqlWhereClause );
12711271
}
12721272

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

12761275
if ( limit >= 0 )
12771276
{

0 commit comments

Comments
 (0)
Please sign in to comment.