#19416: Multi-line statements broken in custom SQL
----------------------------------------------+------------------------
     Reporter:  aaugustin                     |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.5-beta-1
     Severity:  Release blocker               |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+------------------------
 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;']
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19416>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to