@@ -3,6 +3,7 @@ import { TableModel } from '@eggjs/dal-decorator';
33import { Foo } from './fixtures/modules/dal/Foo' ;
44import { SqlGenerator } from '../src/SqlGenerator' ;
55import { AutoUpdateTime } from './fixtures/modules/dal/AutoUpdateTime' ;
6+ import { FooIndexName } from './fixtures/modules/dal/FooIndexName' ;
67
78describe ( 'test/SqlGenerator.test.ts' , ( ) => {
89 it ( 'generator should work' , ( ) => {
@@ -67,4 +68,20 @@ describe('test/SqlGenerator.test.ts', () => {
6768 ' date_4 TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) NOT NULL UNIQUE KEY\n' +
6869 ') ;' ) ;
6970 } ) ;
71+
72+ it ( 'generator index name should work' , ( ) => {
73+ const generator = new SqlGenerator ( ) ;
74+ const fooIndexNameTableModel = TableModel . build ( FooIndexName ) ;
75+ const sql = generator . generate ( fooIndexNameTableModel ) ;
76+ assert . equal ( sql , 'CREATE TABLE IF NOT EXISTS egg_foo (\n' +
77+ ' id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT \'the primary key\',\n' +
78+ ' name VARCHAR(100) NOT NULL UNIQUE KEY,\n' +
79+ ' col1 VARCHAR(100) NOT NULL,\n' +
80+ ' bit_column BIT(10) NOT NULL,\n' +
81+ ' bool_column BOOL NOT NULL,\n' +
82+ ' FULLTEXT KEY idx_col1_bool_column (col1,bool_column) COMMENT \'index comment\\n\',\n' +
83+ ' UNIQUE KEY uk_name_col1_bit_column (name,col1,bit_column) USING BTREE COMMENT \'index comment\\n\'\n' +
84+ ') DEFAULT CHARACTER SET utf8mb4, DEFAULT COLLATE utf8mb4_unicode_ci, COMMENT=\'foo table\';' ,
85+ ) ;
86+ } ) ;
7087} ) ;
0 commit comments