-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Allows editing of postgres JSON fields from Text Edit Widget #30758
Conversation
Should pass now. Never quite sure if I should squash commits or not.. |
75bbce7
to
35519e7
Compare
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
Would be great to see this merged as it fixes minimum 2 bugs and possibly more. Anything else I can do to get it merged? |
I cannot decide about the text edit widget implementation at the moment, but the fix avoiding QGIS from crash on storing to Postgres ( If there is no agreement to merge it, it would be great, when you could separate this fix from the implementation in the text widget. |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
Hi @signedav what aspects do you think changing / review? The concept as a whole, or a specific aspect of the implementation? |
Would very much like to see it land in 3.10 :) |
Sorry for not replying earlier @stev-0 I like the approach. The implementation in the text edit widget looks IMO good. What I am uncertain is, if there is any danger by converting the data in case of type is Btw. it would be nice to have tests for the widget itself. To read and write the text from and to a JSON field. And maybe you can test it with Geopackage JSON fields as well (not only Postgres) to be sure. The part with the JSON value assignement is partly merged already with this: #31264 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Steve
Thanks a lot for your effort. I'm looking forward to merge this nice feature soon. But I found some issues.
First, on creating a new feature with geometry the warning message appears:
It's because it receives somewhere an empty string as value, what is not valid JSON. I didn't dig deeper there. Let me know if you need help.
Then there is something else:
- enter the widget with existing text in it
- select all and delete all (with the keyboard DEL)
- the widget is now empty, I cannot enter anything anymore
Can you reproduce that?
And then I found a minor thing in the warning message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we have the behavior we want at the moment.
Since we do accept empty strings we don't get the warning message on the initialization.
But in every other case an empty string is accepted as valid JSON. And do we want that?
Shouldn't this NULL
and ""
be accepted but `` not?
If we don't accept the empty strings, we have to avoid the message on creating a feature with geometry otherwise...
I checked it again. It's like this:
Fair enough for Postgres (haven't checked Geopackage). But now the confusing part:
I suggest to display always the quotation marks on single strings. And on empty string we can decide if we want:
While I think the second one would be much user friendlier. |
And when I add a feature on the canvas with geometry, enter a invalid JSON and store it, it's not stored and there is no warning message appearing. That's not nice. Sorry for coming back again and again, but it would be great to have a nice and solid feature here 🙂 |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
Not stale. Fingers crossed for this to land in 3.12 |
for json features
I think I have incorporated the main points from @signedav, which were definitely valid and well worth raising. The behaviour now is that primitive / raw JSON strings from the database are quoted in the widget, and only quoted strings are accepted backbas input. Blank strings "" are converted to blank JSON strings I think there are few other things that could be addressed in this, PR, but happy for it to go as it is, following review. In order of importance (I think):
|
And localise changes to texteditwrapper
@signedav this now passes and is good for a review now, which I hope covers everything! |
Thanks @stev-0 I will review it in around week. I'm currently in vacation without good connection... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the code and it looks good. Made some tests as well.
It would be really nice to have this for GPKG JSON as well in future. But since it's there just the status quo I can approve this PR.
Thanks @stev-0 for this nice work.
Great, thanks @signedav |
Will it make it to 3.12? |
Fixes #29361
Description
This allows JSON to be entered in text format as well as with the Key/Value widget. I would value a review on the changes to qgspostgresconn.cpp as that was the only way I could prevent a JSON object becoming a JSON array. Also whether we should be checking for a generic QVariantMap as currently or narrow it down to JSON. Perhaps this might cause problems with some other providers?
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and contain sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit