Changeset 8133
- Timestamp:
- 07/29/08 00:53:44 (4 months ago)
- Files:
-
- django/trunk/django/core/management/commands/sqlcustom.py (modified) (1 diff)
- django/trunk/django/core/management/commands/syncdb.py (modified) (1 diff)
- django/trunk/django/core/management/sql.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/commands/sqlcustom.py
r7706 r8133 8 8 def handle_app(self, app, **options): 9 9 from django.core.management.sql import sql_custom 10 return u'\n'.join(sql_custom(app )).encode('utf-8')10 return u'\n'.join(sql_custom(app, self.style)).encode('utf-8') django/trunk/django/core/management/commands/syncdb.py
r7891 r8133 117 117 for model in models.get_models(app): 118 118 if model in created_models: 119 custom_sql = custom_sql_for_model(model )119 custom_sql = custom_sql_for_model(model, self.style) 120 120 if custom_sql: 121 121 if verbosity >= 1: django/trunk/django/core/management/sql.py
r7790 r8133 220 220 return statements 221 221 222 def sql_custom(app ):222 def sql_custom(app, style): 223 223 "Returns a list of the custom table modifying SQL statements for the given app." 224 224 from django.db.models import get_models … … 229 229 230 230 for model in app_models: 231 output.extend(custom_sql_for_model(model ))231 output.extend(custom_sql_for_model(model, style)) 232 232 233 233 return output … … 243 243 def sql_all(app, style): 244 244 "Returns a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module." 245 return sql_create(app, style) + sql_custom(app ) + sql_indexes(app, style)245 return sql_create(app, style) + sql_custom(app, style) + sql_indexes(app, style) 246 246 247 247 def sql_model_create(model, style, known_models=set()): … … 427 427 return final_output 428 428 429 def custom_sql_for_model(model ):429 def custom_sql_for_model(model, style): 430 430 from django.db import models 431 431 from django.conf import settings … … 434 434 app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), 'sql')) 435 435 output = [] 436 437 # Post-creation SQL should come before any initial SQL data is loaded. 438 # However, this should not be done for fields that are part of a a parent 439 # model (via model inheritance). 440 nm = opts.init_name_map() 441 post_sql_fields = [f for f in opts.local_fields if hasattr(f, 'post_create_sql')] 442 for f in post_sql_fields: 443 output.extend(f.post_create_sql(style, model._meta.db_table)) 436 444 437 445 # Some backends can't execute more than one SQL statement at a time,
