File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
main/java/org/seasar/doma/internal/jdbc/sql
test/java/org/seasar/doma/internal/jdbc/sql Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1515 */
1616package org .seasar .doma .internal .jdbc .sql ;
1717
18- import static org .seasar .doma .internal .util .AssertionUtil .assertNotNull ;
18+ import static org .seasar .doma .internal .util .AssertionUtil .* ;
1919
2020import java .util .Deque ;
2121import java .util .Iterator ;
5252import org .seasar .doma .internal .jdbc .sql .node .WhereClauseNode ;
5353import org .seasar .doma .internal .jdbc .sql .node .WhitespaceNode ;
5454import org .seasar .doma .internal .jdbc .sql .node .WordNode ;
55+ import org .seasar .doma .internal .util .StringUtil ;
5556import org .seasar .doma .jdbc .JdbcException ;
5657import org .seasar .doma .jdbc .SqlNode ;
5758import org .seasar .doma .message .Message ;
@@ -451,7 +452,7 @@ protected void parseForBlockComment() {
451452
452453 protected void parseExpandBlockComment () {
453454 String alias = tokenType .extract (token );
454- if (alias .isEmpty ()) {
455+ if (alias .isEmpty () || StringUtil . isWhitespace ( alias ) ) {
455456 alias = "\" \" " ;
456457 }
457458 ExpandNode node = new ExpandNode (getLocation (), alias , token );
Original file line number Diff line number Diff line change @@ -280,6 +280,18 @@ public void testExpand() throws Exception {
280280 assertEquals ("select bbb, ccc from aaa" , sql .getFormattedSql ());
281281 }
282282
283+ public void testExpand_withSpace () throws Exception {
284+ ExpressionEvaluator evaluator = new ExpressionEvaluator ();
285+ String testSql = "select /*%expand */* from aaa" ;
286+ SqlParser parser = new SqlParser (testSql );
287+ SqlNode sqlNode = parser .parse ();
288+ PreparedSql sql = new NodePreparedSqlBuilder (config , SqlKind .SELECT ,
289+ "dummyPath" , evaluator , SqlLogType .FORMATTED ,
290+ node -> Arrays .asList ("bbb" , "ccc" )).build (sqlNode );
291+ assertEquals ("select bbb, ccc from aaa" , sql .getRawSql ());
292+ assertEquals ("select bbb, ccc from aaa" , sql .getFormattedSql ());
293+ }
294+
283295 public void testExpand_alias () throws Exception {
284296 ExpressionEvaluator evaluator = new ExpressionEvaluator ();
285297 String testSql = "select /*%expand \" a\" */* from aaa a" ;
You can’t perform that action at this time.
0 commit comments