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

simple_* methods handle None incorrectly for key valuesΒ #14157

@clokep

Description

@clokep

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-DatabaseDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbO-UncommonMost users are unlikely to come across this or unexpected workflowS-MinorBlocks non-critical functionality, workarounds exist.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions