[ http://issues.apache.org/jira/browse/IBATIS-95?page=comments#action_61659 ] Erlend Bj�rge commented on IBATIS-95: -------------------------------------
Hi there Leonardo! I'm agree that maybe this is not a new improvment, more like a bug fix for some missing functionality when you have dynamic prepend + ( ). The smart guys should decide which group it should be placed :-) -- >There is another problem with Erlend suggestion. If all parameters >are null the produced result will be for example: >SELECT * WHERE USER_ID = ? AND ( ) AND DATE > ? --- Have seen this problem, that's why I specified: <isParameterPresent> </isParameterPresent> My intention with this check, it checks for the input parameter that is present .... if so I'm sure one of the OR's has a valid value e.g. When you need for several ( ) ... you need a different strategy. To make it even more simple, maybe add a dynamic paranthesis tag to, don't display the ( ) if it's empty ?? --- Of course dynamic prepend should be able to handle OR|AND with ( ) but I guess it's more complicated to find out if the where clause have this situation and do something about it ??? ... adding this new tag e.g. you may have a simple solution for this "problem". More later! Erlend Bj�rge > Removal of extra OR/AND with parantheses ( ) with dynamic prepend! > ------------------------------------------------------------------ > > Key: IBATIS-95 > URL: http://issues.apache.org/jira/browse/IBATIS-95 > Project: iBatis for Java > Type: Improvement > Components: SQL Maps > Environment: Not a issue. > Reporter: Erlend Bj�rge > > Hi there! > I have run into the same kind of problem as Brandon Goodin replied on: > http://www.mail-archive.com/[email protected]/msg01403.html > The problem is not just related to complex queries, but dealing with Dynamic > prepend > and parantheses, you will end up with a extra OR/AND you don't need in you > query. > Simple as that. > If you would have made the where clause by yourself, the simple solution is > after you are finished with your (OR .... OR ... OR) clause, just remove the > first OR/AND after ( and then your clause is correct. This is a simple > solution, > shouldn't it be possible with be possible with SQLMap tags too ?? > What about a new tag like ? (Hope this come out with correct linefeed :-) > where clause bla bla .... > <isParameterPresent> > AND ( > <removeFirstPrependValue> > <isNotNull prepend="OR".....> > <isNotNull prepend="OR" ...> > <isNotNull prepend="OR" ...> > </removeFirstPrependValue> > ) > <isParameterPresent> > Or similar function in the other tags like this as an extra parameter: > where clause bla bla .... > <isParameterPresent> > AND ( > > <isNotNull prepend="OR" property="id" removeFirstPrepend="true"> > <isNotNull prepend="OR" property="name" removeFirstPrepend="true"> > ) > <isParameterPresent> > ??? Isn't that a nice new feature that will remove this kind of problem ? > --- > Thanks! > Best regards, > Erlend Bj�rge -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira
