Opened 15 years ago
Closed 15 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 |
Description
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/query.py in execute_sql
- except EmptyResultSet:
- if result_type == MULTI:
- return empty_iter()
- else:
- return
1732.
- cursor = self.connection.cursor()
- cursor.execute(sql, params) ...
1735.
- if not result_type:
- return cursor
- if result_type == SINGLE:
- if self.ordering_aliases:
- return cursor.fetchone()[:-len(results.ordering_aliases)]
▼ Local vars
Variable Value
cursor
<django.db.backends.util.CursorDebugWrapper object at 0x99fb2ac>
params
("/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")
result_type
None
self
<django.db.models.sql.subqueries.InsertQuery object at 0x99fb18c>
sql
'INSERT INTO shoutcast_song
(path
, title
) VALUES (%s, %s)'
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.