Skip to content

Commit 660e451

Browse files
committedJun 10, 2019
More tests for json values, fix boolean representation
1 parent 114affc commit 660e451

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed
 

‎src/providers/postgres/qgspostgresconn.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,6 @@ QString QgsPostgresConn::quotedJsonValue( const QVariant &value )
10631063
{
10641064
if ( value.isNull() || !value.isValid() )
10651065
return QStringLiteral( "null" );
1066-
if ( value.type() == QVariant::Bool )
1067-
return value.toBool() ? QStringLiteral( "true" ) : QStringLiteral( "false" );
10681066
const auto j { QgsJsonUtils::jsonFromVariant( value ) };
10691067
return quotedString( QString::fromStdString( j.dump() ) );
10701068
}

‎src/providers/postgres/qgspostgresconn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ class QgsPostgresConn : public QObject
285285

286286
/**
287287
* Quote a json(b) value for placement in a SQL string.
288+
* \note a null value will be represented as a NULL and not as a json null.
288289
*/
289290
static QString quotedJsonValue( const QVariant &value );
290291

‎tests/src/python/test_provider_postgres.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,11 @@ def testJson(self):
619619

620620
attrs = (
621621
123,
622-
None,
623-
"String l'iteral with \"quotes\" and other funny chars ;#/",
624622
1233.45,
623+
None,
624+
True,
625+
False,
626+
r"String literal with \"quotes\" 'and' other funny chars []{};#/èé*",
625627
[1, 2, 3.4, None],
626628
[True, False],
627629
{'a': 123, 'b': 123.34, 'c': 'a string', 'd': [1, 2, 3], 'e': {'a': 123, 'b': 123.45}}

0 commit comments

Comments
 (0)
Please sign in to comment.