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

Quick and dirty patch to DB-Manager after PR 8831 #9086

Merged

Conversation

elpaso
Copy link
Contributor

@elpaso elpaso commented Feb 4, 2019

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

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
@elpaso elpaso added the Bugfix label Feb 4, 2019
@elpaso elpaso added this to the 3.6.0 milestone Feb 4, 2019
Copy link
Contributor

@luipir luipir left a 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 ?

@m-kuhn
Copy link
Member

m-kuhn commented Feb 5, 2019

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.

Are there more things that you would like to have fixed on the original PR?

@elpaso
Copy link
Contributor Author

elpaso commented Feb 5, 2019

@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?).

@m-kuhn
Copy link
Member

m-kuhn commented Feb 5, 2019

@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.

agreed, is there more than the thing you put into the try-block?

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?).

Hmmm... don't know, I'm sorry.

@elpaso
Copy link
Contributor Author

elpaso commented Feb 5, 2019

@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).

@m-kuhn
Copy link
Member

m-kuhn commented Feb 5, 2019

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?

@Ailurupoda
Copy link
Contributor

Oh sorry, i can see the mistake :/
I will take a look to see how that can be change.
For the getComment function it won't be a problem to move, but for what is inside setField i'm not sure on how that can be moved.
I'll try to watch for that

@m-kuhn
Copy link
Member

m-kuhn commented Feb 5, 2019

Is there no access to plugin.py via self.db?

@Ailurupoda
Copy link
Contributor

Is there no access to plugin.py via self.db?

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.

@m-kuhn
Copy link
Member

m-kuhn commented Feb 5, 2019

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 self.db.connector it should be possible to call any method in db_manager/db_plugins/postgis/connector.py (and of the inherited db_manager/db_plugins/connector.py) from setFields().

@m-kuhn
Copy link
Member

m-kuhn commented Feb 5, 2019

@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.

@Ailurupoda
Copy link
Contributor

Ailurupoda commented Feb 5, 2019

@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 ?

@m-kuhn
Copy link
Member

m-kuhn commented Feb 5, 2019

Nice!
Geopackage and Spatialite should be very easy to test since they are file based formats. Just test any of the gpkg files in here https://github.com/qgis/QGIS/tree/master/tests/testdata

@elpaso
Copy link
Contributor Author

elpaso commented Feb 5, 2019

@Ailurupoda thanks! Please don't forget the GUI changes to the two dialogs where comments are set/deleted and listed.

@Ailurupoda
Copy link
Contributor

@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 ? :/
What changes should i not forget ?

@elpaso
Copy link
Contributor Author

elpaso commented Feb 5, 2019

@Ailurupoda if a backend does not support comments you must hide all comments related elements from the dialogs.

@Ailurupoda
Copy link
Contributor

So it must have multiple dialogs running where some get comment some does not ?
Or is there a way to hide somehow some field ?

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

@elpaso
Copy link
Contributor Author

elpaso commented Feb 5, 2019

So it must have multiple dialogs running where some get comment some does not ?
Or is there a way to hide somehow some field ?

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)

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

This is IMO not a good design: if comments are not supported they must not be shown.

@Ailurupoda
Copy link
Contributor

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 !

@m-kuhn
Copy link
Member

m-kuhn commented Feb 5, 2019

That's often the easiest

widget.setVisible(False)

@elpaso
Copy link
Contributor Author

elpaso commented Feb 6, 2019

I'm merging this small patch while we are waiting for the real solution

@elpaso elpaso merged commit e4df72e into qgis:master Feb 6, 2019
@elpaso elpaso deleted the bugfix-21151-db-manager-comments-armageddon branch February 6, 2019 06:46
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:
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants