GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add other input types for SQLAlchemy BIT model by jackrua · Pull Request #137 · pgvector/pgvector-python

Conversation

@jackrua

@jackrua jackrua commented Jul 17, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Hi,

First of all, thank you for the great library @ankane!

I'm opening this PR to address some issues that have been raised by users (#84, #110 and #112), that is to input types other than string in the BIT SQLAlchemy model (also when using the asyncpg dialect). In brief with this PR, given:

class Item(Base):
    id = mapped_column(Integer, primary_key=True)
    binary_embedding = mapped_column(BIT(3))

You can add it to your database using whatever input you like (and this will be transformed following the logic already present in the init of the Bit class):

with Session(engine) as session: 
   session.add(Item(id = 1, 
   binary_embedding = [True, False, True])) # or [1, 0, 1], or np.array([1, 0, 1]) 

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jackrua added 4 commits July 17, 2025 17:51
@jackrua
feat: add method to read from database and make method to write to da…
05349f9
…tabase more general
@jackrua
feat: add processor methods to BIT class
2b5e53d
@jackrua
test: use string directly instead of BitString
45cc2e1
@jackrua
fix: fix for case when value is none
3d14b22
@jackrua jackrua changed the title Add other input types for SQLAlchemy models Add other input types for SQLAlchemy BIT model Jul 17, 2025
ankane added a commit that referenced this pull request Sep 2, 2025
@ankane @jackrua
Added support for str objects for bit type with SQLAlchemy - #137
33dee60
Co-authored-by: Giacomo rua <[email protected]>
@ankane

ankane commented Sep 2, 2025

Copy link
Copy Markdown
Member

Hi @jackrua, thanks for the PR. Added support for passing str objects in the commit above. I think the other changes are breaking to some degree, but may make sense for 0.5.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jackrua and others added 5 commits September 8, 2025 19:01
@jackrua
Merge branch 'master' into feature/other_inputs_for_sqlalchemy_bit
33e265c
@jackrua
feat: add other input types for bit
1411240
@jackrua
fix: test
f176041
@jackrua
fix: use correct engine url
c48f0d2
@jackrua
fix: add user back into engine url
2e6795d
@jackrua

jackrua commented Sep 22, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Thank you @ankane for the feedback and sorry for the late response. I merged master in my branch and updated my PR, and now the CI passes too.

However, I was thinking that now when you read from the DB using the sqlalchemy model, we are returning str in some cases and BitString in others, wouldn't it be better to always return a Bit object (similar to what you do with HALFVEC for example), what do you think?
I wanted to implement the result_processor method to fix this in this PR but I wasn't sure what you thought about it, let me know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jackrua
style: remove unused method
d786125
@claude claude Bot mentioned this pull request Jun 2, 2026
chore(deps): bump pgvector from 0.4.1 to 0.4.2 dimagi/open-chat-studio#3513
Merged
@j45856021-dev j45856021-dev mentioned this pull request Oct 14, 2026
Bit cannot round-trip accepted empty values through text #165
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jackrua @ankane
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.