diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2011-09-10 22:02:13 +0000 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2011-09-10 22:02:13 +0000 |
| commit | 807b2a8216cbb8bfc82a2dc3d57fe2169f3349e4 (patch) | |
| tree | 095c4854e3baca2f16622601492c55c74844d90b | |
| parent | b45a4acf6f29025f28baf524809f34a14b7ccde7 (diff) | |
Fixed bulk_insertion on databases which don't yet support it. Thanks to Justin Bronn for his Oracle wizardry.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16793 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/db/models/sql/compiler.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index b8bba4b013..9ddcfc63f9 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -814,7 +814,8 @@ class SQLInsertCompiler(SQLCompiler): values = [[self.connection.ops.pk_default_value()] for obj in self.query.objs] params = [[]] fields = [None] - can_bulk = not any(hasattr(field, "get_placeholder") for field in fields) and not self.return_id + can_bulk = (not any(hasattr(field, "get_placeholder") for field in fields) and + not self.return_id and self.connection.features.has_bulk_insert) if can_bulk: placeholders = [["%s"] * len(fields)] @@ -831,7 +832,7 @@ class SQLInsertCompiler(SQLCompiler): result.append(r_fmt % col) params += r_params return [(" ".join(result), tuple(params))] - if can_bulk and self.connection.features.has_bulk_insert: + if can_bulk: result.append(self.connection.ops.bulk_insert_sql(fields, len(values))) return [(" ".join(result), tuple([v for val in values for v in val]))] else: |
