> Further findings and queries on SelectResults:
>
> 1. Is SelectResults still needed in certain situations:
>
> a. Observed that SelectResults was having a count() method. If we
> don't use SelectResults, either we have to query the database for
> getting the count manually, or use len(list). Using 'len' may not be
> recommended in paginated data grids.
>
> b. Seeing the TurboGears code for 'paginate', it checks for the type
> of variable. If it is a list, it just applies len(list)! Does that
> mean, we have to explicitly use SelectResults with TurboGears?
>
> 2. SelectResults not behaving properly:
>
> I have some code which returns a list although I expect a
> SelectResults. Here is the minimal version reproducing that. Can't
> guess whether I am doing something wrong or it's a bug. Need help.
>
> from sqlalchemy import *
> from sqlalchemy.ext.assignmapper import assign_mapper
> from sqlalchemy.ext.sessioncontext import SessionContext
> import sqlalchemy.mods.selectresults
>
> context = SessionContext(create_session)
> session = context.current
>
> metadata = BoundMetaData('sqlite:///satest', echo=True)
>
> # table definitions
> person_table = Table('person', metadata,
>     Column('person_id', Integer, primary_key=True, autoincrement =
> True),
>     Column('first_name', Unicode(30)),
>     Column('last_name', Unicode(30)))
>
> metadata.drop_all()
> metadata.create_all()
>
> class Person(object):
>     pass
>
> assign_mapper(context, Person, person_table)
>
> p1 = Person(first_name="Sanjay", last_name="Patel")
> p2 = Person(first_name="Ranjan", last_name="Naik")
> session.flush()
> del p1
> del p2
> session.clear()
> # persons = Person.select_by(person_id=1)
> # assert isinstance(persons,
> sqlalchemy.ext.selectresults.SelectResults) # OK
> persons = Person.select(Person.c.person_id.in_(1))
> assert isinstance(persons, sqlalchemy.ext.selectresults.SelectResults)
> # Fails!

Hi Michael,

The post being too long probably was not that clear to draw your
attention. In summary, it tries to justify the need of SelectResults
still in certain situations. Also, it tries to point out what seems
like a bug in SelectResults. Would need your comments & help on this.

thanks
Sanjay


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to