Author: mtredinnick
Date: 2008-02-23 03:26:11 -0600 (Sat, 23 Feb 2008)
New Revision: 7152

Added:
   
django/branches/queryset-refactor/tests/regressiontests/fixtures_regress/fixtures/absolute.json
Modified:
   django/branches/queryset-refactor/AUTHORS
   django/branches/queryset-refactor/django/core/management/commands/loaddata.py
   django/branches/queryset-refactor/django/db/backends/postgresql/operations.py
   django/branches/queryset-refactor/django/db/models/fields/__init__.py
   django/branches/queryset-refactor/django/utils/datastructures.py
   django/branches/queryset-refactor/setup.py
   
django/branches/queryset-refactor/tests/regressiontests/datastructures/tests.py
   django/branches/queryset-refactor/tests/regressiontests/datatypes/models.py
   
django/branches/queryset-refactor/tests/regressiontests/fixtures_regress/models.py
   
django/branches/queryset-refactor/tests/regressiontests/string_lookup/models.py
Log:
queryset-refactor: Merged from trunk up to [7151].


Modified: django/branches/queryset-refactor/AUTHORS
===================================================================
--- django/branches/queryset-refactor/AUTHORS   2008-02-23 09:15:35 UTC (rev 
7151)
+++ django/branches/queryset-refactor/AUTHORS   2008-02-23 09:26:11 UTC (rev 
7152)
@@ -71,6 +71,7 @@
     [EMAIL PROTECTED]
     Andrew Brehaut <http://brehaut.net/blog>
     [EMAIL PROTECTED]
+    [EMAIL PROTECTED]
     Jonathan Buchanan <[EMAIL PROTECTED]>
     Can Burak Çilingir <[EMAIL PROTECTED]>
     Trevor Caira <[EMAIL PROTECTED]>

Modified: 
django/branches/queryset-refactor/django/core/management/commands/loaddata.py
===================================================================
--- 
django/branches/queryset-refactor/django/core/management/commands/loaddata.py   
    2008-02-23 09:15:35 UTC (rev 7151)
+++ 
django/branches/queryset-refactor/django/core/management/commands/loaddata.py   
    2008-02-23 09:26:11 UTC (rev 7152)
@@ -30,7 +30,8 @@
         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 @@
                 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 @@
                             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 @@
                             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 @@
         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)

Modified: 
django/branches/queryset-refactor/django/db/backends/postgresql/operations.py
===================================================================
--- 
django/branches/queryset-refactor/django/db/backends/postgresql/operations.py   
    2008-02-23 09:15:35 UTC (rev 7151)
+++ 
django/branches/queryset-refactor/django/db/backends/postgresql/operations.py   
    2008-02-23 09:26:11 UTC (rev 7152)
@@ -27,6 +27,11 @@
     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]

Modified: django/branches/queryset-refactor/django/db/models/fields/__init__.py
===================================================================
--- django/branches/queryset-refactor/django/db/models/fields/__init__.py       
2008-02-23 09:15:35 UTC (rev 7151)
+++ django/branches/queryset-refactor/django/db/models/fields/__init__.py       
2008-02-23 09:26:11 UTC (rev 7152)
@@ -243,7 +243,11 @@
                 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):

Modified: django/branches/queryset-refactor/django/utils/datastructures.py
===================================================================
--- django/branches/queryset-refactor/django/utils/datastructures.py    
2008-02-23 09:15:35 UTC (rev 7151)
+++ django/branches/queryset-refactor/django/utils/datastructures.py    
2008-02-23 09:26:11 UTC (rev 7152)
@@ -155,6 +155,10 @@
         """
         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
 

Modified: django/branches/queryset-refactor/setup.py
===================================================================
--- django/branches/queryset-refactor/setup.py  2008-02-23 09:15:35 UTC (rev 
7151)
+++ django/branches/queryset-refactor/setup.py  2008-02-23 09:26:11 UTC (rev 
7152)
@@ -27,19 +27,16 @@
 # an easy way to do this.
 packages, data_files = [], []
 root_dir = os.path.dirname(__file__)
-django_dir = os.path.join(root_dir, 'django')
-pieces = fullsplit(root_dir)
-if pieces[-1] == '':
-    len_root_dir = len(pieces) - 1
-else:
-    len_root_dir = len(pieces)
+if root_dir != '':
+    os.chdir(root_dir)
+django_dir = 'django'
 
 for dirpath, dirnames, filenames in os.walk(django_dir):
     # Ignore dirnames that start with '.'
     for i, dirname in enumerate(dirnames):
         if dirname.startswith('.'): del dirnames[i]
     if '__init__.py' in filenames:
-        packages.append('.'.join(fullsplit(dirpath)[len_root_dir:]))
+        packages.append('.'.join(fullsplit(dirpath)))
     elif filenames:
         data_files.append([dirpath, [os.path.join(dirpath, f) for f in 
filenames]])
 

Modified: 
django/branches/queryset-refactor/tests/regressiontests/datastructures/tests.py
===================================================================
--- 
django/branches/queryset-refactor/tests/regressiontests/datastructures/tests.py 
    2008-02-23 09:15:35 UTC (rev 7151)
+++ 
django/branches/queryset-refactor/tests/regressiontests/datastructures/tests.py 
    2008-02-23 09:26:11 UTC (rev 7152)
@@ -101,6 +101,12 @@
 >>> print repr(d)
 {1: 'one', 0: 'zero', 2: 'two'}
 
+>>> d.clear()
+>>> d
+{}
+>>> d.keyOrder
+[]
+
 ### DotExpandedDict 
############################################################
 
 >>> d = DotExpandedDict({'person.1.firstname': ['Simon'], 'person.1.lastname': 
 >>> ['Willison'], 'person.2.firstname': ['Adrian'], 'person.2.lastname': 
 >>> ['Holovaty']})

Modified: 
django/branches/queryset-refactor/tests/regressiontests/datatypes/models.py
===================================================================
--- django/branches/queryset-refactor/tests/regressiontests/datatypes/models.py 
2008-02-23 09:15:35 UTC (rev 7151)
+++ django/branches/queryset-refactor/tests/regressiontests/datatypes/models.py 
2008-02-23 09:26:11 UTC (rev 7152)
@@ -56,4 +56,30 @@
 datetime.time(5, 30)
 >>> d3.consumed_at
 datetime.datetime(2007, 4, 20, 16, 19, 59)
+
+# Year boundary tests (ticket #3689)
+
+>>> d = Donut(name='Date Test 2007', baked_date=datetime.datetime(year=2007, 
month=12, day=31), consumed_at=datetime.datetime(year=2007, month=12, day=31, 
hour=23, minute=59, second=59))
+>>> d.save()
+>>> d1 = Donut(name='Date Test 2006', baked_date=datetime.datetime(year=2006, 
month=1, day=1), consumed_at=datetime.datetime(year=2006, month=1, day=1))
+>>> d1.save()
+
+>>> Donut.objects.filter(baked_date__year=2007)
+[<Donut: Date Test 2007>]
+
+>>> Donut.objects.filter(baked_date__year=2006)
+[<Donut: Date Test 2006>]
+
+>>> Donut.objects.filter(consumed_at__year=2007).order_by('name')
+[<Donut: Apple Fritter>, <Donut: Date Test 2007>]
+
+>>> Donut.objects.filter(consumed_at__year=2006)
+[<Donut: Date Test 2006>]
+
+>>> Donut.objects.filter(consumed_at__year=2005)
+[]
+
+>>> Donut.objects.filter(consumed_at__year=2008)
+[]
+
 """}

Added: 
django/branches/queryset-refactor/tests/regressiontests/fixtures_regress/fixtures/absolute.json
===================================================================
--- 
django/branches/queryset-refactor/tests/regressiontests/fixtures_regress/fixtures/absolute.json
                             (rev 0)
+++ 
django/branches/queryset-refactor/tests/regressiontests/fixtures_regress/fixtures/absolute.json
     2008-02-23 09:26:11 UTC (rev 7152)
@@ -0,0 +1,9 @@
+[
+    {
+        "pk": "1", 
+        "model": "fixtures_regress.absolute", 
+        "fields": {
+            "name": "Load Absolute Path Test"
+        }
+    }
+]
\ No newline at end of file

Modified: 
django/branches/queryset-refactor/tests/regressiontests/fixtures_regress/models.py
===================================================================
--- 
django/branches/queryset-refactor/tests/regressiontests/fixtures_regress/models.py
  2008-02-23 09:15:35 UTC (rev 7151)
+++ 
django/branches/queryset-refactor/tests/regressiontests/fixtures_regress/models.py
  2008-02-23 09:26:11 UTC (rev 7152)
@@ -1,6 +1,7 @@
 from django.db import models
 from django.contrib.auth.models import User
 from django.conf import settings
+import os
 
 class Animal(models.Model):
     name = models.CharField(max_length=150)
@@ -28,6 +29,16 @@
             name = None
         return unicode(name) + u' is owned by ' + unicode(self.owner)
 
+class Absolute(models.Model):
+    name = models.CharField(max_length=40)
+
+    load_count = 0
+
+    def __init__(self, *args, **kwargs):
+        super(Absolute, self).__init__(*args, **kwargs)
+        Absolute.load_count += 1
+
+
 __test__ = {'API_TESTS':"""
 >>> from django.core import management
 
@@ -49,4 +60,15 @@
 >>> Stuff.objects.all()
 [<Stuff: None is owned by None>]
 
+###############################################
+# Regression test for ticket #6436 -- 
+# os.path.join will throw away the initial parts of a path if it encounters
+# an absolute path. This means that if a fixture is specified as an absolute 
path, 
+# we need to make sure we don't discover the absolute path in every fixture 
directory.
+
+>>> load_absolute_path = os.path.join(os.path.dirname(__file__), 'fixtures', 
'absolute.json')
+>>> management.call_command('loaddata', load_absolute_path, verbosity=0)
+>>> Absolute.load_count
+1
+
 """}

Modified: 
django/branches/queryset-refactor/tests/regressiontests/string_lookup/models.py
===================================================================
--- 
django/branches/queryset-refactor/tests/regressiontests/string_lookup/models.py 
    2008-02-23 09:15:35 UTC (rev 7151)
+++ 
django/branches/queryset-refactor/tests/regressiontests/string_lookup/models.py 
    2008-02-23 09:26:11 UTC (rev 7152)
@@ -39,6 +39,7 @@
 class Article(models.Model):
     name = models.CharField(max_length=50)
     text = models.TextField()
+    submitted_from = models.IPAddressField(blank=True, null=True)
 
     def __str__(self):
         return "Article %s" % self.name
@@ -98,4 +99,11 @@
 
 >>> Article.objects.get(text__contains='quick brown fox')
 <Article: Article Test>
+
+# Regression test for #708: "like" queries on IP address fields require casting
+# to text (on PostgreSQL).
+>>> Article(name='IP test', text='The body', 
submitted_from='192.0.2.100').save()
+>>> Article.objects.filter(submitted_from__contains='192.0.2')
+[<Article: Article IP test>]
+
 """}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to