Loading django/db/backends/__init__.py +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ try: from django.utils.six.moves import _thread as thread except ImportError: from django.utils.six.moves import _dummy_thread as thread from collections import namedtuple from contextlib import contextmanager from django.conf import settings Loading Loading @@ -918,6 +919,12 @@ class BaseDatabaseOperations(object): """ return params # Structure returned by the DB-API cursor.description interface (PEP 249) FieldInfo = namedtuple('FieldInfo', 'name type_code display_size internal_size precision scale null_ok' ) class BaseDatabaseIntrospection(object): """ This class encapsulates all backend-specific introspection utilities Loading django/db/backends/mysql/introspection.py +2 −2 Original line number Diff line number Diff line import re from .base import FIELD_TYPE from django.db.backends import BaseDatabaseIntrospection from django.db.backends import BaseDatabaseIntrospection, FieldInfo foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)") Loading Loading @@ -47,7 +47,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): length_map = dict(cursor.fetchall()) cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name)) return [line[:3] + (length_map.get(line[0], line[3]),) + line[4:] return [FieldInfo(*(line[:3] + (length_map.get(line[0], line[3]),) + line[4:])) for line in cursor.description] def _name_to_index(self, cursor, table_name): Loading django/db/backends/oracle/introspection.py +2 −2 Original line number Diff line number Diff line from django.db.backends import BaseDatabaseIntrospection from django.db.backends import BaseDatabaseIntrospection, FieldInfo import cx_Oracle import re Loading Loading @@ -47,7 +47,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): cursor.execute("SELECT * FROM %s WHERE ROWNUM < 2" % self.connection.ops.quote_name(table_name)) description = [] for desc in cursor.description: description.append((desc[0].lower(),) + desc[1:]) description.append(FieldInfo(*((desc[0].lower(),) + desc[1:]))) return description def table_name_converter(self, name): Loading django/db/backends/postgresql_psycopg2/introspection.py +2 −2 Original line number Diff line number Diff line from __future__ import unicode_literals from django.db.backends import BaseDatabaseIntrospection from django.db.backends import BaseDatabaseIntrospection, FieldInfo class DatabaseIntrospection(BaseDatabaseIntrospection): Loading Loading @@ -45,7 +45,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): WHERE table_name = %s""", [table_name]) null_map = dict(cursor.fetchall()) cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name)) return [line[:6] + (null_map[line[0]]=='YES',) return [FieldInfo(*(line[:6] + (null_map[line[0]]=='YES',))) for line in cursor.description] def get_relations(self, cursor, table_name): Loading django/db/backends/sqlite3/introspection.py +2 −2 Original line number Diff line number Diff line import re from django.db.backends import BaseDatabaseIntrospection from django.db.backends import BaseDatabaseIntrospection, FieldInfo field_size_re = re.compile(r'^\s*(?:var)?char\s*\(\s*(\d+)\s*\)\s*$') Loading Loading @@ -60,7 +60,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_table_description(self, cursor, table_name): "Returns a description of the table, with the DB-API cursor.description interface." return [(info['name'], info['type'], None, info['size'], None, None, return [FieldInfo(info['name'], info['type'], None, info['size'], None, None, info['null_ok']) for info in self._table_info(cursor, table_name)] def get_relations(self, cursor, table_name): Loading Loading
django/db/backends/__init__.py +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ try: from django.utils.six.moves import _thread as thread except ImportError: from django.utils.six.moves import _dummy_thread as thread from collections import namedtuple from contextlib import contextmanager from django.conf import settings Loading Loading @@ -918,6 +919,12 @@ class BaseDatabaseOperations(object): """ return params # Structure returned by the DB-API cursor.description interface (PEP 249) FieldInfo = namedtuple('FieldInfo', 'name type_code display_size internal_size precision scale null_ok' ) class BaseDatabaseIntrospection(object): """ This class encapsulates all backend-specific introspection utilities Loading
django/db/backends/mysql/introspection.py +2 −2 Original line number Diff line number Diff line import re from .base import FIELD_TYPE from django.db.backends import BaseDatabaseIntrospection from django.db.backends import BaseDatabaseIntrospection, FieldInfo foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)") Loading Loading @@ -47,7 +47,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): length_map = dict(cursor.fetchall()) cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name)) return [line[:3] + (length_map.get(line[0], line[3]),) + line[4:] return [FieldInfo(*(line[:3] + (length_map.get(line[0], line[3]),) + line[4:])) for line in cursor.description] def _name_to_index(self, cursor, table_name): Loading
django/db/backends/oracle/introspection.py +2 −2 Original line number Diff line number Diff line from django.db.backends import BaseDatabaseIntrospection from django.db.backends import BaseDatabaseIntrospection, FieldInfo import cx_Oracle import re Loading Loading @@ -47,7 +47,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): cursor.execute("SELECT * FROM %s WHERE ROWNUM < 2" % self.connection.ops.quote_name(table_name)) description = [] for desc in cursor.description: description.append((desc[0].lower(),) + desc[1:]) description.append(FieldInfo(*((desc[0].lower(),) + desc[1:]))) return description def table_name_converter(self, name): Loading
django/db/backends/postgresql_psycopg2/introspection.py +2 −2 Original line number Diff line number Diff line from __future__ import unicode_literals from django.db.backends import BaseDatabaseIntrospection from django.db.backends import BaseDatabaseIntrospection, FieldInfo class DatabaseIntrospection(BaseDatabaseIntrospection): Loading Loading @@ -45,7 +45,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): WHERE table_name = %s""", [table_name]) null_map = dict(cursor.fetchall()) cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name)) return [line[:6] + (null_map[line[0]]=='YES',) return [FieldInfo(*(line[:6] + (null_map[line[0]]=='YES',))) for line in cursor.description] def get_relations(self, cursor, table_name): Loading
django/db/backends/sqlite3/introspection.py +2 −2 Original line number Diff line number Diff line import re from django.db.backends import BaseDatabaseIntrospection from django.db.backends import BaseDatabaseIntrospection, FieldInfo field_size_re = re.compile(r'^\s*(?:var)?char\s*\(\s*(\d+)\s*\)\s*$') Loading Loading @@ -60,7 +60,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_table_description(self, cursor, table_name): "Returns a description of the table, with the DB-API cursor.description interface." return [(info['name'], info['type'], None, info['size'], None, None, return [FieldInfo(info['name'], info['type'], None, info['size'], None, None, info['null_ok']) for info in self._table_info(cursor, table_name)] def get_relations(self, cursor, table_name): Loading