aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/pgvector/django/bit.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/pgvector/django/bit.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-4a52a71956a8d46fcb7294ac71734504bb09bcc2.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to '.venv/lib/python3.12/site-packages/pgvector/django/bit.py')
-rw-r--r--.venv/lib/python3.12/site-packages/pgvector/django/bit.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/pgvector/django/bit.py b/.venv/lib/python3.12/site-packages/pgvector/django/bit.py
new file mode 100644
index 00000000..2cc847ad
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/pgvector/django/bit.py
@@ -0,0 +1,32 @@
+from django import forms
+from django.db.models import Field
+
+
+# https://docs.djangoproject.com/en/5.0/howto/custom-model-fields/
+class BitField(Field):
+ description = 'Bit string'
+
+ def __init__(self, *args, length=None, **kwargs):
+ self.length = length
+ super().__init__(*args, **kwargs)
+
+ def deconstruct(self):
+ name, path, args, kwargs = super().deconstruct()
+ if self.length is not None:
+ kwargs['length'] = self.length
+ return name, path, args, kwargs
+
+ def db_type(self, connection):
+ if self.length is None:
+ return 'bit'
+ return 'bit(%d)' % self.length
+
+ def formfield(self, **kwargs):
+ return super().formfield(form_class=BitFormField, **kwargs)
+
+
+class BitFormField(forms.CharField):
+ def to_python(self, value):
+ if isinstance(value, str) and value == '':
+ return None
+ return super().to_python(value)