-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Open
Description
Describe the bug
When using goctl model mysql datasource to generate database models, the tool determines if a field's default value is NULL by checking COLUMN_DEFAULT. However, this logic encounters issues when running against MariaDB.
To Reproduce
Steps to reproduce the behavior, if applicable:
- test sql
CREATE DATABASE testnull;
USE testnull;
CREATE TABLE `test_table` (
`test_null` VARCHAR(10) DEFAULT 'NULL',
`name` VARCHAR(10) DEFAULT 'aaa',
`age` int DEFAULT 10,
`deleted_at` datetime(3) DEFAULT NULL
);
SELECT
c.COLUMN_NAME,
c.DATA_TYPE,
c.COLUMN_TYPE,
c.EXTRA,
c.COLUMN_COMMENT,
c.COLUMN_DEFAULT,
c.IS_NULLABLE,
c.ORDINAL_POSITION
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE c.TABLE_SCHEMA = 'testnull'
AND c.TABLE_NAME = 'test_table';In MySQL-9.6.0 I get the flllowing content

Expected behavior
The code check isDefaultNull with COLUMN_DEFAULT , but in mariadb, we get a null string.
https://github.com/zeromicro/go-zero/blob/master/tools/goctl/model/sql/parser/parser.go#L355
Environments (please complete the following information):
- OS: Linux
- goctl version 1.9.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
