diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-23 09:26:11 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-23 09:26:11 +0000 |
| commit | bdeba9ab94e8bd4012111cbde9e3606867f123cb (patch) | |
| tree | 2cd1e0e9537d89f697480473d753f67e497915a9 /django | |
| parent | cbd6da3540e1116e6d049c2affd9f6894f427ace (diff) | |
queryset-refactor: Merged from trunk up to [7151].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7152 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/commands/loaddata.py | 20 | ||||
| -rw-r--r-- | django/db/backends/postgresql/operations.py | 5 | ||||
| -rw-r--r-- | django/db/models/fields/__init__.py | 6 | ||||
| -rw-r--r-- | django/utils/datastructures.py | 4 |
4 files changed, 27 insertions, 8 deletions
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index e95be6b8d7..dde9e6eb80 100644 --- a/django/core/management/commands/loaddata.py +++ b/django/core/management/commands/loaddata.py @@ -30,7 +30,8 @@ class Command(BaseCommand): show_traceback = options.get('traceback', False) # Keep a count of the installed objects and fixtures - count = [0, 0] + fixture_count = 0 + object_count = 0 models = set() humanize = lambda dirname: dirname and "'%s'" % dirname or 'absolute path' @@ -65,7 +66,12 @@ class Command(BaseCommand): else: print "Skipping fixture '%s': %s is not a known serialization format" % (fixture_name, format) - for fixture_dir in app_fixtures + list(settings.FIXTURE_DIRS) + ['']: + if os.path.isabs(fixture_name): + fixture_dirs = [fixture_name] + else: + fixture_dirs = app_fixtures + list(settings.FIXTURE_DIRS) + [''] + + for fixture_dir in fixture_dirs: if verbosity > 1: print "Checking %s for fixtures..." % humanize(fixture_dir) @@ -86,14 +92,14 @@ class Command(BaseCommand): transaction.leave_transaction_management() return else: - count[1] += 1 + fixture_count += 1 if verbosity > 0: print "Installing %s fixture '%s' from %s." % \ (format, fixture_name, humanize(fixture_dir)) try: objects = serializers.deserialize(format, fixture) for obj in objects: - count[0] += 1 + object_count += 1 models.add(obj.object.__class__) obj.save() label_found = True @@ -113,7 +119,7 @@ class Command(BaseCommand): print "No %s fixture '%s' in %s." % \ (format, fixture_name, humanize(fixture_dir)) - if count[0] > 0: + if object_count > 0: sequence_sql = connection.ops.sequence_reset_sql(self.style, models) if sequence_sql: if verbosity > 1: @@ -124,9 +130,9 @@ class Command(BaseCommand): transaction.commit() transaction.leave_transaction_management() - if count[0] == 0: + if object_count == 0: if verbosity >= 2: print "No fixtures found." else: if verbosity > 0: - print "Installed %d object(s) from %d fixture(s)" % tuple(count) + print "Installed %d object(s) from %d fixture(s)" % (object_count, fixture_count) diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index d2c65a8753..ec54e165fb 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -27,6 +27,11 @@ class DatabaseOperations(BaseDatabaseOperations): def deferrable_sql(self): return " DEFERRABLE INITIALLY DEFERRED" + def field_cast_sql(self, db_type): + if db_type == 'inet': + return 'CAST(%s AS TEXT)' + return '%s' + def last_insert_id(self, cursor, table_name, pk_name): cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" % (table_name, pk_name)) return cursor.fetchone()[0] diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 8c35d63e0f..a295edfd79 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -243,7 +243,11 @@ class Field(object): value = int(value) except ValueError: raise ValueError("The __year lookup type requires an integer argument") - return ['%s-01-01 00:00:00' % value, '%s-12-31 23:59:59.999999' % value] + if settings.DATABASE_ENGINE == 'sqlite3': + first = '%s-01-01' + else: + first = '%s-01-01 00:00:00' + return [first % value, '%s-12-31 23:59:59.999999' % value] raise TypeError("Field has invalid lookup: %s" % lookup_type) def has_default(self): diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index a2b78a31c5..4c278c0d8e 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -155,6 +155,10 @@ class SortedDict(dict): """ return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()]) + def clear(self): + super(SortedDict, self).clear() + self.keyOrder = [] + class MultiValueDictKeyError(KeyError): pass |
