Skip to content

Commit

Permalink
A test case that shows how namespace is resolved in a nested include
Browse files Browse the repository at this point in the history
Several users reported this behavior as a bug, but it is by design.
#2590 #3246 #3306
  • Loading branch information
harawata committed Dec 1, 2024
1 parent 4a6c025 commit 66a96f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,4 +57,10 @@ void testParametrizedIncludes() {
}
}

@Test
void shouldNamespaceBeResolvedAfterIncluded() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Assertions.assertNotNull(sqlSession.selectList("org.apache.ibatis.submitted.includes.mapper.selectIds"));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2009-2023 the original author or authors.
Copyright 2009-2024 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,4 +30,8 @@
<sql id="values">
VALUES (1);
</sql>
<sql id="selectId">
select id from
<include refid="tableName" />
</sql>
</mapper>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2009-2022 the original author or authors.
Copyright 2009-2024 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,9 @@
<sql id="sometable">
${prefix}Table
</sql>
<sql id="tableName">
SomeTable
</sql>

<sql id="someinclude">
<include refid="${include_target}"/>
Expand Down Expand Up @@ -54,4 +57,8 @@
Field3 = #{field3,jdbcType=VARCHAR},
where field1 = #{field1,jdbcType=INTEGER}
</update>

<select id="selectIds" resultType="int">
<include refid="org.apache.ibatis.submitted.includes.fragments.selectId"/>
</select>
</mapper>

0 comments on commit 66a96f5

Please sign in to comment.