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
PostgreSQL provider don't cast bigint PKs to text #35162
Conversation
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.
It looks generally good to me, thanks.
I can imagine that adding tests for what's sent to the db is hard to do, so I'm good with sticking to functional tests and trusting your performance tests (and hoping no regressions are introduced for the latter).
LGTM, the test coverage on PG is pretty good, so I guess that if the tests are passing we should not expect regressions. |
Travis is still choking on formatting, it is as if it hasn't seen ad8f89b . Locally running |
See https://github.com/qgis/QGIS/blob/master/.github/CONTRIBUTING.md#contributing-to-qgis for some hints how to get your code formatted automatically |
I've ran prepare-commit.sh before pushing the C++ code, but I think I missed it when adding the test code, thanks. What can I do about the failed qgis_sip_uptodate test? It passes when I run locally with |
This is the full output of my local ctest -v -R qgis_sip_uptodate (which fails on Travis):
|
You need to run it before committing (it will only work on uncommitted files to save some time). |
Only testdata/untracked files. After running it, git status gives:
|
Ah wait, that remaining thing seems to be something that changed on master meanwhile. The test has a weird behavior with respect to comparing "master merged into pr" with plain "pr".
|
4a0db47
to
b24798d
Compare
Done. Let's see how Travis likes this, thank you for the tip. |
Travis failed the same test... |
I've done a make clean and re-ran ./scripts/sipify_all.sh, which made the change in commit 6767395; this is what I just pushed. |
Now another test failed on Travis, but passed locally: PyQgsPostgresRasterProvider. I've got no idea why. |
6767395
to
36b7be5
Compare
Did nothing this time, just fetched upstream/master, rebased against it, and pushed -f, according to @m-kuhn instructions. The previous failing test in Travis still passes locally (PyQgsPostgresRasterProvider). |
If you really want to test this fully (and I would strongly suggest you do), then you need to implement the ProviderTestCase in a class which uses a bigint primary key. Checkout TestPyQgsPostgresProviderCompoundKey in test_provider_postgres.py for a template on how to do this |
Hi, don't you think that the methods testPktUpdateBigintPk and testPktUpdateBigintPkNonFirst that I wrote in 0853029 are enough? Those exercise loading and saving features with bigint PKs, for a table with an ordinary bigint pk and another table whose PK is not the first one defined. |
Depends how confident you want to be. If you implement the ProviderTestCase then you can 100% sleep at night knowing you're covered in all existing conceivable situations, and will also be automatically covered whenever new functionality is added to the providers... |
(just to clarify: the provider test class is a mega stress test. It throws thousands of edge cases at the provider to make sure they handle them correctly). |
Thanks for the pointer, and for enlightening me as always, I'm working on it. Just subclassing the ProviderTestCase and adjusting the data source? Is there any requirements for the data source (geometry type for example)? Also, is there a need for one subclass for each kind of table (that is, with a single ordinary PK, with a PK which is not defined as the first field, with a composite PK in which at least one member is a bigint...)? Sorry for the torrent of questions, but you provoked it :D |
I still cannot figure out why the test PyQgsPostgresRasterProvider fails on Travis but not on my own system (PostgreSQL 12 + postgisraster 3.0), neither on Azure. |
It's unrelated -- it fails randomly regardless of the PR |
Yes - look at how "someDataCompound" is loaded in tests/testdata/provider/testdata_pg.sql. You need to load in the same reference data rows (but with the different primary key type). Everything from the "pk" field onward needs to stay the same. If you want to also run the editing reference tests then you need to implement
If they aren't already covered, then yes -- this would be very valuable! It's probably the biggest (only?) remaining gap in the test coverage of postgres provider. |
I hoped it was fixed. Is it still flacky? |
@elpaso a rebase should fix this, but now the azure build is bjorked. |
Create a ProviderTestCase subclass, TestPyQgsPostgresProviderBigintSinglePk, with the editing reference tests. The methods which differ from the upper FeatureSourceTestCase class are rewritten and marked with TODO annotations to highlight the provider deficiencies.
7ba1a03
to
d4672b0
Compare
I've added a FeatureSourceTestCase subclass to the test cases, as instructed by @nyalldawson , with the getSource/getEditableLayer implemented. That's why it took so long, and it was good too, because I caught an omission that I corrected in my last "real" commit ( 742454b ). I've noted on the method overrides (with TODO annotations) where the code diverges from the original classes, and why, in order to correct those issues in the future. All those tests pass locally, on my machine, with PostgreSQL version 12.1 and LANG=en_US.UTF-8. Is this mergeable? |
I think @nyalldawson should take a look at the Python test ( d4672b0 ). Also, this should be backportable to 3.12 and 3.10 without issues. The github interface doesn't allow me to add @nyalldawson to the list of reviewers. @m-kuhn , can you do that? Thank you very much. |
@espinafre we don't usually assign anything to anyone, unless we know for sure that the developer agreed. |
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.
It looks good to me as far as I can tell. It's not trivial to understand each change (but that's in the nature of this code, not related to your work), so I'll trust the tests and general good look.
Some minor code style requests and we are good to ship it in my opinion.
I would like to wait for one or two months with a backport to LTR to have some time for any eventual regression to be sorted out first.
@elpaso I've said "assigned to me" in jest, along the lines of "the teacher assigned homework to the students" :) |
@m-kuhn Does the MXE build failure prevent the merge? |
NoOn Apr 17, 2020 20:15, "José de Paula Rodrigues N. Assis" <notifications@github.com> wrote:
@m-kuhn Does the MXE build failure prevent the merge?
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
|
Thanks @espinafre nice work! |
@espinafre don't worry about MXE, the whole service seems to be having issues today. |
This PR is instead of botched #34780 (because of my mistakes with git merging/rebasing); please see the whole discussion there. In addition, a test case for updating tables with positive, zero, negative PKs; I couldn't find a way to test if the queries are being sent to the PostgreSQL backend as designed from within the testing framework. @elpaso , @m-kuhn , is this mergeable? I'm hoping to backport this in time for the next 3.10 and 3.12 point releases.
Fixes #34077
Partially fixes #34264