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

Nested prepends only work some of the time #63

Open
GoogleCodeExporter opened this issue Mar 17, 2015 · 2 comments
Open

Nested prepends only work some of the time #63

GoogleCodeExporter opened this issue Mar 17, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

I'm using ibatis-2.3.4.726.jar

I've got nested isNotEquals with prepends (AND)
        <dynamic prepend="WHERE">
            <isEqual property="CategoryType" compareValue="Pattern">
                Category LIKE #Category#
            </isEqual>
            <isNotEqual property="CategoryType" compareValue="Variable">
                <isNotEqual property="CategoryType" compareValue="Pattern">
                    Category = #Category#
                </isNotEqual>
            </isNotEqual>

            <isEqual prepend="AND" property="VRL_OS_Type" compareValue="Pattern">
                VRL_OS LIKE #VRL_OS#
            </isEqual>
            <isNotEqual prepend="AND" property="VRL_OS_Type" compareValue="Variable">
                <isNotEqual property="VRL_OS_Type" compareValue="Pattern">
                    VRL_OS = #VRL_OS#
                </isNotEqual>
            </isNotEqual>

            <isEqual prepend="AND" property="VRL_Test_Name_Type" compareValue="Pattern">
                VRL_Test_Name LIKE #VRL_Test_Name#
            </isEqual>
            <isNotEqual prepend="AND" property="VRL_Test_Name_Type" compareValue="Variable">
                <isNotEqual property="VRL_Test_Name_Type" compareValue="Pattern">
                    VRL_Test_Name = #VRL_Test_Name#
                </isNotEqual>
            </isNotEqual>
        </dynamic>

When all three (CategoryType, VRL_OS_Type, and VRL_Test_Name_Type) are 
"Constant" (i.e not equal to anything in the query), you would expect to get 
SQL like
   WHERE Category = #Category# AND VRL_OS = #VRL_OS# AND VRL_Test_Name = #VRL_Test_Name#
Instead, I'm getting SQL like
   WHERE Category = ? VRL_OS = ? AND VRL_Test_Name = ?

I tried putting the prepend in BOTH the outer and inner nested isNotEquals, 
then I ended up with TWO ANDs.
   WHERE Category = ? AND VRL_OS = ? AND AND VRL_Test_Name = ?

I ended up putting a prepend in BOTH the outer and inner isNotEquals of the 
second section, but only the outer isNotEquals of the third section, and that 
finally generated the desired output.


Original issue reported on code.google.com by sst...@gmail.com on 2 Jul 2010 at 12:46

@GoogleCodeExporter
Copy link
Author

Original comment by eduardo.macarron on 8 Jan 2012 at 6:00

  • Added labels: Version-Release2.x

@GoogleCodeExporter
Copy link
Author

Original comment by eduardo.macarron on 5 Feb 2012 at 1:54

  • Added labels: Component-SqlMaps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant