#3214: [patch] raw sql file doesn't recognize quotes correctly ---------------------------------------------------+------------------------ Reporter: shaunc <sh...@cuttshome.net> | Owner: nobody Status: reopened | Milestone: Component: Database layer (models, ORM) | Version: SVN Resolution: | Keywords: rawsql Stage: Accepted | Has_patch: 1 Needs_docs: 0 | Needs_tests: 1 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by wdoekes):
* cc: walter+dja...@wjd.nu (added) Comment: > As a workaround, multi-line SQL statements have to have someting other than whitespace between their semicolons and newline characters. For example: {{{ > CREATE OR REPLACE FUNCTION create_post () RETURNS trigger AS $$ > BEGIN > NEW.date_created := current_timestamp; -- > RETURN NEW; -- > END; > $$ LANGUAGE plpgsql; }}} Is that a bug or a feature? I was about to file this patch because I was getting quite puzzling "Command out of sync error"s because I had a bit of comment after a statement: {{{ --- django/core/management/sql.py.orig 2010-02-25 12:32:04.660976707 +0100 +++ django/core/management/sql.py 2010-02-25 12:38:06.240954572 +0100 @@ -174,7 +174,7 @@ # Some backends can't execute more than one SQL statement at a time, # so split into separate statements. - statements = re.compile(r";[ \t]*$", re.M) + statements = re.compile(r";[ \t]*(?:--.*)?$", re.M) # Find custom SQL, if it's available. sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), settings.DATABASE_ENGINE)), }}} But that fix will break your feature. -- Ticket URL: <http://code.djangoproject.com/ticket/3214#comment:21> Django <http://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-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.