You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by 이기동 <br...@3rsoft.com> on 2001/04/25 03:24:51 UTC

Bug in FluxUserList

I'm implementing search in FluxUserList. 
But, there exists a bug in query.

I add this code at getUsers() method in FluxUserList.java.
criteria.add("LOGIN_NAME", (Object)("%"+searchKeyWord+"%"), Criteria.LIKE);

When a search query is submitted, mysql writes the following log.

010425 10:13:33     646 Query      SELECT TURBINE_USER.USER_ID, TURBINE_USER.LOGIN_NAME, TURBINE_USER.PASSWORD_VALUE, TURBINE_USER.FIRST_NAME, TURBINE_USER.LAST_NAME, TURBINE_USER.EMAIL, TURBINE_USER.CONFIRM_VALUE, TURBINE_USER.MODIFIED, TURBINE_USER.CREATED, TURBINE_USER.LAST_LOGIN, TURBINE_USER.OBJECTDATA FROM TURBINE_USER WHERE (TURBINE_USER.LOGIN_NAME='%t%')

I think (TURBINE_USER.LOGIN_NAME='%t%') should be (TURBINE_USER.LOGIN_NAME LIKE '%t%'), is it correct?

Re: TurbineSecurity.getUsers() & Criteria.LIKE (was Re: Bug in FluxUserList)

Posted by Eric Dobbs <er...@dobbse.net>.
Well I found a bug in DBUserManager.java and submitted a patch to
turbine-dev.

-Eric

On Wednesday, April 25, 2001, at 05:14  PM, Eric Dobbs wrote:
> Here's the relevant code:
> if (!search.equalsIgnoreCase(""))
> {
>         
> criteria.add(User.USERNAME,(Object)("%"+search+"%"),Criteria.LIKE);
>         Log.debug("UserManagerTool.java: criteria: "+criteria);
> }
>
> try
> {
>         users = TurbineSecurity.getUsers(criteria);
> }
> catch (DataBackendException e)
> {
>         Log.error("UserManagerTool.java:"
>                   + " DataBackendException"
>                   + " unable to getUsers(): " + e);
> }
>
>
> Here' the results in the turbine.log (wrapped for readability)
>
> [Wed Apr 25 16:51:06 MDT 2001] -- DEBUG -- UserManagerTool.java:
> criteria: Criteria:: LOGIN_NAME<=>(.LOGIN_NAME LIKE '%urb%'):
> Current SQL: SELECT  FROM  WHERE (.LOGIN_NAME LIKE '%urb%')
> [Wed Apr 25 16:51:06 MDT 2001] -- DEBUG -- BasePeer.querySql=
> SELECT
>   TURBINE_USER.USER_ID, TURBINE_USER.LOGIN_NAME,
>   TURBINE_USER.PASSWORD_VALUE, TURBINE_USER.FIRST_NAME,
>   TURBINE_USER.LAST_NAME, TURBINE_USER.EMAIL,
>   TURBINE_USER.CONFIRM_VALUE, TURBINE_USER.MODIFIED,
>   TURBINE_USER.CREATED, TURBINE_USER.LAST_LOGIN,
>   TURBINE_USER.OBJECTDATA
> FROM TURBINE_USER
> WHERE (TURBINE_USER.LOGIN_NAME='%urb%')
>
> As you can see, the debug output of the criteria looks okay immediately
> before handing it to TurbineSecurity.getUsers().
>
> Monday, I spent a long time trying to trace through the code to see 
> where
> the problem was.  But the last time I spent several hours hunting for
> bugs in turbine it turned out I was using the wrong constant.
>
> I noticed that DBUserManager builds a new criteria object that it hands
> to TurbineUserPeer.doSelect().  Looking at that code, I can't see why
> it would be causing the problem -- it seems to be just modifying the 
> keys
> in the Criteria object.  That's about where I stopped looking.  Should I
> continue, or have I missed another constant?  8^)

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


TurbineSecurity.getUsers() & Criteria.LIKE (was Re: Bug in FluxUserList)

Posted by Eric Dobbs <er...@dobbse.net>.
I've been fighting something similar this week.  Details below...

On Tuesday, April 24, 2001, at 08:06  PM, Daniel Rall wrote:

> =?ks_c_5601-1987?B?wMyx4rW/?= <br...@3rsoft.com> writes:
>
>> I'm implementing search in FluxUserList.
>> But, there exists a bug in query.
>>
>> I add this code at getUsers() method in FluxUserList.java.
>> criteria.add("LOGIN_NAME", (Object)("%"+searchKeyWord+"%"), 
>> Criteria.LIKE);
>>
>> When a search query is submitted, mysql writes the following log.
>>
>> 010425 10:13:33     646 Query      SELECT TURBINE_USER.USER_ID, 
>> TURBINE_USER.LOGIN_NAME, TURBINE_USER.PASSWORD_VALUE, 
>> TURBINE_USER.FIRST_NAME, TURBINE_USER.LAST_NAME, TURBINE_USER.EMAIL, 
>> TURBINE_USER.CONFIRM_VALUE, TURBINE_USER.MODIFIED, 
>> TURBINE_USER.CREATED, TURBINE_USER.LAST_LOGIN, TURBINE_USER.OBJECTDATA 
>> FROM TURBINE_USER WHERE (TURBINE_USER.LOGIN_NAME='%t%')
>> I think (TURBINE_USER.LOGIN_NAME='%t%') should be 
>> (TURBINE_USER.LOGIN_NAME LIKE '%t%'), is it correct?
>
> It should be using LIKE.  You could put some Log.debug() statements in
> Criteria.add(String, Object, String) to make sure the right code is
> getting excercised.


Here's the relevant code:
if (!search.equalsIgnoreCase(""))
{
         
criteria.add(User.USERNAME,(Object)("%"+search+"%"),Criteria.LIKE);
         Log.debug("UserManagerTool.java: criteria: "+criteria);
}

try
{
         users = TurbineSecurity.getUsers(criteria);
}
catch (DataBackendException e)
{
         Log.error("UserManagerTool.java:"
                   + " DataBackendException"
                   + " unable to getUsers(): " + e);
}


Here' the results in the turbine.log (wrapped for readability)

[Wed Apr 25 16:51:06 MDT 2001] -- DEBUG -- UserManagerTool.java:
criteria: Criteria:: LOGIN_NAME<=>(.LOGIN_NAME LIKE '%urb%'):
Current SQL: SELECT  FROM  WHERE (.LOGIN_NAME LIKE '%urb%')
[Wed Apr 25 16:51:06 MDT 2001] -- DEBUG -- BasePeer.querySql=
SELECT
   TURBINE_USER.USER_ID, TURBINE_USER.LOGIN_NAME,
   TURBINE_USER.PASSWORD_VALUE, TURBINE_USER.FIRST_NAME,
   TURBINE_USER.LAST_NAME, TURBINE_USER.EMAIL,
   TURBINE_USER.CONFIRM_VALUE, TURBINE_USER.MODIFIED,
   TURBINE_USER.CREATED, TURBINE_USER.LAST_LOGIN,
   TURBINE_USER.OBJECTDATA
FROM TURBINE_USER
WHERE (TURBINE_USER.LOGIN_NAME='%urb%')

As you can see, the debug output of the criteria looks okay immediately
before handing it to TurbineSecurity.getUsers().

Monday, I spent a long time trying to trace through the code to see where
the problem was.  But the last time I spent several hours hunting for
bugs in turbine it turned out I was using the wrong constant.

I noticed that DBUserManager builds a new criteria object that it hands
to TurbineUserPeer.doSelect().  Looking at that code, I can't see why
it would be causing the problem -- it seems to be just modifying the keys
in the Criteria object.  That's about where I stopped looking.  Should I
continue, or have I missed another constant?  8^)

-Eric

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Bug in FluxUserList

Posted by Daniel Rall <dl...@finemaltcoding.com>.
=?ks_c_5601-1987?B?wMyx4rW/?= <br...@3rsoft.com> writes:

> I'm implementing search in FluxUserList. 
> But, there exists a bug in query.
> 
> I add this code at getUsers() method in FluxUserList.java.
> criteria.add("LOGIN_NAME", (Object)("%"+searchKeyWord+"%"), Criteria.LIKE);
> 
> When a search query is submitted, mysql writes the following log.
> 
> 010425 10:13:33     646 Query      SELECT TURBINE_USER.USER_ID, TURBINE_USER.LOGIN_NAME, TURBINE_USER.PASSWORD_VALUE, TURBINE_USER.FIRST_NAME, TURBINE_USER.LAST_NAME, TURBINE_USER.EMAIL, TURBINE_USER.CONFIRM_VALUE, TURBINE_USER.MODIFIED, TURBINE_USER.CREATED, TURBINE_USER.LAST_LOGIN, TURBINE_USER.OBJECTDATA FROM TURBINE_USER WHERE (TURBINE_USER.LOGIN_NAME='%t%')
> I think (TURBINE_USER.LOGIN_NAME='%t%') should be (TURBINE_USER.LOGIN_NAME LIKE '%t%'), is it correct?

It should be using LIKE.  You could put some Log.debug() statements in
Criteria.add(String, Object, String) to make sure the right code is
getting excercised.

Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org