Opened 11 years ago

Closed 11 years ago

#11165 closed (invalid)

Data gets truncated when saved

Reported by: neoel Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I am working on a system to index my music library, and I think I stumbled on a bug.
When a query gets formed quote marks are not entered in the query. here is a piece of code where I believe the problem lies.
Below is the complete code.

The query is formed with this code:

INSERT INTO shoutcast_song (path, title) VALUES (%s, %s)

the data is entered at the values but no quotation marks are found.
I believe the code should be like this:

INSERT INTO shoutcast_song (path, title) VALUES ('%s', '%s')

/var/lib/python-support/python2.5/django/db/models/sql/ in execute_sql

  1. except EmptyResultSet:
  2. if result_type == MULTI:
  3. return empty_iter()
  4. else:
  5. return


  1. cursor = self.connection.cursor()
  1. cursor.execute(sql, params) ...


  1. if not result_type:
  2. return cursor
  3. if result_type == SINGLE:
  4. if self.ordering_aliases:
  5. return cursor.fetchone()[:-len(results.ordering_aliases)]

▼ Local vars
Variable Value
<django.db.backends.util.CursorDebugWrapper object at 0x99fb2ac>
("/files/Music/Q/Queens of the Stone Age - Songs For The Deaf/Queens Of The Stone Age - Era Vulgaris/Queens of the Stone Age - Queens Of The Stone Age/Queens of the Stone Age - Lullabies To Paralyze/Queens Of The Stone Age/Queens Of The Stone Age - Rated R/Queens Of The Stone Age - Songs For The Deaf [Europe]Queens Of The Stone Age - 01 - You Think I Ain't Worth A Dollar, But I Feel Like A Millionaire.mp3", "Queens Of The Stone Age - 01 - You Think I Ain't Worth A Dollar, But I Feel Like A Millionaire.mp3")
<django.db.models.sql.subqueries.InsertQuery object at 0x99fb18c>
'INSERT INTO shoutcast_song (path, title) VALUES (%s, %s)'

Change History (1)

comment:1 Changed 11 years ago by Russell Keith-Magee

Resolution: invalid
Status: newclosed

Django uses the Python DBAPI interface to submit queries, and that API handles the quoting and argument substitution. You don't need to put the quotes into the template SQL itself.

I'm going to guess this is a problem with usage, rather than a fundamental problem with Django DB interface. If you need help diagnosing your problem, I suggest asking on Django-users with a repeatable example.

Note: See TracTickets for help on using tickets.
Back to Top