Ticket #1935: django.core.management.diff
File django.core.management.diff, 1.5 KB (added by , 18 years ago) |
---|
-
django/core/management.py
328 328 app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), 'sql')) 329 329 output = [] 330 330 331 # Find custom SQL, if it's available. 331 sql_expr = re.compile( 332 r"""( # each statement is... 333 (?: # one or more chunks of ... 334 (?:[^;'"]+) # not the end of a statement or start of a quote 335 | (?:'[^']+') # something in single quotes 336 | (?:"[^"]+") # something in double quotes 337 )+)""", re.VERBOSE) 338 339 # Find custom SQL, if it's available. 332 340 sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), settings.DATABASE_ENGINE)), 333 341 os.path.join(app_dir, "%s.sql" % opts.object_name.lower())] 334 342 for sql_file in sql_files: 335 343 if os.path.exists(sql_file): 336 344 fp = open(sql_file) 337 output.append(fp.read())345 sql = fp.read() 338 346 fp.close() 347 if ';' in sql: 348 # some backends can't execute more than one statement at a time 349 statements = sql_expr.findall(sql) 350 if statements: 351 output.extend(statements) 352 continue 353 output.append(sql) 339 354 355 340 356 return output 341 357 342 358 def get_sql_initial_data(app):