@@ -20,7 +20,7 @@ describe('MySQL entity collector tests', () => {
2020 } ) ;
2121
2222 test ( 'split results' , ( ) => {
23- expect ( splitListener . statementsContext . length ) . toBe ( 15 ) ;
23+ expect ( splitListener . statementsContext . length ) . toBe ( 16 ) ;
2424 } ) ;
2525
2626 test ( 'create table by columns' , ( ) => {
@@ -468,21 +468,21 @@ describe('MySQL entity collector tests', () => {
468468 const functionEntity = allEntities [ 0 ] ;
469469
470470 expect ( functionEntity . entityContextType ) . toBe ( EntityContextType . FUNCTION_CREATE ) ;
471- expect ( functionEntity . text ) . toBe ( 'my_concat_ws ' ) ;
471+ expect ( functionEntity . text ) . toBe ( 'hello ' ) ;
472472 expect ( functionEntity . position ) . toEqual ( {
473- endColumn : 43 ,
474- endIndex : 982 ,
473+ endColumn : 39 ,
474+ endIndex : 978 ,
475475 line : 39 ,
476- startColumn : 31 ,
477- startIndex : 971 ,
476+ startColumn : 34 ,
477+ startIndex : 974 ,
478478 } ) ;
479479
480480 expect ( functionEntity . belongStmt . stmtContextType ) . toBe (
481481 StmtContextType . CREATE_FUNCTION_STMT
482482 ) ;
483483 expect ( functionEntity . belongStmt . position ) . toEqual ( {
484- endColumn : 87 ,
485- endIndex : 1026 ,
484+ endColumn : 114 ,
485+ endIndex : 1053 ,
486486 endLine : 39 ,
487487 startColumn : 1 ,
488488 startIndex : 941 ,
@@ -492,4 +492,42 @@ describe('MySQL entity collector tests', () => {
492492 expect ( functionEntity . columns ) . toBeNull ( ) ;
493493 expect ( functionEntity . relatedEntities ) . toBeNull ( ) ;
494494 } ) ;
495+
496+ test ( 'create function loadable' , ( ) => {
497+ const functionCreateContext = splitListener . statementsContext [ 15 ] ;
498+
499+ const collectListener = new MySqlEntityCollector ( commonSql ) ;
500+ mysql . listen ( collectListener as ParseTreeListener , functionCreateContext ) ;
501+
502+ const allEntities = collectListener . getEntities ( ) ;
503+
504+ expect ( allEntities . length ) . toBe ( 1 ) ;
505+
506+ const functionEntity = allEntities [ 0 ] ;
507+
508+ expect ( functionEntity . entityContextType ) . toBe ( EntityContextType . FUNCTION_CREATE ) ;
509+ expect ( functionEntity . text ) . toBe ( 'my_concat_ws' ) ;
510+ expect ( functionEntity . position ) . toEqual ( {
511+ endColumn : 43 ,
512+ endIndex : 1098 ,
513+ line : 41 ,
514+ startColumn : 31 ,
515+ startIndex : 1087 ,
516+ } ) ;
517+
518+ expect ( functionEntity . belongStmt . stmtContextType ) . toBe (
519+ StmtContextType . CREATE_FUNCTION_STMT
520+ ) ;
521+ expect ( functionEntity . belongStmt . position ) . toEqual ( {
522+ endColumn : 87 ,
523+ endIndex : 1142 ,
524+ endLine : 41 ,
525+ startColumn : 1 ,
526+ startIndex : 1057 ,
527+ startLine : 41 ,
528+ } ) ;
529+
530+ expect ( functionEntity . columns ) . toBeNull ( ) ;
531+ expect ( functionEntity . relatedEntities ) . toBeNull ( ) ;
532+ } ) ;
495533} ) ;
0 commit comments