#19416 closed Bug (fixed)
Multi-line statements broken in custom SQL
Reported by: | Aymeric Augustin | Owned by: | Claude Paroz |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.5-beta-1 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
After upgrading to Django 1.5 alpha, custom SQL files containing multi-line statements aren't loaded any longer.
I get the following error:
Failed to install custom SQL for sessions.Session model: syntax error at or near "sessions_session" LINE 1: ...E INDEX unique_active_session_user_idON sessions_s...
This regression was introduced in 423244bc6b670abc2b7d6896add5c1baf0b4ef2a.
The problem lies in the _split_statements
added by this commit. It strips whitespace and joins consecutive lines without keeping a space:
>>> multi_line_sql = """ ... CREATE UNIQUE INDEX unique_active_session_user_id ... ON sessions_session(user_id) ... WHERE closed_at IS NULL; ... """ >>> from django.core.management.sql import _split_statements >>> _split_statements(multi_line_sql) [u'CREATE UNIQUE INDEX unique_active_session_user_idON sessions_session(user_id)WHERE closed_at IS NULL;']
Attachments (1)
Change History (4)
comment:1 by , 12 years ago
Owner: | changed from | to
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 12 years ago
Attachment: | 19416-1.diff added |
---|
comment:2 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
In 5fa5621f574f9ae211ed756c3e2ad453470dae8a: