On 11/18/05, Alan Franzoni <alan.franzoni.xyz@gmail.com> wrote:
"Jonathan Hayward http://JonathansCorner.com" on
gmane.comp.python.sqlobject said:

> database_matches_to_list creates a list of row objects, and is always
> returning 0 results (I created documents containing the word "test",
> and then searched for "test").

I'm a bit tricked by all your code (it's kind of hard to read), couldn't
you write a stripped-down version (less lines, less functions) sharing the
same issue?

I can't do that right now because my computer is in the middle of the upgrade. But there is a specific part I think I can excerpt:

database_document extends SQLObject and adds text and datetime columns. query and to_order_by have been built up. There is something specific that surprises me in this code:

       database_matches = database_document.select(query, orderBy = \
          to_order_by)
        debug_log("Raw search results: " + str(database_matches))
        result = database_matches_to_list(database_matches)


I want database_matches to have the database_document rows matching query and ordered by to_order_by. The debug_log says that database_matches is a string:

Raw search results: SELECT database_document.id, database_document.date_last_modified, database_document.date_last_viewed, database_document.field_permanent_id, database_document.field_text, database_document.field_title, database_document.field_version, database_document.relative_filename, database_document.section, database_document.text, database_document.tokenized FROM database_document WHERE EXISTS (SELECT database_document_keyword.id FROM database_document, database_document_keyword WHERE ((database_document.id = database_document_keyword.document_id) AND (database_document_keyword.word = 'test'))) ORDER BY database_document.date_last_viewed at 1132326661.36

What I'd like to know is what how to take what's in database_matches now, and execute the query so that I can access results.get(0), results.get(1).

If a stripped-down version would help, I can probably get to work on that, but what's puzzling me now is that database_matches is assigned a SQL statement instead of being a result set. How do I get a result set now that I have the query I want?

Thanks,

Also... I can't understand what you mean: Are you getting an empty list? Or
does list index 0 (at least) contain anything? And have you tried fetching
actual results from the DB before checking debug output?

--
Alan Franzoni <alan.franzoni.xyz@gmail.com >
--
Togli .xyz dalla mia email per contattarmi
Remove .xyz from my email in order to contact me.



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss



--
++ Jonathan Hayward, jonathan.hayward@pobox.com
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com

** If you'd like a Google Mail ( gmail.com) account, please tell me!