Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: encoding/xml Unmarshal comment with tag #39357

Open
LinWanCen opened this issue Jun 2, 2020 · 0 comments
Open

Proposal: encoding/xml Unmarshal comment with tag #39357

LinWanCen opened this issue Jun 2, 2020 · 0 comments
Labels
Projects
Milestone

Comments

@LinWanCen
Copy link

@LinWanCen LinWanCen commented Jun 2, 2020

What did you do?

<mapper namespace="TEST">

  <!-- Multi-table -->
  <select id="MULTI" parameterType="java.util.Map" resultType="Map">
    SELECT * FROM information_schema.COLUMNS, COLUMNS, ${schema}.TABLES
  </select>

  <!-- Join -->
  <select id="JOIN" parameterType="java.util.Map" resultType="Map">
    SELECT * FROM information_schema.COLUMNS JOIN TABLES
  </select>
<mapper namespace="TEST">
type (
	Mapper struct {
		XMLName   xml.Name
		Namespace string `xml:"namespace,attr"`
		Select    []sql  `xml:"select"`
		Insert    []sql  `xml:"insert"`
		Update    []sql  `xml:"update"`
		Delete    []sql  `xml:"delete"`
	}

	sql struct {
		Comment string `xml:",comment"`
		Id      string `xml:"id,attr"`
		SQL     string `xml:",innerxml"`
	}
)

func test(path string)  {
	model := Mapper{}
	xml.Unmarshal(util.ReadByte(path), &model)
}

What did you expect to see?

Mapper.Select[0].Comment == "Multi-table"
Mapper.Select[1].Comment == "Join"

if

	Mapper struct {
		XMLName   xml.Name
		Namespace string `xml:"namespace,attr"`
		Comment []string `xml:"select,comment"`
		Select    []sql  `xml:"select"`
		Insert    []sql  `xml:"insert"`
		Update    []sql  `xml:"update"`
		Delete    []sql  `xml:"delete"`
	}

then

Mapper.Comment[0] == "Multi-table"
Mapper.Comment[1] == "Join"

What did you see instead?

Mapper.Select[0].Comment == ""
Mapper.Select[1].Comment == ""

if

	Mapper struct {
		XMLName   xml.Name
		Namespace string `xml:"namespace,attr"`
		Comment string `xml:",comment"`
		Select    []sql  `xml:"select"`
		Insert    []sql  `xml:"insert"`
		Update    []sql  `xml:"update"`
		Delete    []sql  `xml:"delete"`
	}

then

Mapper.Comment  == "Multi-table Join"
@gopherbot gopherbot added this to the Proposal milestone Jun 2, 2020
@gopherbot gopherbot added the Proposal label Jun 2, 2020
@rsc rsc added this to Incoming in Proposals Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Proposals
Incoming
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.