Skip to content

Support Bit operands in Django distance functions - #179

Open
AlexShen-Oguri wants to merge 1 commit into
pgvector:masterfrom
AlexShen-Oguri:codex/django-bit-distance-arguments
Open

AlexShen-Oguri wants to merge 1 commit into
pgvector:masterfrom
AlexShen-Oguri:codex/django-bit-distance-arguments

Conversation

@AlexShen-Oguri

Copy link
Copy Markdown

Summary

Accept pgvector.Bit operands in Django's HammingDistance and JaccardDistance. Convert the operand to its bit string before wrapping it in a Django Value, and use the same normalized argument for expression identity. The original queryset compiled with a Bit parameter that Psycopg's default adapters could not bind.

Evidence

The new regression fails on the original code and passes with the fix. I also compiled both distance expressions with Django's PostgreSQL backend and adapted their parameters with Psycopg without a database connection. Bit('101') and '101' produce the same SQL and bindable parameter, and an F() operand resolves to a column. The focused suite passed 115 tests, with 8 skipped because SciPy was unavailable. PostgreSQL integration is left to the project suite.

OpenAI Codex assisted with the fix and verification.

Convert Bit operands to bindable strings and use normalized operands for Django expression identity.

Co-authored-by: OpenAI Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant