This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年12月11日 21:45 by xapple, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| sqlrowslice.patch | xapple, 2011年12月11日 21:45 | Patch for implementing slices in sqlite3.Row | review | |
| issue13583.patch | jesstess, 2014年04月28日 06:03 | review | ||
| sqlite3_slicing_demo.py | jesstess, 2014年04月28日 06:04 | |||
| sqlite3_row_slice.patch | serhiy.storchaka, 2015年03月07日 17:33 | review | ||
| Messages (9) | |||
|---|---|---|---|
| msg149251 - (view) | Author: Lucas Sinclair (xapple) | Date: 2011年12月11日 21:45 | |
When using the sqlite3.Row object as a row factory, one can access the resulting rows by index (such as row[1]) or by name (such as row['b']). However, the slice functionality is lost, as doing row[0:2] raises the error: "slices not implemented, yet" Here is a patch that fixes this, I implemented it and I added the corresponding unit test. |
|||
| msg149871 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年12月19日 15:17 | |
Thanks for the patch. Two things: - there is a compilation warning using gcc: /home/antoine/cpython/default/Modules/_sqlite/row.c: In function ‘pysqlite_row_subscript’: /home/antoine/cpython/default/Modules/_sqlite/row.c:128:26: attention : passing argument 1 of ‘PySlice_GetIndicesEx’ from incompatible pointer type - you can use assertEqual to avoid defining the error message yourself |
|||
| msg217343 - (view) | Author: Jessica McKellar (jesstess) * (Python triager) | Date: 2014年04月28日 06:03 | |
Thanks for the ticket and patch, xapple! I updated the patch to address the compiler warning and use assertEqual. While testing, I noticed that slicing with steps wasn't supported, so I expanded the sqlite3.Row slicing code to support steps, and added some additional tests. The slicing code in Modules/_sqlite/row.c:pysqlite_row_subscript is unfortunately pretty redundant with the slicing code in Objects/tupleobject.c. It'd be better to either be able to factor the code from both into a function (but I couldn't see how to do this without making it part of the public API), or have tuple, sqlite.Row, etc. implement a shared slicing interface. Perhaps we should defer that decision to a future ticket, though. Note that even after this patch, sqlite.Row instances don't support negative indices. * This patch passes `make patchcheck`. * The full test suite passes with this patch. * There are no build warnings related to the patch. |
|||
| msg217344 - (view) | Author: Jessica McKellar (jesstess) * (Python triager) | Date: 2014年04月28日 06:04 | |
I've also uploaded a short script that sets up an in-memory sqlite database that fetches Rows, for easy manual testing. |
|||
| msg233840 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年01月11日 08:12 | |
May be just use PyObject_GetItem(self->data, idx)? |
|||
| msg237462 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年03月07日 17:33 | |
Here is a patch with much simpler implementation. |
|||
| msg239172 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年03月24日 20:01 | |
Could you look at the patch Gerhard? |
|||
| msg239680 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年03月31日 10:34 | |
New changeset e47f520eb756 by Serhiy Storchaka in branch 'default': Issue #13583: sqlite3.Row now supports slice indexing. https://hg.python.org/cpython/rev/e47f520eb756 |
|||
| msg239681 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年03月31日 10:36 | |
The implementation can be much simpler, but in any case thank you for your patches Lucas and Jessica. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:24 | admin | set | github: 57792 |
| 2015年03月31日 10:36:54 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: + msg239681 stage: patch review -> resolved |
| 2015年03月31日 10:34:18 | python-dev | set | nosy:
+ python-dev messages: + msg239680 |
| 2015年03月31日 10:25:01 | serhiy.storchaka | set | assignee: ghaering -> serhiy.storchaka |
| 2015年03月24日 20:01:26 | serhiy.storchaka | set | messages: + msg239172 |
| 2015年03月07日 17:33:56 | serhiy.storchaka | set | files:
+ sqlite3_row_slice.patch messages: + msg237462 components: + Extension Modules |
| 2015年01月11日 08:12:51 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg233840 |
| 2015年01月11日 02:01:02 | ghaering | set | assignee: ghaering |
| 2014年04月28日 06:04:55 | jesstess | set | files:
+ sqlite3_slicing_demo.py messages: + msg217344 |
| 2014年04月28日 06:03:24 | jesstess | set | files:
+ issue13583.patch versions: + Python 3.5, - Python 3.3 nosy: + jesstess messages: + msg217343 keywords: + needs review |
| 2011年12月19日 15:17:40 | pitrou | set | versions:
- Python 2.7, Python 3.2 nosy: + pitrou messages: + msg149871 stage: patch review |
| 2011年12月16日 23:55:54 | terry.reedy | set | nosy:
+ ghaering versions: - Python 2.6 |
| 2011年12月11日 21:45:47 | xapple | create | |