Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix json hanlding of bools and complete json(b) PG support #30137

Merged
merged 8 commits into from Jun 10, 2019

Conversation

elpaso
Copy link
Contributor

@elpaso elpaso commented Jun 8, 2019

Fixes #30131 and add tests for jsonutils

@elpaso elpaso added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jun 8, 2019
@m-kuhn
Copy link
Member

m-kuhn commented Jun 9, 2019

Looks good

@elpaso
Copy link
Contributor Author

elpaso commented Jun 9, 2019

@m-kuhn thanks for the review!

src/core/qgsjsonutils.h Outdated Show resolved Hide resolved
Co-Authored-By: Matthias Kuhn <matthias@opengis.ch>
src/providers/postgres/qgspostgresconn.cpp Outdated Show resolved Hide resolved
@@ -1057,6 +1059,16 @@ QString QgsPostgresConn::quotedValue( const QVariant &value )
}
}

QString QgsPostgresConn::quotedJsonValue( const QVariant &value )
{
if ( value.isNull() || !value.isValid() )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( value.isNull() || !value.isValid() )
if ( value.isNull() || !value.isValid() || value.type() == QVariant::Bool )
return QgsPostgresConn::quotedValue( value );

(for consistency)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few more tests, null, true and false should be handled correctly now.

src/core/qgsjsonutils.h Outdated Show resolved Hide resolved
Co-Authored-By: Matthias Kuhn <matthias@opengis.ch>
@elpaso elpaso merged commit 13099cc into qgis:master Jun 10, 2019
@elpaso elpaso deleted the bugfix-gh30131-postgres-json branch June 10, 2019 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saving edits to a layer with JSON field throws an error
3 participants