Skip to content

fix: pass codec options to db.command()#39

Open
msyavuz wants to merge 1 commit into
passren:mainfrom
msyavuz:fix/command-codec-options
Open

fix: pass codec options to db.command()#39
msyavuz wants to merge 1 commit into
passren:mainfrom
msyavuz:fix/command-codec-options

Conversation

@msyavuz

@msyavuz msyavuz commented Jul 16, 2026

Copy link
Copy Markdown

Database.command() falls back to DEFAULT_CODEC_OPTIONS when codec_options is omitted, so options configured on the client were ignored on every read. Most visibly, uuidRepresentation had no effect: BSON UUID fields were decoded as raw bson.Binary instead of uuid.UUID no matter what the connection string asked for, because reads go through db.command({'find': ...}) rather than collection.find().

  # mongodb://.../db?uuidRepresentation=standard
  cur.execute("SELECT * FROM testUuid")
  cur.fetchall()   # -> Binary(b'\xbc\xf9...', 4)   expected: UUID('bcf9a897-...')

Pass the database's codec options for both find and getMore, so results decode consistently with collection.find() and across batches.

Database.command() falls back to DEFAULT_CODEC_OPTIONS when codec_options is
omitted, so options configured on the client were ignored on every read. Most
visibly, uuidRepresentation had no effect: BSON UUID fields were decoded as raw
bson.Binary instead of uuid.UUID no matter what the connection string asked for,
because reads go through db.command({'find': ...}) rather than collection.find().

Pass the database's codec options for both find and getMore, so results decode
consistently with collection.find() and across batches.
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.

1 participant