]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
10556: Create new BitString subclass for bitstrings for PG drivers
authorThomas Stephenson <ovangle@gmail.com>
Thu, 15 May 2025 13:21:49 +0000 (23:21 +1000)
committerThomas Stephenson <ovangle@gmail.com>
Thu, 15 May 2025 13:21:49 +0000 (23:21 +1000)
commit761748582718bde596fcb46d7109a274b910d0cc
tree4fa50afa76a71ea58fc2bdc08ada398871d2c571
parent46996843876a7635705686f67057fba9c795d787
10556: Create new BitString subclass for bitstrings for PG drivers

- Added custom `BitString` implementation which inherits from `str`
  and overrides methods and operators appropriately and
  implements the bitwise operations in a manner consistent with
  postgresql. Also exposes class and instance methods ensuring
  instances can be converted to/from `int` and `bytes` sensibly.

- Added default implementations of `bind_processor` and
  `result_processor` to `postgresql.BIT` type to convert `BitString`
  to/from string for PG drivers.

- Override `bind_processor` and `result_processor` in AsyncpgBit
  in order to convert `BitString` to/from `asynpg.BitString`
  in `asyncpg` driver.

- Added support for bitwise comparators to postgresql `BIT` instances

Fixes: 10556
lib/sqlalchemy/dialects/postgresql/__init__.py
lib/sqlalchemy/dialects/postgresql/asyncpg.py
lib/sqlalchemy/dialects/postgresql/bitstring.py [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/types.py
test/dialect/postgresql/test_bitstring.py [new file with mode: 0644]
test/dialect/postgresql/test_types.py