-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Feature Request
Summary
Enable seamless mapping of TINYINT(1) to Boolean in r2dbc-mysql by implementing the tinyInt1isBit flag with true as the default behavior. This enhancement aligns with the common MySQL convention of using TINYINT(1) for boolean values, simplifying development workflows and improving compatibility with existing schemas.
Problem Statement
Currently, r2dbc-mysql does not treat TINYINT(1) as Boolean by default. This creates challenges for developers who rely on the widespread convention of TINYINT(1) being used for boolean fields in MySQL schemas. The following issues arise:
- Developers are forced to modify their database schemas (e.g., switching to
BIT(1)), which is often impractical for legacy systems. - Custom converters or manual getter/setter logic must be implemented to handle boolean mappings, adding unnecessary complexity to the application code.
Given that TINYINT(1) is commonly treated as a boolean in many MySQL connectors (e.g., mysql-connector-j), r2dbc-mysql should adopt the same behavior by default to minimize friction and provide an intuitive developer experience.
Proposed Solution
- Implement the
tinyInt1isBitflag inr2dbc-mysql. - Set the default value of
tinyInt1isBittotrue, ensuring that:TINYINT(1)columns are automatically mapped toBooleanfields in Java entities.- Developers can explicitly disable this behavior if they prefer
TINYINT(1)to be treated asInteger.
Example Configuration for Overriding Default Behavior:
spring:
r2dbc:
url: r2dbc:mysql://<host>/<database>?tinyInt1isBit=falseBenefits
-
Seamless Integration:
TreatingTINYINT(1)asBooleanby default aligns with developer expectations and reduces the need for schema changes or custom logic. -
Compatibility with MySQL Ecosystem:
This change alignsr2dbc-mysqlwith other popular MySQL connectors (e.g., Hibernate, JDBC), which treatTINYINT(1)as boolean by default. -
Flexibility:
Developers who requireTINYINT(1)to be treated asIntegercan easily disable the feature by settingtinyInt1isBit=false.