summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-09-29 23:43:03 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-09-29 23:43:03 +0000
commit998fc72c0d10afb6df3c58aa965540a4e23af431 (patch)
tree48ee9b6b7f8fac93767079eac407a4d09d01b6bd
parent27b1f69d79787af2c2db35b4d2a96784a59d39a7 (diff)
Changed [735] so that database-agnostic SQL always gets executed, even if database-specific SQL doesn't exist.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@737 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/django/core/management.py b/django/core/management.py
index 89ffb80b59..f3accd84cc 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -156,29 +156,23 @@ get_sql_reset.args = APP_ARGS
def get_sql_initial_data(mod):
"Returns a list of the initial INSERT SQL statements for the given module."
+ from django.core import db
output = []
app_label = mod._MODELS[0]._meta.app_label
output.append(_get_packages_insert(app_label))
app_dir = os.path.normpath(os.path.join(os.path.dirname(mod.__file__), '../sql'))
for klass in mod._MODELS:
opts = klass._meta
- # Add custom SQL, if it's available.
- from django.core import db
-
- # Get the sql file name for the init data for the current database engine
- db_engine_sql_file_name = os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE.lower() + '.sql')
- # Check if the data specific file exists
- if os.path.exists(db_engine_sql_file_name):
- sql_file_name = db_engine_sql_file_name
- # if the database specific file doesn't exist, use the database agnostic version
- else:
- sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
+ # Add custom SQL, if it's available.
+ sql_files = [os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE + '.sql'),
+ os.path.join(app_dir, opts.module_name + '.sql')]
+ for sql_file in sql_files:
+ if os.path.exists(sql_file):
+ fp = open(sql_file)
+ output.append(fp.read())
+ fp.close()
- if os.path.exists(sql_file_name):
- fp = open(sql_file_name, 'r')
- output.append(fp.read())
- fp.close()
# Content types.
output.append(_get_contenttype_insert(opts))
# Permissions.
@@ -664,4 +658,4 @@ def createcachetable(tablename):
for statement in index_output:
curs.execute(statement)
db.db.commit()
-createcachetable.args = "[tablename]" \ No newline at end of file
+createcachetable.args = "[tablename]"