Skip to content

Conversation

@Dreamroute
Copy link
Contributor

Format class XNode toString method, make the sub label retract a 'tab'. eclipse "ctrl+shift+i" to watch the value of variable friendly.

Copy link
Member

@harawata harawata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Dreamroute ,

Thanks for the update!
There still is no test, so I wrote a simple test and it failed.

XPathParser parser = new XPathParser("<books><book><title>book1</title></book></books>");
assertEquals("<books>\n\t<book>\n\t\t<title>book1</title>\n\t</book>\n</books>",
  parser.evalNode("/books").toString());

Please add a test case or two so that we can understand what the expected behavior is.

p.s.
Please add new changes to this PR instead of submitting a new PR.
You can just 1) git commit new changes and then 2) git push to the same branch on your fork.
Let me know if you have any difficulty.

@Dreamroute
Copy link
Contributor Author

@harawata I have add a test case.pls check.

@harawata
Copy link
Member

Thanks for the update, @Dreamroute !

There seems to be a problem with a node with 3+ levels.
Try this test:

@Test
public void formatXNodeToStringDeep() {
  XPathParser parser = new XPathParser("<a><b><c><d>text</d></c></b></a>");
  String actual = parser.evalNode("/a").toString();
  String expect = "<a>\n\t<b>\n\t\t<c>\n\t\t\t<d>text</d>\n\t\t</c>\n\t</b>\n</a>\n";
  assertEquals(expect, actual);
}

@Dreamroute
Copy link
Contributor Author

@harawata I have solve the 3+ level format and add 3 test case.

Copy link
Member

@harawata harawata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update, @Dreamroute !
Please see the comments.

@Dreamroute
Copy link
Contributor Author

@harawata your 2 suggest have done.

Dreamroute and others added 2 commits September 23, 2019 23:40
fix: fix zhe test.

test: add fomate Xnode toString() method test.

fix: support 3+ level format, add 3 test case for every level.

fix: fix retract.

fix: revert.

fix: exchange the test 'expect' and 'actual'

refact: only use one StringBuilder in toString method.

fix: add comments.
- Re-formatted.
- Removed a few redundancies.
@harawata harawata merged commit 70e7e42 into mybatis:master Sep 23, 2019
@harawata
Copy link
Member

Hi @Dreamroute .
It's merged. I cleaned up your commits and force-pushed. Hope you don't mind.
Thanks again for your work!

@harawata
Copy link
Member

HI @Dreamroute ,

I noticed that this patch is not good enough for actual mapper statements.
Here is an example (a node contains both body text and a child element):

<select id="getUser" resultType="org.apache.ibatis.submitted.foreach.User">
  select * from users WHERE id in (
  <foreach item="friendList" index="index" collection="friendList" separator=",">
    #{friendList.id}
  </foreach>
  )
</select>

Do you think you can fix it?

@harawata harawata mentioned this pull request May 8, 2022
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
Indent output of XNode#toString().
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
Merge pull request mybatis#1660 from Dreamroute/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants