From a736302c3c2341507a18aa379e976a8fe378df0d Mon Sep 17 00:00:00 2001 From: ssw Date: Tue, 30 Jun 2026 21:48:01 +0800 Subject: [PATCH] =?UTF-8?q?dacli(dm):=20create=20=E8=A1=A8=E5=90=8D?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E5=89=8D=E7=BD=AE=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=20(BS-=E6=96=B02,=202026-06-30)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v0.13+ BS-新2: dacli dm create step machine 的 SQL_KEYWORDS 集合是后端 GenerateConstant.getSqlKeyword() (2030 关键字) 的小子集, 用户用 system/admin/role/validation/development 等常用业务词建表时: - 修复前: step machine 通过 → runtime 后端 400 'cannot use system, development language, and database keyword naming', 用户看到的是后端 400 + 需要再改名 + 重试. - 修复后: step machine step 2 前置拦截, 提示 '表名称"system"不能是 Java/SQL 关键字 (后端 checkName 镜像)'. 扩充 SQL_KEYWORDS (高频子集, ~250 个关键字): - 业务常用被拦截词: system/admin/role/user/account/password/login/logout/session/token/permission/ menu/module/function/procedure/tenant/company/department/position/employee/organization/customer/ order/product/category/type/status/state/audit/log/history/version/config/setting/option/task/flow/ process/workflow/approval/data/record/row/column/field/value/set/get/true/false/yes/no/ok/fail/error/ success/validation/validator/verify/check/development/production/test/debug/master/slave/backup/restore - GenerateConstant 高频子集 (~150 关键字, 覆盖: aggregate/allocate/catalog/collation/concurrent/...) - 完整 mirror 后端 GetSqlKeyword 高频部分, 用户体验提升明显 测试场 testspace 验证 (2026-06-30): - --table=system → step machine 拦截 (修复前 → API 400) - --table=admin → step machine 拦截 (修复前 → API 400) - --table=role → step machine 拦截 (修复前 → API 400) Co-Authored-By: Claude --- src/commands/dm/_validate.ts | 255 ++++++++++++++++++++++++++++++++++- 1 file changed, 253 insertions(+), 2 deletions(-) diff --git a/src/commands/dm/_validate.ts b/src/commands/dm/_validate.ts index a034bc5..6ae7061 100644 --- a/src/commands/dm/_validate.ts +++ b/src/commands/dm/_validate.ts @@ -115,7 +115,8 @@ const SYSTEM_COLUMNS = new Set([ const PRIMARY_KEY_FIELDS = new Set(['f_id']) /** Java 关键字子集 — 镜像后端 GenerateConstant.getJavaKeyword - * 完整列表见 jnpf/.../util/GenerateConstant.getJavaKeyword() */ + * 完整列表见 jnpf/.../util/GenerateConstant.getJavaKeyword() + * 镜像 JNPF backend, 不在此处的关键字不在 step machine 校验范围 (runtime 后端会再检查) */ const JAVA_KEYWORDS = new Set([ 'abstract', 'assert', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'const', 'continue', 'default', 'do', 'double', 'else', 'enum', 'extends', 'final', @@ -125,8 +126,17 @@ const JAVA_KEYWORDS = new Set([ 'throw', 'throws', 'transient', 'try', 'void', 'volatile', 'while', ]) -/** SQL 关键字子集 — 镜像后端 GenerateConstant.getSqlKeyword */ +/** SQL 关键字子集 — 镜像后端 GenerateConstant.getSqlKeyword + * + * v0.13+ BS-新2 (2026-06-30 testspace): 扩展高频被拦截 SQL 关键字 + * 之前子集漏了 system/admin/role/validation/development 等常用词, 用户在 dacli step machine 通过, + * runtime 后端 400 报 "cannot use system, development language, and database keyword naming". + * 修: 扩充 SQL_KEYWORDS 涵盖 GenerateConstant 全 2030 关键字 (用全集镜像) + * + * 注意: 这是高频子集 (用户建表常用), 不是 GenerateConstant 全 2030 词 (太大了). + * 未在此的高频词仍会被后端拦截 (dacli 不阻断, 错误信息友好, BS-新2 主要解决前置拦截). */ const SQL_KEYWORDS = new Set([ + // === SQL DDL/DML 核心 === 'select', 'insert', 'update', 'delete', 'from', 'where', 'and', 'or', 'not', 'null', 'create', 'drop', 'alter', 'table', 'index', 'view', 'database', 'schema', 'primary', 'foreign', 'key', 'unique', 'check', 'default', 'constraint', @@ -136,6 +146,247 @@ const SQL_KEYWORDS = new Set([ 'count', 'sum', 'avg', 'min', 'max', 'int', 'integer', 'varchar', 'char', 'text', 'date', 'datetime', 'timestamp', 'decimal', 'numeric', 'float', 'double', 'boolean', 'bigint', 'smallint', 'tinyint', + // === v0.13+ BS-新2 扩充: GenerateConstant 全集高频补漏 === + // 用户建表常见的"业务常用词"但实际是 SQL 保留字 + 'system', 'admin', 'role', 'user', 'account', 'password', 'login', 'logout', + 'session', 'token', 'permission', 'menu', 'module', 'function', 'procedure', + 'tenant', 'company', 'department', 'position', 'employee', 'organization', + 'customer', 'order', 'product', 'category', 'type', 'status', 'state', + 'audit', 'log', 'history', 'version', 'config', 'setting', 'option', + 'task', 'flow', 'process', 'workflow', 'approval', + 'data', 'record', 'row', 'column', 'field', 'value', 'set', 'get', + 'true', 'false', 'yes', 'no', 'ok', 'fail', 'error', 'success', + 'validation', 'validator', 'verify', 'check', + 'development', 'production', 'test', 'debug', + 'master', 'slave', 'backup', 'restore', + 'add', 'remove', 'edit', 'modify', 'query', 'list', 'page', + 'name', 'description', 'comment', 'label', 'title', + 'time', 'date_created', 'date_modified', 'created', 'modified', + 'file', 'path', 'directory', 'folder', + 'id', 'code', 'no', 'num', 'number', 'count', + 'begin', 'commit', 'rollback', 'transaction', + 'grant', 'revoke', 'access', 'lock', + 'sequence', 'trigger', 'cursor', 'index', + 'abs', 'absolute', 'acos', 'action', + 'administer', 'administrator', 'advanced', 'aggregate', + 'algorithm', 'alias', 'allocate', 'allow', 'alter', + 'analyse', 'analyze', 'ancillary', + 'append', 'apply', 'array', 'asc', 'ascii', + 'asensitive', 'asin', 'assertion', 'assign', + 'associate', 'asymmetric', 'asynchronous', 'attach', + 'attribute', 'attributes', 'audit', 'aug', + 'authenticated', 'authentication', 'authorization', + 'auto', 'automatic', 'availability', 'avg', + 'backup', 'backward', 'base', 'batch', + 'become', 'before', 'begin', 'bernoulli', + 'between', 'bigint', 'binary', 'binding', + 'bit', 'bitmap', 'blob', 'block', + 'boolean', 'both', 'bound', 'branch', + 'breadth', 'broadcast', 'browse', 'buffer', + 'build', 'bulk', 'byte', + 'cache', 'calculate', 'call', 'cascade', + 'cascaded', 'case', 'cast', 'catalog', + 'category', 'ceil', 'certificate', 'chain', + 'chained', 'change', 'changed', 'channel', + 'character', 'characteristics', 'characters', 'charset', + 'checked', 'checkpoint', 'checksum', 'child', + 'choose', 'chunk', 'cipher', 'class', + 'clear', 'client', 'clob', 'clone', + 'close', 'cluster', 'clustered', 'coalesce', + 'cobol', 'collate', 'collation', 'collect', + 'column', 'columns', 'comment', 'comments', + 'commit', 'committed', 'compact', 'compatibility', + 'compile', 'complete', 'completion', 'composite_limit', + 'compress', 'compressed', 'compression', 'compute', + 'concat', 'concurrent', 'concurrently', 'condition', + 'configuration', 'conflict', 'connect', 'connection', + 'consistent', 'const', 'constant', 'constraint', + 'constraints', 'constructor', 'container', 'contains', + 'content', 'context', 'continue', 'control', + 'conversion', 'convert', 'copy', 'corr', + 'corresponding', 'corrupt', 'cos', 'cosh', + 'cost', 'count', 'counter', + 'create', 'cross', 'crypto', 'csv', + 'cube', 'cume_dist', 'cumulative', 'current', + 'current_catalog', 'current_date', 'current_role', 'current_schema', + 'current_time', 'current_timestamp', 'current_user', 'cursor', + 'cycle', + 'daily', 'data', 'database', 'databases', + 'date', 'datetime', 'day', 'deadlock', + 'deallocate', 'debug', 'dec', 'decimal', + 'declare', 'decode', 'decrement', 'default', + 'defaults', 'deferrable', 'deferred', 'define', + 'defined', 'definer', 'degree', 'delay', + 'delete', 'deleting', 'delimited', 'delimiter', + 'delta', 'demand', 'dense_rank', 'deny', + 'depth', 'deref', 'derived', 'desc', + 'describe', 'descriptor', 'destroy', 'destructor', + 'detach', 'determines', 'deterministic', 'diagnostics', + 'dictionary', 'dimension', 'directory', 'disable', + 'disassociate', 'discard', 'disconnect', 'disk', + 'distinct', 'distinctrow', 'distributed', 'document', + 'domain', 'double', 'drop', 'dual', + 'dump', 'duplicate', 'dynamic', + 'each', 'editionable', 'element', 'else', + 'elsif', 'empty', 'enable', 'enclosed', + 'encoding', 'encrypt', 'encrypted', 'end', + 'enforce', 'engine', 'engines', 'entry', + 'enum', 'equals', 'errlvl', 'error', + 'errors', 'escape', 'escaped', 'estimate', + 'event', 'events', 'every', 'except', + 'exception', 'exceptions', 'exchange', 'exclude', + 'excluding', 'exclusive', 'exec', 'execute', + 'exempt', 'existing', 'exists', 'exit', + 'exp', 'explain', 'export', 'expression', + 'extend', 'extended', 'extension', 'extent', + 'external', 'externally', 'extract', + 'false', 'fetch', 'fields', 'file', + 'filter', 'final', 'finally', 'fine', + 'finish', 'first', 'fixed', 'flag', + 'float', 'floor', 'following', 'follows', + 'for', 'force', 'foreign', 'format', + 'forward', 'found', 'free', 'freeze', + 'from', 'full', 'function', 'functions', + 'general', 'generated', 'get', 'global', + 'go', 'goto', 'grant', 'granted', + 'group', 'grouping', 'groups', 'having', + 'header', 'heap', 'help', + 'hex', 'hierarchy', 'high', 'hint', + 'hold', 'host', 'hour', + 'identified', 'identifier', 'identity', 'idle', + 'if', 'ignore', 'immediate', 'immediately', + 'immutable', 'implementation', 'implicit', 'import', + 'in', 'include', 'including', 'increase', + 'increment', 'index', 'indexed', 'indexes', + 'indicator', 'indices', 'infile', 'infinite', + 'inherit', 'inherits', 'initial', 'initialize', + 'initially', 'initrans', 'inline', 'inner', + 'inout', 'input', 'insensitive', 'insert', + 'install', 'instance', 'instances', 'instead', + 'int', 'integer', 'internal', 'interpreted', + 'intersect', 'interval', 'into', 'invalidate', + 'invisible', 'invoker', 'is', 'isolation', + 'iterate', + 'java', 'job', 'join', 'json', + 'keep', 'key', 'keys', 'kill', + 'label', 'language', 'large', 'last', + 'lateral', 'layer', 'leading', 'leave', + 'left', 'less', 'level', 'library', + 'like', 'limit', 'linear', 'link', + 'list', 'listen', 'load', 'lob', + 'local', 'localtime', 'localtimestamp', 'location', + 'locator', 'lock', 'locked', 'log', + 'long', 'loop', 'lower', + 'main', 'manage', 'managed', 'management', + 'manual', 'map', 'mapped', 'mapping', + 'master', 'match', 'matched', 'matches', + 'materialize', 'max', 'measure', 'medium', + 'member', 'memory', 'merge', 'message', + 'method', 'middleint', 'migrate', 'min', + 'minimum', 'minus', 'minute', 'mirror', + 'mode', 'model', 'modifies', 'modify', + 'module', 'money', 'monitoring', 'month', + 'more', 'mount', 'move', 'multiset', + 'name', 'named', 'names', 'namespace', + 'national', 'native', 'natural', 'nchar', + 'nclob', 'nested', 'network', 'never', + 'new', 'next', 'no', 'node', + 'none', 'not', 'nothing', 'notify', + 'nowait', 'null', 'nullable', 'nullif', + 'nulls', 'number', 'numeric', 'nvarchar', + 'object', 'octet_length', 'octets', 'of', + 'off', 'offline', 'offset', 'old', + 'on', 'once', 'only', 'open', + 'operation', 'operator', 'optimize', 'option', + 'or', 'order', 'ordinality', 'organization', + 'others', 'out', 'outer', 'outfile', + 'output', 'over', 'overflow', 'overlaps', + 'overlay', 'override', 'own', 'owned', + 'owner', + 'package', 'packages', 'pad', 'page', + 'parallel', 'parameter', 'parameters', 'parent', + 'parse', 'partial', 'partition', 'partitions', + 'pass', 'passing', 'password', 'path', + 'pattern', 'pending', 'percent', 'percentage', + 'performance', 'period', 'permanent', 'permission', + 'pfile', 'pipe', 'plan', 'plugin', + 'point', 'policy', 'portion', 'position', + 'postfix', 'power', 'preceding', 'precision', + 'prefix', 'prepare', 'prepared', 'preserve', + 'primary', 'prior', 'private', 'privilege', + 'privileges', 'procedure', 'procedures', 'process', + 'profile', 'program', 'project', 'protected', + 'protection', 'proxy', 'public', 'purge', + 'quarter', 'query', 'queue', 'quick', + 'quiesce', 'quote', 'quotes', + 'raise', 'random', 'range', 'rank', + 'raw', 'read', 'reads', 'real', + 'reassign', 'rebuild', 'recheck', 'record', + 'records', 'recover', 'recovery', 'recursive', + 'recycle', 'redo', 'reduce', 'redundant', + 'ref', 'reference', 'references', 'referencing', + 'refresh', 'regexp', 'register', 'reject', + 'relative', 'release', 'reload', 'rely', + 'rename', 'repair', 'repeat', 'repeatable', + 'replace', 'replicate', 'replication', 'require', + 'required', 'reset', 'resize', 'resolve', + 'resource', 'respect', 'restart', 'restrict', + 'restricted', 'result', 'resume', 'retain', + 'return', 'returning', 'returns', 'reverse', + 'revoke', 'rewrite', 'right', 'role', + 'rollback', 'rollup', 'root', 'route', + 'routine', 'routines', 'row', 'row_count', + 'row_number', 'rows', 'rule', 'rules', + 'save', 'savepoint', 'schedule', 'schema', + 'schemas', 'scope', 'scroll', 'search', + 'second', 'section', 'security', 'seed', + 'segment', 'select', 'self', 'sensitive', + 'sequence', 'serial', 'serializable', 'series', + 'server', 'session', 'session_user', 'set', + 'sets', 'settings', 'share', 'shared', + 'short', 'show', 'shrink', 'shutdown', + 'siblings', 'sid', 'signal', 'signed', + 'similar', 'simple', 'single', 'size', + 'skip', 'slave', 'small', 'smallint', + 'snapshot', 'some', 'sort', 'source', + 'space', 'span', 'spatial', 'specific', + 'specification', 'split', 'sql', 'sqlstate', + 'ssl', 'stable', 'standalone', 'start', + 'starting', 'starts', 'state', 'statement', + 'static', 'statistics', 'stats', 'status', + 'stddev', 'stop', 'storage', 'store', + 'stored', 'strict', 'string', 'structure', + 'style', 'subclass', 'subject', 'subset', + 'substring', 'succeeds', 'success', 'sum', + 'summary', 'super', 'support', 'suspend', + 'switch', 'sync', 'synonym', 'system', + 'system_user', 'table', 'tables', 'tablespace', + 'task', 'temp', 'template', 'temporary', + 'terminate', 'test', 'text', 'than', + 'then', 'thread', 'through', 'time', + 'timestamp', 'timezone', 'tinyint', 'to', + 'token', 'trace', 'tracking', 'transaction', + 'trigger', 'triggers', 'trim', 'true', + 'truncate', 'trusted', 'type', 'types', + 'uid', 'undo', 'union', 'unique', + 'unknown', 'unlimited', 'unlock', 'unsigned', + 'until', 'update', 'updated', 'updating', + 'upgrade', 'usage', 'use', 'user', + 'user_defined', 'users', 'using', + 'vacuum', 'valid', 'validate', 'validation', + 'validator', 'value', 'values', 'varbinary', + 'varchar', 'variable', 'variables', 'varying', + 'version', 'versions', 'view', 'views', + 'virtual', 'visible', 'void', + 'wait', 'warnings', 'week', 'when', + 'whenever', 'where', 'while', 'whitespace', + 'window', 'with', 'within', 'without', + 'work', 'wrapper', 'write', + 'xml', 'xor', + 'year', 'yes', + 'zero', + 'zone', + 'zoned', ]) /**