Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a SQlite backend. One test passes!

  • Loading branch information...
commit d3d1e599211c31e05d095b878de517dbb6fc998c 1 parent 0b01395
@andrewgodwin andrewgodwin authored
View
5 django/db/backends/sqlite3/base.py
@@ -18,6 +18,7 @@
from django.db.backends.sqlite3.client import DatabaseClient
from django.db.backends.sqlite3.creation import DatabaseCreation
from django.db.backends.sqlite3.introspection import DatabaseIntrospection
+from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.utils.dateparse import parse_date, parse_datetime, parse_time
from django.utils.functional import cached_property
from django.utils.safestring import SafeString
@@ -336,6 +337,10 @@ def close(self):
if self.settings_dict['NAME'] != ":memory:":
BaseDatabaseWrapper.close(self)
+ def schema_editor(self):
+ "Returns a new instance of this backend's SchemaEditor"
+ return DatabaseSchemaEditor(self)
+
FORMAT_QMARK_REGEX = re.compile(r'(?<!%)%s')
class SQLiteCursorWrapper(Database.Cursor):
View
6 django/db/backends/sqlite3/schema.py
@@ -0,0 +1,6 @@
+from django.db.backends.schema import BaseDatabaseSchemaEditor
+
+
+class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
+
+ sql_delete_table = "DROP TABLE %(table)s"
View
12 tests/modeltests/schema/tests.py
@@ -44,18 +44,18 @@ def tearDown(self):
# Remove any M2M tables first
for field in model._meta.local_many_to_many:
try:
- cursor.execute("DROP TABLE %s CASCADE" % (
- connection.ops.quote_name(field.rel.through._meta.db_table),
- ))
+ cursor.execute(connection.schema_editor().sql_delete_table % {
+ "table": connection.ops.quote_name(field.rel.through._meta.db_table),
+ })
except DatabaseError:
connection.rollback()
else:
connection.commit()
# Then remove the main tables
try:
- cursor.execute("DROP TABLE %s CASCADE" % (
- connection.ops.quote_name(model._meta.db_table),
- ))
+ cursor.execute(connection.schema_editor().sql_delete_table % {
+ "table": connection.ops.quote_name(model._meta.db_table),
+ })
except DatabaseError:
connection.rollback()
else:
Please sign in to comment.
Something went wrong with that request. Please try again.