Skip to content

Add cursor.description type codes - #852

Open
rnovatorov wants to merge 3 commits into
crate:mainfrom
rnovatorov:raw-int-type-codes
Open

rnovatorov wants to merge 3 commits into
crate:mainfrom
rnovatorov:raw-int-type-codes

Conversation

@rnovatorov

Copy link
Copy Markdown

Populate cursor.description type codes with raw wire values.

Summary of the changes / Why this is an improvement

CrateDB reports the type of every result column in col_types, but Cursor.description always reported None for the type code, forcing consumers to read the private cursor._result.

Pass the wire value through unchanged: an integer for scalar columns, a nested list for arrays, None when col_types is absent, null, or short. Unknown identifiers pass through rather than raise.

Checklist

CrateDB reports the type of every result column in `col_types`, but
`Cursor.description` always reported `None` for the type code, forcing
consumers to read the private `cursor._result`.

Pass the wire value through unchanged: an integer for scalar columns, a
nested list for arrays, `None` when `col_types` is absent, null, or
short. Unknown identifiers pass through rather than raise.

Fixes crate#837
@mergify

mergify Bot commented Nov 23, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@seut seut left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, thanks!

@bgunebakan
bgunebakan self-requested a review November 24, 2026 10:16

@bgunebakan bgunebakan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @rnovatorov,
Thank you for your contribution! I've added some comments.

Comment thread src/crate/client/cursor.py Resolved
Comment thread tests/client/test_cursor.py Resolved
Comment thread tests/client/test_cursor.py Resolved

@rnovatorov rnovatorov left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @bgunebakan, thank you for the review. I didn't know type codes must be hashable - the pep doesn't mention it. If the recursive list->tuple conversion cuts this - I'll fix and test it.

Comment thread src/crate/client/cursor.py Resolved
Comment thread tests/client/test_cursor.py Resolved

@rnovatorov rnovatorov left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @bgunebakan, I think I've fixed the issues, would you mind taking a look?

Comment thread src/crate/client/cursor.py Resolved
Comment thread tests/client/test_cursor.py Resolved
Comment thread tests/client/test_cursor.py Resolved

@bgunebakan bgunebakan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for your contribution. One of the job is failing in the pipeline but it's because of the flaky test, looks like it's not related with PR changes.

@rnovatorov

Copy link
Copy Markdown
Author

@bgunebakan, @seut, thank you for the review.

I've resolved the comments as I believe the mentioned issues are now fixed. Feel free to reopen if needed.

How do you guys handle flaky tests? I'd allow the test to fail on v3.10 and create an issue to track it. This way we can merge the PR and call it a day. On the other hand 5 failures in a row on a single Python version and no failures before the PR is suspicious, so further research might be necessary.

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.

cursor.description's type_code is always None, even though col_types is already available internally

3 participants