On 9/20/05, scottpierce <[EMAIL PROTECTED]> wrote:
> sql_queries shows a query like this:
> SELECT
assignments_assignments.id,assignments_assignments.teacher_id,assignments_assignments.student_id,assignments_assignments.subject_id,assignments_assignments.assignment_title,assignments_assignments.assignment,assignments_assignments.date_assigned,assignments_assignments.due_date,assignments_assignments.date_last_modified,assignments_assignments.complete,assignments_assignments.grade,assignments_assignments.teachers_note,assignments_assignments.students_note
> FROM assignments_assignments WHERE assignments_assignments.grade IS
> NULL AND assignments_assignments.complete = False AND
> assignments_assignments.due_date < 2005-09-20 02:04:59.582205
> 
> In psql this will give an obvious error.  Just to be sure, I also
> executed from a psycopg cursor within a python shell.  It returns an
> error.  If you change the select like so:
> SELECT
> assignments_assignments.id,assignments_assignments.teacher_id,assignments_assignments.student_id,assignments_assignments.subject_id,assignments_assignments.assignment_title,assignments_assignments.assignment,assignments_assignments.date_assigned,assignments_assignments.due_date,assignments_assignments.date_last_modified,assignments_assignments.complete,assignments_assignments.grade,assignments_assignments.teachers_note,assignments_assignments.students_note
> FROM assignments_assignments WHERE assignments_assignments.grade IS
> NULL AND assignments_assignments.complete = False AND
> assignments_assignments.due_date < date'2005-09-20 02:04:59.582205'
> 
> I am hesitant to file a ticket or what have you 'cause I have to
> believe this is working for someone.  It is to glaring and effects to
> many things to have gone unnoticed.  However, I cannot utilize any
> dates in select queries.

I assume you're talking about the "sql_queries" you get when you have
DEBUG=True. If so, you should note that sql_queries does simple string
substitution to display the raw SQL, so you can't always
copy-and-paste the SQL directly into the database client.

Technically, sql_queries gets passed the SQL statement, with "%s"
placeholders, and the values that go into those placeholders.

Do you have a problem with the queries the API runs, or is your only
problem that the query in db_queries doesn't have quotes around the
date? If the former, please post the full exception.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

Reply via email to