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
Quick and dirty patch to DB-Manager after PR 8831 #9086
Quick and dirty patch to DB-Manager after PR 8831 #9086
Conversation
The "comments" PR 8831 added support for postgres only (and broke all the others backends). I'd be in favor of a revert of the whole original PR but this patch restores functionality and could be an acceptable temporary fix until the comments PR is reworked in a more maintainable and elegant way. Fixes qgis#21151 btw
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.
IMHO a better and wider solution would be in charge of the patched PR 8831.
Is it necessary to add need-docs because of QMessageBoxes @elpaso ?
Are there more things that you would like to have fixed on the original PR? |
@m-kuhn the architecture is plain wrong: the back-end specific part should go into the plugins.py of the various back-ends instead of the parent class, we now have a bunch of PG specific SQL in the parent class which is not specific to PG. The GUI also needs some refactoring: it makes no sense to have post-mortem messages when after the user tried to set a comment on a back-end that do not supports (or worse do not implement) them, the GUI should hide the comments part completely if not supported/implemented. Btw, I think that with this PR at least we don't get tracebacks anymore ---> ( if I manage to fix the pep8 thing, that my commit hooks insist to rewrite in a way that travis do not like: do we need a particular version of autopep8?). |
agreed, is there more than the thing you put into the try-block?
Hmmm... don't know, I'm sorry. |
@m-kuhn the try-block works but it's just a "patch", I don't like it, but in the paid-bugfixing context I don't feel it's fair to spend QGIS money on a deeper refactoring (but I might be wrong on this). |
I was just trying to see the scope. @Ailurupoda could you have a look at moving all the postgres specific sql (i.e. https://github.com/qgis/QGIS/pull/8831/files#diff-95efee568b4d3a74493ad92c3e99b065R1098 and https://github.com/qgis/QGIS/pull/8831/files#diff-1e7be63b28c39937475e92fce50a24aeR59 into the postgres plugin? |
Oh sorry, i can see the mistake :/ |
Is there no access to |
I don't know. But i'm not sure to understand how this would help. The setField() method is on the dlg_field_properties.py file. Not sure on how to make this function inherit on the side of postgis. |
Via |
@Ailurupoda do you have an idea when you'll have time to work on this? A rough idea will be good to decide on the next steps on this PR and your original PR. |
I'm working on it, i think i managed to fix this. I've moved to connector and plugin files and it works using postgis. I didn't test with spatialite or oracle, i've no base to test. I'm working on the commit. By the way, where should i modify and commit ? |
Nice! |
@Ailurupoda thanks! Please don't forget the GUI changes to the two dialogs where comments are set/deleted and listed. |
Sorry, i don't understand ? :/ |
@Ailurupoda if a backend does not support comments you must hide all comments related elements from the dialogs. |
So it must have multiple dialogs running where some get comment some does not ? For the moment i have dialogs where comment are editable, but for exemple for the GPKG, there is no error, but the comment won't be added |
That's up to you (if implement a single dialog and hide fields or implement multiple dialogs) And yes, there are ways to hide fields and columns (or better: to not add them at all)
This is IMO not a good design: if comments are not supported they must not be shown. |
I agree with you, but the fact is i don't know how to not show them .. I'll try on this ! |
That's often the easiest
|
I'm merging this small patch while we are waiting for the real solution |
try: | ||
#Using the db connector, executing de SQL query Comment on table | ||
self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\';'.format(self.table.schema().name, self.table.name, self.viewComment.text())) | ||
except DbError as e: | ||
DlgDbError.showError(e, self) | ||
return | ||
except Exception as e: |
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.
@elpaso is there any chance to avoid the catch all exception? I think even for quick and dirty patches this should be avoided.
The "comments" PR #8831 added support for postgres only
(and broke all the others backends).
I'd be in favor of a revert of the whole original PR but
this patch restores functionality and could be an acceptable
temporary fix until the comments PR is reworked in a more
maintainable and elegant way.
Fixes #21151