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

Dynamic SQL: choose/when/otherwise only valid in a single line #4

Open
erysavy opened this issue Jan 12, 2014 · 8 comments
Open

Dynamic SQL: choose/when/otherwise only valid in a single line #4

erysavy opened this issue Jan 12, 2014 · 8 comments

Comments

@erysavy
Copy link

erysavy commented Jan 12, 2014

When including a conditional expression to create dynamic SQL using "choose" and enclosed "when" and "otherwise" tags, a Scala MatchError is thrown if there is any whitespace between the tags.
E.g. this works ok:

<choose><when test="sometest">xx</when><otherwise>yy</otherwise></choose>

but this doesn't and throws a MatchError in line 74 of DynamicSQLBuilder.scala:

<choose>
   <when test="sometest">xx</when>
   <otherwise>yy</otherwise>
</choose>
@mnesarco
Copy link
Member

Hi Erysavy,

Sounds like an already fixed bug. What version of mybatis-scala are you
using?

Frank.

On Sat, Jan 11, 2014 at 9:44 PM, erysavy notifications@github.com wrote:

When including a conditional expression to create dynamic SQL using
"choose" and enclosed "when" and "otherwise" tags, a Scala MatchError is
thrown if there is any whitespace between the tags.
E.g. this works ok:

xxyy

but this doesn't and throws a MatchError in line 74 of
DynamicSQLBuilder.scala:

xx yy


Reply to this email directly or view it on GitHubhttps://github.com//issues/4
.

Frank D. Martínez M.

@erysavy
Copy link
Author

erysavy commented Jan 12, 2014

Hi Frank,

I'm using the latest version in the maven repository: mybatis-scala-core_2.10
version 1.0.1.

I have checked this source version on code.google.com (trunk revision 5726): http://code.google.com/p/mybatis/source/browse/sub-projects/scala/trunk/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/DynamicSQLBuilder.scala?r=5726#70 (lines 73 ... 87),
there seems to be the same problem as far as I understand the code: in the
loop inside the "choose" case only "when" and "otherwise" are matched, but no
Atom like in the outer match block, therefore if there's any whitespace
between e.g. the choose tag and the following when tag, there's no matching
case block.

Regards,
Eduard.

Am Sonntag, 12. Januar 2014, 04:57:23 schrieb Frank David Martínez M:

Hi Erysavy,

Sounds like an already fixed bug. What version of mybatis-scala are you
using?

Frank.

On Sat, Jan 11, 2014 at 9:44 PM, erysavy notifications@github.com wrote:

When including a conditional expression to create dynamic SQL using
"choose" and enclosed "when" and "otherwise" tags, a Scala MatchError is
thrown if there is any whitespace between the tags.
E.g. this works ok:

xxyy

but this doesn't and throws a MatchError in line 74 of
DynamicSQLBuilder.scala:

xx
yy


Reply to this email directly or view it on
GitHubhttps://github.com//issues/4 .

@mnesarco
Copy link
Member

Hi Eyal,

If you are using google code version, you are with an old version. We moved
the code to github more than a year ago. Can you try the github version
please?

https://github.com/mybatis/scala

Cheers,

Frank.

On Sun, Jan 12, 2014 at 10:11 AM, erysavy notifications@github.com wrote:

Hi Frank,

I'm using the latest version in the maven repository:
mybatis-scala-core_2.10
version 1.0.1.

I have checked this source version on code.google.com (trunk revision
5726),
there seems to be the same problem as far as I understand the code: in the
loop inside the "choose" case only "when" and "otherwise" are matched, but
no
Atom like in the outer match block, therefore if there's any whitespace
between e.g. the choose tag and the following when tag, there's no
matching
case block.

Regards,
Eduard.

Am Sonntag, 12. Januar 2014, 04:57:23 schrieb Frank David Martínez M:

Hi Erysavy,

Sounds like an already fixed bug. What version of mybatis-scala are you
using?

Frank.

On Sat, Jan 11, 2014 at 9:44 PM, erysavy notifications@github.com
wrote:

When including a conditional expression to create dynamic SQL using
"choose" and enclosed "when" and "otherwise" tags, a Scala MatchError
is
thrown if there is any whitespace between the tags.
E.g. this works ok:

xxyy

but this doesn't and throws a MatchError in line 74 of
DynamicSQLBuilder.scala:

xx
yy


Reply to this email directly or view it on
GitHubhttps://github.com//issues/4 .


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-32124573
.

Frank D. Martínez M.

@mnesarco
Copy link
Member

Hi Erysavy,

I have confused your name (I am so sorry).

The problem was fixed two months ago in github.

9f61f88#diff-15fce1edb26e4a4e020f124daeac7f7c

Can you try the unreleased github version?

Cheers,

Frank.

On Sun, Jan 12, 2014 at 11:19 AM, Frank Martínez mnesarco@gmail.com wrote:

Hi Eyal,

If you are using google code version, you are with an old version. We
moved the code to github more than a year ago. Can you try the github
version please?

https://github.com/mybatis/scala

Cheers,

Frank.

On Sun, Jan 12, 2014 at 10:11 AM, erysavy notifications@github.comwrote:

Hi Frank,

I'm using the latest version in the maven repository:
mybatis-scala-core_2.10
version 1.0.1.

I have checked this source version on code.google.com (trunk revision
5726),
there seems to be the same problem as far as I understand the code: in
the
loop inside the "choose" case only "when" and "otherwise" are matched,
but no
Atom like in the outer match block, therefore if there's any whitespace
between e.g. the choose tag and the following when tag, there's no
matching
case block.

Regards,
Eduard.

Am Sonntag, 12. Januar 2014, 04:57:23 schrieb Frank David Martínez M:

Hi Erysavy,

Sounds like an already fixed bug. What version of mybatis-scala are you
using?

Frank.

On Sat, Jan 11, 2014 at 9:44 PM, erysavy notifications@github.com
wrote:

When including a conditional expression to create dynamic SQL using
"choose" and enclosed "when" and "otherwise" tags, a Scala MatchError
is
thrown if there is any whitespace between the tags.
E.g. this works ok:

xxyy

but this doesn't and throws a MatchError in line 74 of
DynamicSQLBuilder.scala:

xx
yy


Reply to this email directly or view it on
GitHubhttps://github.com//issues/4 .


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-32124573
.

Frank D. Martínez M.

Frank D. Martínez M.

@erysavy
Copy link
Author

erysavy commented Jan 13, 2014

Hi Frank,

thanks for the hint and sorry for missing this before.
I have tried the github version, works as expected 👍

There's one point with this code, though: it accepts and discards any characters, even XML tags, inside the <choose> element and outside of <when> and <otherwise>. This seems a bit too permissive to me.
Now that we're already talking about it, do you consider it nit-picky suggesting to restrict this to XML whitespace (which consists of either of four characters: http://www.w3.org/TR/xml/#NT-S) and throw an error for everything else?

Best,
Eduard.

@mnesarco
Copy link
Member

Hi Erysavy,

You are right, it was a quick fix and it is too permissive. I will fix in
the next release, the 1.0.2 is scheduled for today and I don't have time to
review it before. So it will be fixed in 1.0.3.

Cheers,

Frank.

On Sun, Jan 12, 2014 at 7:40 PM, erysavy notifications@github.com wrote:

Hi Frank,

thanks for the hint and sorry for missing this before.
I have tried the github version, works as expected [image: 👍]

There's one point with this code, though: it accepts any characters, even
XML tags, inside the element and outside of and
. This seems a bit too permissive to me.
Now that we're already talking about it, do you consider it nit-picky
suggesting to restrict this to XML whitespace (which consists of either of
four characters: http://www.w3.org/TR/xml/#NT-S)?

Best,
Eduard.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-32139577
.

Frank D. Martínez M.

@hazendaz
Copy link
Member

@mnesarco Has this issue been addressed?

@mnesarco
Copy link
Member

Hi Jeremy,

This is not addressed yet. But it is not critical and not blocking.
I think it can be easily fixed, but I can't do it right now.

I hope I will have some spare time soon.

On Sat, Sep 12, 2015 at 2:33 PM, Jeremy Landis notifications@github.com
wrote:

@mnesarco https://github.com/mnesarco Has this issue been addressed?


Reply to this email directly or view it on GitHub
#4 (comment).

Frank D. Martínez M.

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

No branches or pull requests

3 participants