Skip to content

Normalize BIT column default literals#439

Open
JanJakes wants to merge 1 commit into
trunkfrom
default-bit-fix
Open

Normalize BIT column default literals#439
JanJakes wants to merge 1 commit into
trunkfrom
default-bit-fix

Conversation

@JanJakes

@JanJakes JanJakes commented Jun 18, 2026

Copy link
Copy Markdown
Member

What

BIT column defaults were stored and rendered incorrectly. A column such as BIT(1) DEFAULT '0' (e.g., as produced by Ninja Forms) emitted an invalid SHOW CREATE TABLE / dump line:

`maintenance` bit(1) DEFAULT '0'

MySQL does not accept a quoted-string default on a BIT column—the value has to be a bit literal (b'0') or a number (0). The invalid output broke dump/restore flows (e.g., Studio → Pressable).

Fix

Normalize BIT column default literals end to end:

  • Store: Record BIT defaults in the information schema in a normalized format (b'...').
  • SHOW CREATE TABLE: Emit the stored bit literal verbatim (bit(1) DEFAULT b'0').
  • Internal SQLite DDL / column = DEFAULT: Render the bit literal as the SQLite integer it maps to.
  • Legacy migration: The information-schema reconstructor converts integer BIT defaults into a bit literal.

Tests

  • SHOW CREATE TABLE output and the inserted/read-back values for every default form (quoted string, integer, b'…', 0b…, x'…', TRUE, FALSE).
  • UPDATE … SET col = DEFAULT on a BIT column.
  • Reconstruction of BIT defaults for legacy databases.
  • Full unit suite green; coding standards (PHPCS) pass.

Store BIT defaults as canonical bit literals (b'...') in the information
schema and render them as bit literals for SHOW CREATE TABLE, while using
SQLite integer literals for the internal table DDL and DEFAULT assignments.

This fixes dumps that emitted invalid output such as `bit(1) DEFAULT '0'`
for BIT columns defined with a quoted-string, integer, hex, bit-literal,
or TRUE/FALSE default.
@JanJakes JanJakes marked this pull request as ready for review June 18, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant