Opened 9 hours ago

Last modified 6 hours ago

#36101 closed New feature

Support BIT data type model field for MySQL and PostgreSQL — at Version 1

Reported by: Jordan Bae Owned by:
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Jordan Bae Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jordan Bae)

Support BIT data type model field for MySQL and PostgreSQL

Currently, Django's model fields do not support the BIT data type which is available in both MySQL and PostgreSQL databases.

Key reasons for adding BIT data type support:

  1. Improved Database Inspection
    • When using inspectdb on tables containing BIT columns, Django currently falls back to TextField with a "This field type is a guess" comment
    • Native BitField support would provide accurate model generation for existing databases
  1. Database-specific Features
    • MySQL: Support for BIT(M) where M can specify the number of bits
    • PostgreSQL: Support for both BIT(n) and BIT VARYING(n) types


  1. Use Cases
    • Efficient storage of boolean flags and bit flags
    • Direct mapping to database-native bit operations
    • Better integration with legacy databases using BIT columns

This enhancement would improve Django's database type coverage and provide more efficient handling of bit-based data.

Change History (1)

comment:1 by Jordan Bae, 9 hours ago

Description: modified (diff)
Summary: Support bit data type model field on MySQL, PostgreSQLSupport BIT data type model field for MySQL and PostgreSQL
Note: See TracTickets for help on using tickets.
Back to Top