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

gh-100450: Add sqlite.Row.__contains__ method #100457

Closed
wants to merge 4 commits into from

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Dec 23, 2022

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

I left some nitpicks. Also, please add tests.

static int
pysqlite_row_contains(pysqlite_Row* self, PyObject *arg)
{
Py_ssize_t nitems, i;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use intermingled declarations :)

for (i = 0; cmp == 0 && i < nitems; i++) {
cmp = PyObject_RichCompareBool(
arg,
PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a lot happening on this line. I'd prefer it if you extracted these items before calling PyObject_RichCompareBool, for improved readability.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@pochmann
Copy link
Contributor

@erlend-aasland Hmm, is this whole thing not wrong anyway? (See my comment in the issue thread.)

@sobolevn
Copy link
Member Author

@erlend-aasland

Also, please add tests.

I've added two doctests, aren't they enough?
If not, I don't know what is the best place for these tests. I can make new file for Row tests 🤔

@erlend-aasland
Copy link
Contributor

I've added two doctests, aren't they enough? If not, I don't know what is the best place for these tests.

The doctests are there to make sure the examples in the docs actually work; it is not the place for unit tests. The unit tests (and regression tests, functional tests, etc.) all live in Lib/test/test_sqlite3. Their purpose is to test the _sqlite extension module (and the sqlite3 module) in all possible ways; we aim for as high code coverage as possible.

If I want to check the code coverage of the _sqlite C code, I can do so easily with a couple of compiler/linker flags, running ./python.exe -m test test_sqlite3, and generate a report.

Also, I'm not sure the buildbots run doctests; IIRC, they only run the test suite, but I might be wrong about this.

@sobolevn
Copy link
Member Author

Sure, @erlend-aasland, I've added a unit test :)

@erlend-aasland
Copy link
Contributor

Sure, @erlend-aasland, I've added a unit test :)

Thanks! BTW; I haven't decided if this is a good thing to add, or not. But lets keep that conversation on the issue. I'm going to mark this with do-not-merge until the discussion has landed.

@vsajip
Copy link
Member

vsajip commented Dec 24, 2022

I haven't decided if this is a good thing to add

Should we open this to wider discussion on Discourse/Core development?

@erlend-aasland
Copy link
Contributor

Yeah, IMO it is worth it trying to gather more feedback on Discourse.

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

Successfully merging this pull request may close these issues.

5 participants