diff options
| author | Kevin Kubasik <kevin@kubasik.net> | 2009-09-08 17:36:43 +0000 |
|---|---|---|
| committer | Kevin Kubasik <kevin@kubasik.net> | 2009-09-08 17:36:43 +0000 |
| commit | 3de5792e13d777c2beedea11bcc308f6c9df4ff9 (patch) | |
| tree | 88a433f78b5f77ab1964162594d25f6a59e7a5d9 /django | |
| parent | e2d14c075a51eb1f0b832765df8723d82f0afac4 (diff) | |
| parent | bb9cc01b132dbde2461191dbb1035eaae4885051 (diff) | |
[gsoc2009-testing] Massive merge update to trunk. This is to prep for uploadarchive/soc2009/test-improvements
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11480 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/options.py | 2 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/delete_selected_confirmation.html | 4 | ||||
| -rw-r--r-- | django/contrib/gis/management/commands/inspectdb.py | 2 | ||||
| -rw-r--r-- | django/core/management/commands/inspectdb.py | 7 | ||||
| -rw-r--r-- | django/db/backends/__init__.py | 9 | ||||
| -rw-r--r-- | django/db/backends/oracle/base.py | 21 | ||||
| -rw-r--r-- | django/db/backends/oracle/introspection.py | 8 |
7 files changed, 39 insertions, 14 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 31a28ccf0b..3144a22a2a 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -482,7 +482,7 @@ class ModelAdmin(BaseModelAdmin): def get_action(self, action): """ - Return a given action from a parameter, which can either be a calable, + Return a given action from a parameter, which can either be a callable, or the name of a method on the ModelAdmin. Return is a tuple of (callable, name, description). """ diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html index a6258b94c0..5550b73e2e 100644 --- a/django/contrib/admin/templates/admin/delete_selected_confirmation.html +++ b/django/contrib/admin/templates/admin/delete_selected_confirmation.html @@ -19,7 +19,7 @@ {% endfor %} </ul> {% else %} - <p>{% blocktrans %}Are you sure you want to delete the selected {{ object_name }} objects? All of the following objects and it's related items will be deleted:{% endblocktrans %}</p> + <p>{% blocktrans %}Are you sure you want to delete the selected {{ object_name }} objects? All of the following objects and their related items will be deleted:{% endblocktrans %}</p> {% for deleteable_object in deletable_objects %} <ul>{{ deleteable_object|unordered_list }}</ul> {% endfor %} @@ -34,4 +34,4 @@ </div> </form> {% endif %} -{% endblock %}
\ No newline at end of file +{% endblock %} diff --git a/django/contrib/gis/management/commands/inspectdb.py b/django/contrib/gis/management/commands/inspectdb.py index d4fe210953..365bb24063 100644 --- a/django/contrib/gis/management/commands/inspectdb.py +++ b/django/contrib/gis/management/commands/inspectdb.py @@ -131,7 +131,7 @@ class Command(InspectCommand): if srid != 4326: extra_params['srid'] = srid else: try: - field_type = connection.introspection.data_types_reverse[row[1]] + field_type = connection.introspection.get_field_type(row[1], row) except KeyError: field_type = 'TextField' comment_notes.append('This field type is a guess.') diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py index f30a00b7b2..54203c532b 100644 --- a/django/core/management/commands/inspectdb.py +++ b/django/core/management/commands/inspectdb.py @@ -15,8 +15,9 @@ class Command(NoArgsCommand): def handle_inspection(self): from django.db import connection import keyword - - table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '') + + table2model = lambda table_name: table_name.title() + .replace('_', '').replace(' ', '').replace('-', '').replace('*','_').replace(',','_') cursor = connection.cursor() yield "# This is an auto-generated Django model module." @@ -73,7 +74,7 @@ class Command(NoArgsCommand): extra_params['db_column'] = column_name else: try: - field_type = connection.introspection.data_types_reverse[row[1]] + field_type = connection.introspection.get_field_type(row[1], row) except KeyError: field_type = 'TextField' comment_notes.append('This field type is a guess.') diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 579bf80aaf..9a1fe30925 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -470,6 +470,14 @@ class BaseDatabaseIntrospection(object): def __init__(self, connection): self.connection = connection + def get_field_type(self, data_type, description): + """Hook for a database backend to use the cursor description to + match a Django field type to a database column. + + For Oracle, the column data_type on its own is insufficient to + distinguish between a FloatField and IntegerField, for example.""" + return self.data_types_reverse[data_type] + def table_name_converter(self, name): """Apply a conversion to the name for the purposes of comparison. @@ -560,4 +568,3 @@ class BaseDatabaseValidation(object): def validate_field(self, errors, opts, f): "By default, there is no backend-specific validation" pass - diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 80558a0a68..c4155e2c9a 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -36,6 +36,14 @@ DatabaseError = Database.DatabaseError IntegrityError = Database.IntegrityError +# Check whether cx_Oracle was compiled with the WITH_UNICODE option. This will +# also be True in Python 3.0. +if int(Database.version.split('.', 1)[0]) >= 5 and not hasattr(Database, 'UNICODE'): + convert_unicode = force_unicode +else: + convert_unicode = smart_str + + class DatabaseFeatures(BaseDatabaseFeatures): empty_fetchmany_value = () needs_datetime_string_cast = False @@ -170,10 +178,10 @@ WHEN (new.%(col_name)s IS NULL) return "RETURNING %s INTO %%s", (InsertIdVar(),) def savepoint_create_sql(self, sid): - return "SAVEPOINT " + self.quote_name(sid) + return convert_unicode("SAVEPOINT " + self.quote_name(sid)) def savepoint_rollback_sql(self, sid): - return "ROLLBACK TO SAVEPOINT " + self.quote_name(sid) + return convert_unicode("ROLLBACK TO SAVEPOINT " + self.quote_name(sid)) def sql_flush(self, style, tables, sequences): # Return a list of 'TRUNCATE x;', 'TRUNCATE y;', @@ -304,7 +312,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): def _cursor(self): cursor = None if not self._valid_connection(): - conn_string = self._connect_string() + conn_string = convert_unicode(self._connect_string()) self.connection = Database.connect(conn_string, **self.settings_dict['DATABASE_OPTIONS']) cursor = FormatStylePlaceholderCursor(self.connection) # Set oracle date to ansi date format. This only needs to execute @@ -355,7 +363,8 @@ class OracleParam(object): if hasattr(param, 'bind_parameter'): self.smart_str = param.bind_parameter(cursor) else: - self.smart_str = smart_str(param, cursor.charset, strings_only) + self.smart_str = convert_unicode(param, cursor.charset, + strings_only) if hasattr(param, 'input_size'): # If parameter has `input_size` attribute, use that. self.input_size = param.input_size @@ -423,7 +432,7 @@ class FormatStylePlaceholderCursor(object): # is being passed to SQL*Plus. if query.endswith(';') or query.endswith('/'): query = query[:-1] - query = smart_str(query, self.charset) % tuple(args) + query = convert_unicode(query % tuple(args), self.charset) self._guess_input_sizes([params]) try: return self.cursor.execute(query, self._param_generator(params)) @@ -445,7 +454,7 @@ class FormatStylePlaceholderCursor(object): # is being passed to SQL*Plus. if query.endswith(';') or query.endswith('/'): query = query[:-1] - query = smart_str(query, self.charset) % tuple(args) + query = convert_unicode(query % tuple(args), self.charset) formatted = [self._format_params(i) for i in params] self._guess_input_sizes(formatted) try: diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py index 543e84a8f3..0b4f61a360 100644 --- a/django/db/backends/oracle/introspection.py +++ b/django/db/backends/oracle/introspection.py @@ -26,6 +26,14 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): except AttributeError: pass + def get_field_type(self, data_type, description): + # If it's a NUMBER with scale == 0, consider it an IntegerField + if data_type == cx_Oracle.NUMBER and description[5] == 0: + return 'IntegerField' + else: + return super(DatabaseIntrospection, self).get_field_type( + data_type, description) + def get_table_list(self, cursor): "Returns a list of table names in the current database." cursor.execute("SELECT TABLE_NAME FROM USER_TABLES") |
