[BUG] parse regex sql error · Issue #21491 · bytebase/bytebase · GitHub
Skip to content

[BUG] parse regex sql error #21491

Open
Open

Description

@oslet

Provide the Bytebase version you are using

Release 3.22.1

Describe the bug

create table like

CREATE TABLE `mkt_channel` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `channel_no` varchar(64) NOT NULL COMMENT '渠道业务编号',
  `channel_code` varchar(2) NOT NULL COMMENT '两位大写渠道编码',
  `channel_name` varchar(128) NOT NULL COMMENT '渠道名称',
  `top_user_id` bigint DEFAULT NULL COMMENT '渠道商顶级用户ID',
  `status` varchar(32) NOT NULL COMMENT '业务状态',
  `official` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否官方渠道:0否,1是',
  `remark` varchar(512) DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(UTC)',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间(UTC)',
  `create_by` bigint DEFAULT NULL COMMENT '创建人用户ID',
  `update_by` bigint DEFAULT NULL COMMENT '更新人用户ID',
  `deleted` bigint NOT NULL DEFAULT '0' COMMENT '逻辑删除标识:0有效,非0已删除',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_mkt_channel_no` (`channel_no`),
  UNIQUE KEY `uk_mkt_channel_code` (`channel_code`,`deleted`),
  UNIQUE KEY `uk_mkt_channel_top_user` (`top_user_id`,`deleted`),
  KEY `idx_mkt_channel_status` (`status`,`create_time`,`id`),
  CONSTRAINT `ck_mkt_channel_code` CHECK (regexp_like(`channel_code`,_utf8mb4'^[A-Z]{2}$'))
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='营销渠道'

Steps to reproduce

database/table sync:

Code 13: Internal
[internal] failed to compute schema diff: failed to load source schema: unexpected token (line 673, column 42)
related text:   CONSTRAINT `ck_mkt_channel_code` CHECK regexp_like(`channel_code`,_utf8mb4'^[A-Z]{2}$')

Expected behavior

Code 13: Internal
[internal] failed to compute schema diff: failed to load source schema: unexpected token (line 673, column 42)
related text:   CONSTRAINT `ck_mkt_channel_code` CHECK regexp_like(`channel_code`,_utf8mb4'^[A-Z]{2}$')

Provide the database you are using

mysql 8.0

Additional context

No response

Activity

  1. whiskey-coder commented on Sep 19, 2026

    @whiskey-coder

    Hi, I traced this to the SQL serialization step - the expression is read correctly, but CHECK is rendered without the required parentheses.

    I can fix it and add a regression test if this is still available!

  2. d-bytebase commented on Sep 19, 2026

    @d-bytebase
    Collaborator

    Appreciate it. Please also check whether the issue is fixed on main, probably yes.

    Merci!

  3. whiskey-coder commented on Sep 19, 2026

    @whiskey-coder

    Please also check whether the issue is fixed on main, probably yes.

    Confirmed on latest main — the issue is still reproducible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions