@@ -1125,8 +1125,11 @@ public override void ExitAliased_table_name(MiniSqlParserParser.Aliased_table_na
11251125 }
11261126
11271127 public override void ExitHinted_table_name ( MiniSqlParserParser . Hinted_table_nameContext context ) {
1128- if ( context . table_hint ( ) == null ) {
1129- // table_hintが存在しない場合はなにもしない
1128+ // コメントでテーブル別名の指定があれば取得する
1129+ var implicitAliasName = this . GetTableAliasNameFromDocComment ( context ) ;
1130+
1131+ if ( context . table_hint ( ) == null && string . IsNullOrEmpty ( implicitAliasName ) ) {
1132+ // Tableオブジェクトを再作成する必要がなければ何もしない
11301133 return ;
11311134 }
11321135
@@ -1135,8 +1138,6 @@ public override void ExitHinted_table_name(MiniSqlParserParser.Hinted_table_name
11351138 comments . AddRange ( this . GetComments ( context ) ) ;
11361139 comments . AddRange ( this . GetComments ( context . table_hint ( ) ) ) ;
11371140
1138- // コメントでテーブル別名の指定があれば取得する
1139- var implicitAliasName = this . GetTableAliasNameFromDocComment ( context ) ;
11401141
11411142 var hinted_table = this . CreateHintedTable ( context . table_hint ( )
11421143 , tableNode
@@ -1172,20 +1173,23 @@ private Table CreateHintedTable(MiniSqlParserParser.Table_hintContext table_hint
11721173 Identifier indexSchemaName = null ;
11731174 Identifier indexName = null ;
11741175 bool hasNotIndexed = false ;
1175-
1176- if ( table_hintContext . K_NOT ( ) != null ) {
1177- hasNotIndexed = true ;
1178- } else if ( table_hintContext . K_INDEXED ( ) != null ) {
1179- comments . AddRange ( this . GetComments ( table_hintContext . index_name ( ) . qualified_schema_name ( ) ) ) ;
1180- comments . AddRange ( this . GetComments ( table_hintContext . index_name ( ) ) ) ;
1181- if ( table_hintContext . index_name ( ) . qualified_schema_name ( ) != null ) {
1182- indexServerName = this . GetIdentifier ( table_hintContext . index_name ( ) . qualified_schema_name ( ) . s ) ;
1183- indexDatabaseName = this . GetIdentifier ( table_hintContext . index_name ( ) . qualified_schema_name ( ) . d ) ;
1184- indexSchemaName = this . GetIdentifier ( table_hintContext . index_name ( ) . qualified_schema_name ( ) . n ) ;
1176+ var msSqlHint = MsSqlHint . None ;
1177+
1178+ if ( table_hintContext != null ) {
1179+ if ( table_hintContext . K_NOT ( ) != null ) {
1180+ hasNotIndexed = true ;
1181+ } else if ( table_hintContext . K_INDEXED ( ) != null ) {
1182+ comments . AddRange ( this . GetComments ( table_hintContext . index_name ( ) . qualified_schema_name ( ) ) ) ;
1183+ comments . AddRange ( this . GetComments ( table_hintContext . index_name ( ) ) ) ;
1184+ if ( table_hintContext . index_name ( ) . qualified_schema_name ( ) != null ) {
1185+ indexServerName = this . GetIdentifier ( table_hintContext . index_name ( ) . qualified_schema_name ( ) . s ) ;
1186+ indexDatabaseName = this . GetIdentifier ( table_hintContext . index_name ( ) . qualified_schema_name ( ) . d ) ;
1187+ indexSchemaName = this . GetIdentifier ( table_hintContext . index_name ( ) . qualified_schema_name ( ) . n ) ;
1188+ }
1189+ indexName = this . GetIdentifier ( table_hintContext . index_name ( ) . identifier ( ) ) ;
11851190 }
1186- indexName = this . GetIdentifier ( table_hintContext . index_name ( ) . identifier ( ) ) ;
1191+ msSqlHint = this . ConvToMsSqlHint ( table_hintContext . h ) ;
11871192 }
1188- var msSqlHint = this . ConvToMsSqlHint ( table_hintContext . h ) ;
11891193
11901194 return new Table ( tableNode . ServerName
11911195 , tableNode . DataBaseName
0 commit comments