Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

simple_* methods handle None incorrectly for key values #14157

Open
clokep opened this issue Oct 12, 2022 · 0 comments
Open

simple_* methods handle None incorrectly for key values #14157

clokep opened this issue Oct 12, 2022 · 0 comments
Labels
A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@clokep
Copy link
Member

clokep commented Oct 12, 2022

Generally the simple_* methods do not handle None properly when used as a key-value (the exact arguments differ by method). See #14138 for real fallout from this.

simple_upsert_emulated_txn has special handling for null which should likely be abstracted:

def _getwhere(key: str) -> str:
# If the value we're passing in is None (aka NULL), we need to use
# IS, not =, as NULL = NULL equals NULL (False).
if keyvalues[key] is None:
return "%s IS ?" % (key,)
else:
return "%s = ?" % (key,)

This is mostly a footgun that we could avoid by either:

  1. Raising an exception (or asserting) when a key-value is None.
  2. Automatically handling None and turning it into IS NONE (which is what simple_upsert_emulated_txn does).
@clokep clokep added S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Oct 12, 2022
@MadLittleMods MadLittleMods added the A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db label Oct 12, 2022
@DMRobertson DMRobertson added good first issue Good for newcomers and removed good first issue Good for newcomers labels Oct 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

No branches or pull requests

3 participants