mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
[soc2010/query-refactor] Altered the base database backend class to not have anything more than the bare minimum. Also add the bare beginnings for a mongodb backend.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13330 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a61b34b048
commit
0813aa4614
5
django/contrib/mongodb/README
Normal file
5
django/contrib/mongodb/README
Normal file
@ -0,0 +1,5 @@
|
||||
NOTE
|
||||
====
|
||||
|
||||
This backend lives here for conveinience purposes during the 2010 GSOC. This
|
||||
is not it's permanent location (nor should you probably be using it all).
|
0
django/contrib/mongodb/__init__.py
Normal file
0
django/contrib/mongodb/__init__.py
Normal file
5
django/contrib/mongodb/base.py
Normal file
5
django/contrib/mongodb/base.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.db.backends import BaseDatabaseWrapper
|
||||
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
pass
|
@ -10,13 +10,10 @@ class BaseDatabaseWrapper(local):
|
||||
"""
|
||||
Represents a database connection.
|
||||
"""
|
||||
ops = None
|
||||
|
||||
def __init__(self, settings_dict, alias=DEFAULT_DB_ALIAS):
|
||||
# `settings_dict` should be a dictionary containing keys such as
|
||||
# NAME, USER, etc. It's called `settings_dict` instead of `settings`
|
||||
# to disambiguate it from Django settings modules.
|
||||
self.connection = None
|
||||
self.queries = []
|
||||
self.settings_dict = settings_dict
|
||||
self.alias = alias
|
||||
@ -27,6 +24,14 @@ class BaseDatabaseWrapper(local):
|
||||
def __ne__(self, other):
|
||||
return not self == other
|
||||
|
||||
|
||||
class BaseSQLDatabaseWrapper(BaseDatabaseWrapper):
|
||||
ops = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.connection = None
|
||||
super(BaseSQLDatabaseWrapper, self).__init__(*args, **kwargs)
|
||||
|
||||
def _commit(self):
|
||||
if self.connection is not None:
|
||||
return self.connection.commit()
|
||||
@ -80,6 +85,7 @@ class BaseDatabaseWrapper(local):
|
||||
def make_debug_cursor(self, cursor):
|
||||
return util.CursorDebugWrapper(cursor, self)
|
||||
|
||||
|
||||
class BaseDatabaseFeatures(object):
|
||||
allows_group_by_pk = False
|
||||
# True if django.db.backend.utils.typecast_timestamp is used on values
|
||||
|
@ -230,7 +230,7 @@ class DatabaseOperations(BaseDatabaseOperations):
|
||||
def max_name_length(self):
|
||||
return 64
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
class DatabaseWrapper(BaseSQLDatabaseWrapper):
|
||||
|
||||
operators = {
|
||||
'exact': '= %s',
|
||||
@ -303,7 +303,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
|
||||
def _rollback(self):
|
||||
try:
|
||||
BaseDatabaseWrapper._rollback(self)
|
||||
super(DatabaseWrapper, self)._rollback()
|
||||
except Database.NotSupportedError:
|
||||
pass
|
||||
|
||||
|
@ -310,7 +310,7 @@ WHEN (new.%(col_name)s IS NULL)
|
||||
return super(DatabaseOperations, self).combine_expression(connector, sub_expressions)
|
||||
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
class DatabaseWrapper(BaseSQLDatabaseWrapper):
|
||||
|
||||
operators = {
|
||||
'exact': '= %s',
|
||||
|
@ -81,7 +81,7 @@ class UnicodeCursorWrapper(object):
|
||||
class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
uses_savepoints = True
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
class DatabaseWrapper(BaseSQLDatabaseWrapper):
|
||||
operators = {
|
||||
'exact': '= %s',
|
||||
'iexact': '= UPPER(%s)',
|
||||
|
@ -78,7 +78,7 @@ class DatabaseOperations(PostgresqlDatabaseOperations):
|
||||
def return_insert_id(self):
|
||||
return "RETURNING %s", ()
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
class DatabaseWrapper(BaseSQLDatabaseWrapper):
|
||||
operators = {
|
||||
'exact': '= %s',
|
||||
'iexact': '= UPPER(%s)',
|
||||
|
@ -128,7 +128,7 @@ class DatabaseOperations(BaseDatabaseOperations):
|
||||
# No field, or the field isn't known to be a decimal or integer
|
||||
return value
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
class DatabaseWrapper(BaseSQLDatabaseWrapper):
|
||||
|
||||
# SQLite requires LIKE statements to include an ESCAPE clause if the value
|
||||
# being escaped has a percent or underscore in it.
|
||||
@ -184,7 +184,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
# database. To prevent accidental data loss, ignore close requests on
|
||||
# an in-memory db.
|
||||
if self.settings_dict['NAME'] != ":memory:":
|
||||
BaseDatabaseWrapper.close(self)
|
||||
super(DatabaseWrapper, self).close()
|
||||
|
||||
FORMAT_QMARK_REGEX = re.compile(r'(?![^%])%s')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user