[sqlalchemy] Re: Query objects and empty slices

2008-05-11 Thread Yannick Gingras

Michael Bayer [EMAIL PROTECTED] writes:

 yes.  but the question was, limit is ignored when offset is zero,
 which is not the issue.  LIMIT is ignored when its zero, period (it
 evaluates to false).  the decision to be made is, should Query
 circumvent querying altogether when limit is zero.  this will be
 easy to fix in 0.5 since slices will no longer be generative, so
 we'll just return an empty iterator.  ticket 1035 in trac.

Sounds good.  Keep up the good work.

-- 
Yannick Gingras

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Query objects and empty slices

2008-05-10 Thread Michael Bayer


On May 10, 2008, at 10:22 AM, Yannick Gingras wrote:

 I attach a test case.  In here, it prints:

 --
 ** q[:0]
 SELECT users.id AS users_id, users.name AS users_name
 FROM users ORDER BY users.id


 ** q[0:0]
 SELECT users.id AS users_id, users.name AS users_name
 FROM users ORDER BY users.id


 ** q[1:1]
 SELECT users.id AS users_id, users.name AS users_name
 FROM users ORDER BY users.id
 LIMIT 0 OFFSET 1


 ** q[0:10]
 SELECT users.id AS users_id, users.name AS users_name
 FROM users ORDER BY users.id
 LIMIT 10 OFFSET 0
 --

 Shouldn't the first two feature  LIMIT 0 OFFSET 1?

yes.  but the question was, limit is ignored when offset is zero,  
which is not the issue.  LIMIT is ignored when its zero, period (it  
evaluates to false).  the decision to be made is, should Query  
circumvent querying altogether when limit is zero.   this will be easy  
to fix in 0.5 since slices will no longer be generative, so we'll just  
return an empty iterator.  ticket 1035 in trac.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Query objects and empty slices

2008-05-02 Thread Michael Bayer


On May 2, 2008, at 6:33 AM, Yannick Gingras wrote:

 My guess is that the underlying Select object does not take limit
 into account when offset is 0.

you mean, a limit of zero itself is ignored.  an offset of zero  
doesn't affect limit.

 You will all agree that this is a bug and that it needs to be fixed.
 I don't mind digging into the sources to fix it.  Can anyone point me
 in the right direction?

if the limit is zero Id imagine that no SQL would be issued at all.   
do you agree ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Query objects and empty slices

2008-05-02 Thread Yannick Gingras

Michael Bayer [EMAIL PROTECTED] writes:

 My guess is that the underlying Select object does not take limit
 into account when offset is 0.

 you mean, a limit of zero itself is ignored.  an offset of zero  
 doesn't affect limit.

When _offset is 0 or None, _limit seems to be ignored.  There might be
something else but I see:

 print q[:0] # no limit statement in the SQL
 print q[0:0] # no limit statement in the SQL
 print q[1:1] # limit statement is there

 You will all agree that this is a bug and that it needs to be fixed.
 I don't mind digging into the sources to fix it.  Can anyone point me
 in the right direction?

 if the limit is zero Id imagine that no SQL would be issued at all.   
 do you agree ?

That's one way to see it and it would make sense.  However, issuing
the query anyway validates that aside from returning nothing, all the
selected tables are there.  My preference goes for returning an empty
list without emitting SQL.

-- 
Yannick Gingras

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Query objects and empty slices

2008-05-02 Thread Michael Bayer


On May 2, 2008, at 10:52 AM, Yannick Gingras wrote:

 When _offset is 0 or None, _limit seems to be ignored.  There might be
 something else but I see:

 print q[:0] # no limit statement in the SQL
 print q[0:0] # no limit statement in the SQL
 print q[1:1] # limit statement is there

the first two have a LIMIT of zero.  Did you try:

print q[0:10] ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---