Ticket #13656: django-management-dbs.diff

File django-management-dbs.diff, 1.6 KB (added by Alex, 5 years ago)
  • django/core/management/base.py

    diff --git a/django/core/management/base.py b/django/core/management/base.py
    index 4016faa..4afe500 100644
    a b class BaseCommand(object): 
    219219            if output:
    220220                if self.output_transaction:
    221221                    # This needs to be imported here, because it relies on settings.
    222                     from django.db import connection
     222                    from django.db import connections
     223                    connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
    223224                    if connection.ops.start_transaction_sql():
    224225                        print self.style.SQL_KEYWORD(connection.ops.start_transaction_sql())
    225226                print output
    226227                if self.output_transaction:
    227                     print self.style.SQL_KEYWORD("COMMIT;")
     228                    print self.style.SQL_KEYWORD(connection.ops.end_transaction_sql())
    228229        except CommandError, e:
    229230            sys.stderr.write(smart_str(self.style.ERROR('Error: %s\n' % e)))
    230231            sys.exit(1)
  • django/db/backends/__init__.py

    diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
    index 5918935..a823503 100644
    a b class BaseDatabaseOperations(object): 
    352352        Returns the SQL statement required to start a transaction.
    353353        """
    354354        return "BEGIN;"
     355   
     356    def end_transaction_sql(self, fails=False):
     357        if fails:
     358            return "ROLLBACK;"
     359        return "COMMIT;"
    355360
    356361    def tablespace_sql(self, tablespace, inline=False):
    357362        """
Back to Top