[MYSQL] Columns with DEFAULT '' are incorrectly included in ColumnsWithoutDefault
Why this is a problem? This results in an unnecessary extra SELECT query (reload) being executed after the INSERT operation to fetch and backfill the data.
Description: When a MySQL table column is defined with an empty string as its default value (e.g., CHAR(40) NOT NULL DEFAULT ''), SQLBoiler's code generation incorrectly treats this column as having no default value and includes it in ColumnsWithoutDefault.
It seems the driver parses a default value of '' (empty string) and conflates it with the internal representation of "no default value" (which is also an empty string/nil).
Steps to Reproduce
1 Create a MySQL table with a column like this:
SQL:
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name CHAR(40) NOT NULL DEFAULT '',
token CHAR(40) NOT NULL DEFAULT ''
);
2 Run sqlboiler to generate the models. 3 Check the generated column slices/metadata (e.g., UserColumnsWithoutDefault). 4 run user = new(models.User) user .Name= 'SQLBoiler' user.InsertG(ctx, boil.Infer())
Expected Behavior: A column with DEFAULT '' should be recognized as having a default value, meaning it should not be forced into ColumnsWithoutDefault (or it should be categorized correctly as having a default).
Environment: SQLBoiler Version: v4.19.7
Source: aarondl/sqlboiler