Normalize BIT column default literals#439
Open
JanJakes wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 invalidSHOW CREATE TABLE/ dump line: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:
b'...').SHOW CREATE TABLE: Emit the stored bit literal verbatim (bit(1) DEFAULT b'0').column = DEFAULT: Render the bit literal as the SQLite integer it maps to.Tests
SHOW CREATE TABLEoutput and the inserted/read-back values for every default form (quoted string, integer,b'…',0b…,x'…',TRUE,FALSE).UPDATE … SET col = DEFAULTon a BIT column.