Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-118221: Always use the default row factory in sqlite3.iterdump()#118223
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
The iterdump() implementation depends on the row factory returningresulting rows as tuples; it will fail with custom row factories likefor example a dict factory.Fixed by overriding the row factory of the cursor used by iterdump().FTR, this does not affect the row factory of the parent connection.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -190,6 +190,21 @@ def __getitem__(self, index): | ||
| got = list(self.cx.iterdump()) | ||
| self.assertEqual(expected, got) | ||
| def test_dump_custom_row_factory(self): | ||
| # gh-118221: iterdump should be able to cope with custom row factories | ||
erlend-aasland marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| def dict_factory(cu, row): | ||
| fields = [col[0] for col in cu.description] | ||
| return {k: v for k, v in zip(fields, row)} | ||
erlend-aasland marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| self.cx.row_factory = dict_factory | ||
| CREATE_TABLE = "CREATE TABLE test(t);" | ||
| expected = ["BEGIN TRANSACTION;", CREATE_TABLE, "COMMIT;"] | ||
| self.cu.execute(CREATE_TABLE) | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| actual = list(self.cx.iterdump()) | ||
| self.assertEqual(expected, actual) | ||
| self.assertEqual(self.cx.row_factory, dict_factory) | ||
| def test_dump_virtual_tables(self): | ||
| # gh-64662 | ||
| expected = [ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix a bug where:func:`sqlite3.iterdump` could fail if a custom:attr:`row | ||
| factory <sqlite3.Cursor.row_factory>` was supplied. Patch by Erlend Aasland. | ||
erlend-aasland marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||