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

Allow <set> to trim comma prefix #21

Closed
fengxx opened this issue Mar 22, 2013 · 1 comment
Closed

Allow <set> to trim comma prefix #21

fengxx opened this issue Mar 22, 2013 · 1 comment
Assignees
Labels
enhancement Improve a feature or add a new feature
Milestone

Comments

@fengxx
Copy link
Contributor

fengxx commented Mar 22, 2013

Propose to change set node to allow it trim comma prefix

public class SetSqlNode extends TrimSqlNode {

  public SetSqlNode(Configuration configuration,SqlNode contents) {
    super(configuration, contents, "SET", ",", null, ",");
  }

}

Reason:
It is natural for users migrated from ibatis to write code like this

UPDATE user
<set>
    <if test="name != null">
        name=#{name}
    </if>
    <if test="desc != null">
        ,desc=#{desc}
    </if>
</set>

Instead of

UPDATE user
<set>
    <if test="name != null">
        name=#{name},
    </if>
    <if test="desc != null">
        desc=#{desc}
    </if>
</set>

The added feature will not break anything, although may use some cpu cycles and slow down a bit.

@harawata harawata self-assigned this Oct 30, 2018
@harawata harawata added this to the 3.5.0 milestone Oct 30, 2018
@harawata
Copy link
Member

I have just committed the fix.
Thank you! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
Development

No branches or pull requests

2 participants