53 rows where "changetime" is on date 2008-04-27

View and edit SQL

Suggested facets: changetime, stage, component, type, severity, version, owner, keywords, has_patch, needs_better_patch, needs_tests, needs_docs, created (date), last_pulled_from_trac (date)

changetime (date)

  • 2008-04-27 · 53
id ▼ created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
245 2005-08-01 19:54:48 2008-04-27 02:50:16 2019-06-24 00:17:52.326120 Accepted closed Metasystem defect trivial   fixed Remove old ordering syntax For the 1.0 release, we should remove the {{{DeprecationWarning}}} for use of old ordering syntax. This means old ordering syntax will no longer be supported. nobody adrian 1.0 deprecated, qs-rf-fixed 0 1 0 0 0 0
1050 2005-12-12 19:31:15 2008-04-27 02:50:16 2019-06-24 00:26:26.102475 Accepted closed Database layer (models, ORM) defect normal   fixed Can't find null objects in a ManyToMany that may be null Model B defined a ManyToMany relationship to Model A that can be null. There's no way in the ORM to look up all the Bs where it's null. There might be a workaround with a custom SQL query. Jacobkm in IRC told me to post a ticket so he doesn't forget to fix this. nobody ph@malaprop.org null, manytomany, orm, qs-rf-fixed 0 0 0 0 0 0
1656 2006-04-19 07:49:38 2008-04-27 02:50:16 2019-06-24 00:32:50.995499 Fixed on a branch closed Database layer (models, ORM) enhancement normal   fixed Model Inheritance is not implemented The ideas in ModelInheritance should be implemented by the clever folks involved. nobody jim-django@dsdd.org feature_request qs-rf-fixed 0 0 0 0 0 0
1801 2006-05-08 12:35:19 2008-04-27 02:50:16 2019-06-24 00:34:24.100108 Accepted closed Database layer (models, ORM) defect major master fixed QuerySet.__and__ does not work for joined queries Try {{{ # Who has written a and a2? Reporter.objects.filter(article__id__exact=a1.id) & Reporter.objects.filter(article__id__exact=a2.id) }}} ... this does not work as expected. I've added a patch for the or tests that should make it easy for you to verify this bug. The underlying problem is that you cannot simply lump together the where conditions in this case. This does only work as long as you don't have joins. Probably using UNION would fix this, but is the overhead tolerable? nobody mir@noris.de qs-rf-fixed 0 0 0 0 0 0
2091 2006-06-05 14:39:58 2008-04-27 02:50:16 2019-06-24 00:37:28.388711 Accepted closed Database layer (models, ORM) defect normal master fixed IN field lookup returns all objects without filtering by the supplied list when used on ManyToMany field. using an IN field lookup in a filter on a ManyToMany field seems to return all objects. as far as i know, the two e.filter statements below should return the same queryset. {{{ >>> e = Entry.objects.all() >>> e [<Entry: smooth sailing>, <Entry: wii rocks e3>, <Entry: 30thirty reboot>] >>> t = Tag.objects.get(id=6) >>> t <Tag: django> >>> t.entry_set.all() [<Entry: smooth sailing>, <Entry: 30thirty reboot>] >>> e.filter(tags__id__exact=6) [<Entry: smooth sailing>, <Entry: 30thirty reboot>] >>> e.filter(tags__id__in=[6]) [<Entry: smooth sailing>, <Entry: wii rocks e3>, <Entry: 30thirty reboot>] }}} nobody real dot human at mrmachine dot net in field lookup filter manytomany m2m many, qs-rf-fixed 0 0 0 0 0 0
2150 2006-06-13 23:32:13 2008-04-27 02:50:16 2019-06-24 00:38:07.035315 Accepted closed Database layer (models, ORM) enhancement normal master fixed slicing to the end of a QuerySet Currently, when trying to slice to the end of a QuerySet, an AssertionError is raised: {{{ #!python >>>Foo.objects.all()[3:] Traceback (most recent call last): File "<console>", line 1, in ? File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 88, in __repr__ return repr(self._get_data()) File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 412, in _get_data self._result_cache = list(self.iterator()) File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 162, in iterator select, sql, params = self._get_sql_clause() File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 490, in _get_sql_clause assert self._offset is None, "'offset' is not allowed without 'limit'" AssertionError: 'offset' is not allowed without 'limit' }}} However, returning rows from an offset to the end of a result set does seem possible... '''in MySQL (>=3.23)''' ''"To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:"'' http://dev.mysql.com/doc/refman/4.1/en/select.html {{{ #!sql SELECT * FROM tbl LIMIT 95,18446744073709551615; }}} '''and in PostgreSQL (>=7.3)''' ''"LIMIT ALL is the same as omitting the LIMIT clause."'' http://www.postgresql.org/docs/7.3/static/queries-limit.html {{{ #!sql SELECT select_list FROM table_expression [LIMIT { number | ALL }] [OFFSET number] }}} nobody Gary Wilson <gary.wilson@gmail.com> qs-rf-fixed 0 0 0 0 0 0
2253 2006-06-28 08:12:02 2008-04-27 02:50:16 2019-06-24 00:39:12.881924 Accepted closed Database layer (models, ORM) defect major master fixed Combining QuerySets via | operator does not always work I am working through the first example model in the documentation (http://www.djangoproject.com/documentation/models/basic/). Using that model as a reference, I can show the output here from the python interpeter that where the "|" operator generates an incorrect result (but the "&" operator seems to work OK): >>> all = Article.objects.all() >>> one = Article.objects.filter(id=1) >>> >>> all [<Article: Area womman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Fourth article>, <Article: Article 6>, <Article: Default headline>, <Article: Article 7>, <Article: Article 8>, <Article: Article 9>, <Article: Article 7>] >>> >>> one [<Article: Area womman programs in Python>] >>> >>> all | one [<Article: Area womman programs in Python>] <-- should be the union of the two QuerySets, but it is not >>> >>> all & one [<Article: Area womman programs in Python>] >>> The operation: "all | one" should have been the union of these two ResultSets, but here it is a list containing only a single object. Note that the intersection "all & one" is, however, correct. Here are a few more details: >>> import django >>> django.VERSION (0, 95, 'post-magic-removal') >>> Specifically, this is for revision 3214. anonymous jeffrey.a.zelt@vm.ntnu.no qs-rf-fixed 0 0 0 1 0 0
2306 2006-07-08 02:53:05 2008-04-27 02:50:16 2019-06-24 00:39:46.872688 Accepted closed Database layer (models, ORM) defect normal master fixed Many-to-many queries very slow on MySQL 3.23.58 We have a MySQL 3.23.58 database with about 1000 Room and Photo objects, connected by a many-to-many relationship. Given a room r, asking Django to evaluate r.photos.all() runs an explicit join: {{{ SELECT `kords3_photo`.`id`,`kords3_photo`.`image` FROM `kords3_photo` LEFT OUTER JOIN `kords3_room_photos` AS `m2m_kords3_photo__room` ON `kords3_photo`.`id` = `m2m_kords3_photo__room`.`photo_id` WHERE (`m2m_kords3_photo__room`.`room_id` = 1) ORDER BY `kords3_photo`.`image` ASC }}} which takes around 1 second, when the same query rewritten as an implicit join: {{{ SELECT `kords3_photo`.`id`,`kords3_photo`.`image` FROM `kords3_photo` , `kords3_room_photos` WHERE `kords3_photo`.`id` = `kords3_room_photos`.`photo_id` AND `kords3_room_photos`.`room_id` = 1 ORDER BY `kords3_photo`.`image` ASC }}} would take under a millisecond. nobody anonymous qs-rf-fixed 0 0 0 0 0 0
2400 2006-07-22 10:42:09 2008-04-27 02:50:16 2019-06-24 00:40:46.582394 Accepted closed Core (Other) enhancement normal master fixed allow querying of existance of backwards relationship without resorting to custom sql Both of these threads cover the same issue: http://groups.google.com/group/django-users/browse_frm/thread/98b7aedf8f9d806c http://groups.google.com/group/django-users/browse_frm/thread/b129d64b1ed77e28 To summarize, I can get all Reporters who have associated Articles by doing: {{{ Reporter.objects.filter(article__isnull = False) }}} But, I can't get Reporters who have *no* associated Article by doing: {{{ Reporter.objects.filter(article__isnull = True) }}} as it returns an empty list, since the article property does not exist for those Reporters, and thus, it can't even be null. Furthermore, being able to do the same in limit_choices_to would be extremely useful. nobody mattimustang@gmail.com qs-rf-fixed 0 0 0 0 0 0
2430 2006-07-26 20:02:15 2008-04-27 02:50:16 2019-06-24 00:41:05.808366 Accepted closed Database layer (models, ORM) defect normal master fixed QuerySet should be evaluated when used in boolean tests Currently, a QuerySet is not evaluated when being used in boolean contexts (e.g., doing `if SomeModel.objects.all():`); this leads to counterintuitive behavior, because it will always resolve to a True value regardless of whether it would return any objects when "actually" evaluated. Adding a `__nonzero__` method to QuerySet which does the evaluation would solve this. nobody ubernostrum qs-rf-fixed 0 1 0 0 0 0
2482 2006-08-04 16:55:30 2008-04-27 02:50:16 2019-06-24 00:41:39.063926 Accepted closed Database layer (models, ORM) enhancement normal   fixed [patch] Add optional flat values() to QuerySet The attached patch adds a keyword argument, 'flat', to the QuerySet.values() method, which causes it to return a flattened list of values rather than a list of dictionaries. See discussion here: http://groups.google.com/group/django-developers/browse_thread/thread/0b1897d4d5dd7277/1ed627b92f3e56c9#1ed627b92f3e56c9 poelzi mccutchen@gmail.com sprintdec01 qs-rf-fixed 0 1 1 0 0 0
2496 2006-08-07 19:34:50 2008-04-27 02:50:16 2019-06-24 00:41:48.168273 Accepted closed Database layer (models, ORM) defect normal master fixed select_related will cause table multiple times in FROM clause if table already in extra() If a QuerySet is built or initialized with select_related and extra() and extra contains a table that will ultimately be iterated over through the select_related, that table will not be picked up in fill_table_cache. The result is a query with the table twice in the FROM clause and results in an DB error when executed (at least on postgresql, can't speak for any other DBs). Patch submitted. Example error from postgresql: ProgrammingError: 'ERROR: table name "client" specified more than once nobody rezzrovv qs-rf-fixed 0 1 1 1 0 0
2676 2006-09-08 05:23:09 2008-04-27 02:50:16 2019-06-24 00:43:43.144454 Accepted closed Database layer (models, ORM) enhancement normal   fixed abilty to view a QuerySet's generated SQL without running the query Discussion... http://groups.google.com/group/django-users/browse_thread/thread/37a6222006d0633b/6e62a5ba4ba97bbf nobody Gary Wilson <gary.wilson@gmail.com> qs-rf-fixed 0 0 0 0 0 0
2874 2006-10-05 03:50:27 2008-04-27 02:50:16 2019-06-24 00:45:47.881367 Accepted closed Database layer (models, ORM) defect normal master fixed select_related (and hence the admin) sometimes generate incorrect ordering '''Description:''' Under certain circumstances, Model.objects.select_related().order_by('table.field') will generate strangely ordered output. As a result, the admin interface displays incorrectly sorted items when the heading of a column specified in list_display is clicked. '''How to reproduce:''' This only occurs when the model being queried contains multiple foreign keys which point to the same table, one directly and another indirectly via other !ForeignKey relationships. Example: {{{ from django.db import models class Program(models.Model): name = models.CharField(maxlength=30) class Admin: pass def __str__(self): return self.name class Teacher(models.Model): first_name = models.CharField(maxlength=20) last_name = models.CharField(maxlength=20) def __str__(self): return self.last_name +", "+ self.first_name class Admin: pass class Meta: ordering = ["last_name"] class Department(models.Model): name = models.CharField(maxlength=20) head = models.ForeignKey(Teacher) def __str__(self): return self.name class Admin: pass class Subject(models.Model): name = models.CharField(maxlength=40) department = models.ForeignKey(Department) def __str__(self): return self.name class Admin: pass class Course(models.Model): program = models.ForeignKey(Program,default=1) subject = models.ForeignKey(Subject) teacher = models.ForeignKey(Teacher) def __str__(self): return str(self.id) class Admin: list_display = ('__str__','program','subject','teacher') }}} The 'model in question' here is Course. Following the relationships recursively in order: Course.program -> Progam[[BR]] Course.subject -> Subject -> Department -> Teacher[[BR]] Course.teacher -> Teacher i.e. the Teacher model is reached more than once when recursively following !ForeignKey relationships. Also necessary to reproduce the bug is the fact that the the !ForeignKey pointing directly to Teacher is reached AFTER having followed the indirect link to Teacher. … nobody bangcok_dangerus [ a t ) hotmail.com qs-rf-fixed 0 1 0 0 0 0
2902 2006-10-11 20:40:41 2008-04-27 02:50:16 2019-06-24 00:46:05.665398 Accepted closed Database layer (models, ORM) defect normal   fixed .extra()'s params list is incorrectly merged into the unordered select dictionary's %s slots. .extra() expects a dictionary of extra select fields, and a list of query parameters to go with it. Since dictionaries are unordered, something like this fails: {{{ .extra(select={'thingOne': 'REGEX %s', 'thingTwo': 'REGEX %s'}, params = (one, two)) }}} I tried using a django.utils.datastructures.SortedDict, but that did not solve the problem. More discussion: http://groups.google.com/group/django-users/browse_thread/thread/8ced145389650d62 nobody Beau Hartshorne <beau@hartshorne.ca> qs-rf-fixed 0 0 0 0 0 0
2939 2006-10-20 10:38:07 2008-04-27 02:50:16 2019-06-24 00:46:29.327793 Accepted closed Database layer (models, ORM) defect normal   fixed .values(*fields).distinct().count() returns the wrong value >>> Post.objects.values('author') [{'author': 1}, {'author': 2}, {'author': 1}, {'author': 2}, {'author': 1}] >>> Post.objects.values('author').distinct() [{'author': 1}, {'author': 2}] >>> Post.objects.values('author').distinct().count() 5 >>> len(Post.objects.values('author').distinct()) 2 nobody anonymous qs-rf-fixed 0 1 1 0 0 0
3037 2006-11-18 10:02:47 2008-04-27 02:50:16 2019-06-24 00:47:32.223022 Accepted closed Database layer (models, ORM) defect normal master fixed Q(a=1, b=2) treated as Q(a=1) | Q(b=2) As far as I can tell from the documentation, arguments to a Q are anded together, e.g. Q(a=1, b=2) is equivalent to Q(a=1) & Q(b=2). However, I am currently finding (in revision 4085) that Q(a=1, b=2) is instead equivalent to Q(a=1) | Q(b=2). In this particular case, I am doing something like: q1 = Q(a=1, b=2) q2 = Q(a=3, b=4) model.objects.filter(q1 | q2) When I look at connection.queries, I find that there is no parenthesization at all, and all of the terms are combined with OR like "a=1 OR b=2 OR a=3 OR b=4" instead of "(a=1 AND b=2) OR (a=3 AND b=4)". I made my description a little bit abstract for clarity, but I can post the exact queries if necessary. Right now I'm working around the problem by doing something of the form: q1 = Q(a=1) & Q(b=2) etc., which gives the query I expected. I hope this report is clear. Let me know if you have any questions. nobody Andrew McNabb <amcnabb@mcnabbs.org> qs-rf-fixed 0 0 0 0 0 0
3141 2006-12-14 05:36:52 2008-04-27 02:50:16 2019-06-24 00:48:43.427548 Accepted closed Database layer (models, ORM) defect normal master fixed can't use count() on querysets when extra() has been used with params. there seems to be a bug in django/db/models/query.py when using extra() with params on a queryset. the queryset is generated correctly, i can access it, iterate through it, but i can't count() it. {{{ #!python >>> from django.contrib.auth.models import User >>> u = User.objects.filter(pk=1).extra(select={'foo': '%s'}, params=['1']) >>> u[0].foo '1' >>> u.count() Traceback (most recent call last): File "<console>", line 1, in ? File "/Volumes/Singularity/Projects/django/django/db/models/query.py", line 202, in count cursor.execute("SELECT COUNT(*)" + sql, params) File "/Volumes/Singularity/Projects/django/django/db/backends/util.py", line 19, in execute self.db.queries.append({ TypeError: not all arguments converted during string formatting >>> u = User.objects.filter(pk=1).extra(select={'foo': '1'}) >>> u[0].foo '1' >>> u.count() 1 }}} deepak mrmachine <real dot human at mrmachine dot net> queryset extra params count, qs-rf-fixed 0 1 0 1 0 0
3288 2007-01-12 13:50:15 2008-04-27 02:50:16 2019-06-24 00:50:16.586943 Accepted closed Database layer (models, ORM) defect major master fixed ForeignKey to 'self' and select_related() = infinite recursion Maybe it's a variant of #3045 bug. The [simplified] case is {{{ #!python class Foo(models.Model): parent = models.ForeignKey('self') class Meta: db_table = 'foos' foo = Foo.objects.select_related().get(pk=1) }}} That leads to infinite recursion in django.db.models.query.fill_table_cache. The bottom of the stack trace is: {{{ ........ many many lines ............ File "/home/maxim/dproject/django/db/models/query.py", line 684, in fill_table_cache fill_table_cache(f.rel.to._meta, select, tables, where, db_table, cache_tables_seen) File "/home/maxim/dproject/django/db/models/query.py", line 684, in fill_table_cache fill_table_cache(f.rel.to._meta, select, tables, where, db_table, cache_tables_seen) File "/home/maxim/dproject/django/db/models/query.py", line 681, in fill_table_cache where.append('%s.%s = %s.%s' % \ File "/home/maxim/dproject/django/db/models/fields/related.py", line 737, in get_related_field return self.to._meta.get_field(self.field_name) File "/home/maxim/dproject/django/db/models/options.py", line 98, in get_field if f.name == name: RuntimeError: maximum recursion depth exceeded in cmp }}} PhiR Max Derkachev <mderk@yandex.ru> qs-rf-fixed 0 1 1 0 0 0
3440 2007-02-06 01:23:30 2008-04-27 02:50:16 2019-06-24 00:51:52.883965 Fixed on a branch closed Database layer (models, ORM)     queryset-refactor fixed DateQuerySet.iterator not iterable if empty The changes in r4394 to support empty QuerySets does not work for `DateQuerySet.iterator()` because the method is not a generator, but instead returns an iterable. Instead of raising a `StopIteration` it should return an empty list. Also, the other methods that are generators (e.g. `QuerySet.iterator()`) raise a `StopIteration` when they could simply return. adrian ashleywalsh@gmail.com qs-rf-fixed 0 1 0 0 0 0
3739 2007-03-15 22:07:57 2008-04-27 02:50:16 2019-06-24 00:55:00.940498 Accepted closed Database layer (models, ORM)     master fixed Add .all() method to QuerySets Per Google Groups discussion [http://groups.google.com/group/django-users/browse_frm/thread/5fed0f7c47b4ac15 here], I've found that it would be nice if QuerySets exhibited a {{{.all()}}} method so that custom instance-level model methods which return QuerySets could be treated as if they were regular relationship-generated Manager objects. The attached patch adds this to 0.95.1 and I can put together a unittest if needed. nobody Jeff Forcier <reg@bitprophet.org> qs-rf-fixed 0 1 1 0 0 0
4088 2007-04-19 16:34:21 2008-04-27 02:50:16 2019-06-24 00:58:39.844923 Accepted closed Database layer (models, ORM)     master fixed Not able to filter() on foreign keys. I'm trying to filter by a value that is contained in a foreign key. I've seen this done in the django documentation (the blog example). Here are my models: {{{ class Students(models.Model): ssn = models.CharField(unique=True, maxlength=11) name = models.CharField(blank=True, maxlength=50) address = models.CharField(blank=True, maxlength=50) dob = models.DateField(null=True, blank=True) email = models.CharField(blank=True, maxlength=50) level = models.CharField(blank=True, maxlength=5) def __str__(self): return self.ssn class Takes(models.Model): student = models.ForeignKey(Students, to_field='ssn', db_index=True, db_column='ssn') course = models.ForeignKey(Courses, to_field='cid', db_index=True, db_column='cid') semester = models.ForeignKey(Semesters, to_field='sname', db_index=True, db_column='sname') grade = models.CharField(blank=True, maxlength=2) def __str__(self): return "%s - %s" % (self.course.cid, self.semester.sname) }}} The other models aren't relevant to the question. We are just focusing on the student foreign key inside Takes. Now, here is an example of me trying to filter by someone's name {{{ >>> Takes.objects.filter(student__name="Kevin Smith") [] >>> Takes.objects.get(id=1).student.name 'Kevin Smith' >>> }}} I've also tried every combination of icontains. To circumvent this, I've been using the code below (if it helps) {{{ takes = Takes.objects.all() takes2 = [] for x in takes: if (x.student.name).lower().find("kev".lower()) != -1: takes2.append(x) }}} And takes2[0].student.name returns "Kevin Smith". Maybe I'm missing something totally, which I would love to know. But this feels like a bug to me. nobody no@binds.net filter foreignkey, qs-rf-fixed 0 1 0 1 0 0
4260 2007-05-10 04:32:10 2008-04-27 02:50:16 2019-06-24 01:00:28.956548 Accepted closed Database layer (models, ORM)     master fixed add an update method to QuerySet One should be able to update multiple records at once with something like {{{ #!python User.objects.all().update(is_active=True) }}} instead of having to update one at a time with something like {{{ #!python for user in User.objects.all(): user.is_active = True user.save() }}} nobody Gary Wilson <gary.wilson@gmail.com> qs-rf-fixed 0 1 0 1 1 0
4289 2007-05-14 07:04:13 2008-04-27 02:50:16 2019-06-24 01:00:47.709102 Accepted closed Database layer (models, ORM)     master fixed Misbehaving Q objects Hi, The following ticket will try to highlight a problem that I have found when using the 'OR' operator on Q objects in the boulder-oracle-sprint branch. My model looks like this. {{{ class Test(models.Model): num = models.IntegerField() def __str__(self): return 'num=%d'%self.num }}} The following code will highlight the bug: {{{ In [1]: from testapp.models import * In [2]: from django.db.models import Q In [3]: for i in [4,8,12]: ...: Test(num=i).save() ...: In [4]: Test.objects.filter(num__lt=4) Out[4]: [] In [5]: Test.objects.filter(num__gt=8, num__lt=12) Out[5]: [] In [6]: Test.objects.filter(Q(num__lt = 4) | Q(num__gt=8, num__lt=12)) Out[6]: [<Test: num=12>, <Test: num=4>, <Test: num=8>] In [7]: Test.objects.filter(Q(num__gt=8, num__lt=12) | Q(num__lt = 4)) Out[7]: [<Test: num=12>, <Test: num=4>, <Test: num=8>] In [8]: Test.objects.filter(Q(num__gt=8) & Q(num__lt=12) | Q(num__lt = 4)) Out[8]: [] }}} Lines 6 and 7 illustrate the bug. The query appears to indicate that there are three Test objects where 'num' is less than 4 or, greater than 8 and less than 12. Lines 4 and 5 show that no such object should exist. Line 8 shows how I would expect the query to run. The following is the formated (but otherwise unmodified) SQL query produced by django. {{{ SELECT * FROM "TESTAPP_TEST" WHERE (("TESTAPP_TEST"."NUM" < 4 OR "TESTAPP_TEST"."NUM" > 8 OR "TESTAPP_TEST"."NUM" < 12)) }}} The issue is that the second 'OR' operator should be an AND operator. Also for the sake of safety/sanity I feel that queries specified within the Q objects should also be surrounded by a bracket. The corrected query should read {{{ SELECT * FROM "TESTAPP_TEST" WHERE ((("TESTAPP_TEST"."NUM" < 4) OR ("TESTAPP_TEST"."NUM" > 8 AND "TESTAPP_TEST"."NUM" < 12))) }}} Regards Ben [[BR]] nobody Ben Khoo Q Oracle sqlite OR qs-rf-fixed 0 0 0 0 0 0
4306 2007-05-15 21:55:02 2008-04-27 02:50:16 2019-06-24 01:00:58.520270 Accepted closed Database layer (models, ORM)     master fixed 'to_field' breaks lookups that span relationships {{{ #!python class Website(models.Model): id = models.IntegerField(primary_key=True) dfp_id = models.IntegerField() name = models.CharField(maxlength=300) url = models.CharField(maxlength=150) class Report(models.Model): id = models.IntegerField(primary_key=True) site = models.ForeignKey(Website, to_field='dfp_id') }}} 444549 is a valid dfp_id in the Website model. {{{ Report.objects.filter(site=444549) <-- Returns results. good. Report.objects.filter(site__id=444549) <-- Returns results, but it shouldn't. Report.objects.filter(site__dfp_id=444549) <-- No results, but it should. }}} 130 is the valid id for a Website. {{{ Report.objects.filter(site__id=130) <- No results, no work around. Report.objects.filter(site__name='Validname') <- Also no results. Report.objects.filter(site__url='validurl.com') <- Also no results }}} nobody shwag qs-rf-fixed 0 0 0 0 0 0
4358 2007-05-22 09:11:53 2008-04-27 02:50:16 2019-06-24 01:01:31.457425 Accepted closed Database layer (models, ORM)     master fixed Inconsistent results between .values() and .values('field') when field is an fkey In a model with a !ForeignKey, (say Choice from the poll example), Choice.objects.values() will show one field as 'poll_id' for the !ForeignKey. However, if you want to select only that value, Choice.objects.values('poll_id') will raise !FieldDoesNotExist. Instead it requires you to do Choice.objects.values('poll') and returns the values in the key 'poll' nobody Collin Grady <cgrady@the-magi.us> qs-rf-fixed 0 0 0 0 0 0
4464 2007-06-02 17:47:28 2008-04-27 02:50:16 2019-06-24 01:02:39.742411 Accepted closed Database layer (models, ORM)     master fixed Chaining filters on ManyToManyFields broken? The last part of this fails (with MySql 5): {{{ from django.db import models class Category(models.Model): name=models.CharField(maxlength=40) class Thing(models.Model): """ >>> cat1 = Category.objects.create(name="cat2") >>> cat1.save() >>> cat2 = Category.objects.create(name="cat2") >>> cat2.save() >>> my_thing = Thing.objects.create(name="My thing") >>> my_thing.save() >>> my_thing.categories = [cat1, cat2] >>> Thing.objects.filter(categories=cat1) [<Thing: My thing>] >>> Thing.objects.filter(categories=cat2) [<Thing: My thing>] >>> Thing.objects.filter(categories=cat1).filter(categories=cat2) [<Thing: My thing>] """ name=models.CharField(maxlength=40) categories = models.ManyToManyField(Category) def __str__(self): return self.name }}} Am I right in thinking that ought to pass? nobody ml_django25@joebutton.co.uk manytomany, manytomanyfield, qs-rf-fixed 0 0 0 0 0 0
4510 2007-06-08 17:58:58 2008-04-27 02:50:16 2019-06-24 01:03:09.461651 Accepted closed Database layer (models, ORM)     0.96 fixed Reverse relationship ignores to_field The db-api is constructing a query that uses 'id' as the key for the join, when it should be using the to_field='dfp_id' as specified in the model. {{{ Ad.objects.get(report__date__gte="2007-06-01") SELECT ... FROM `campaign_line_item_ads` INNER JOIN `reports` AS `campaign_line_item_ads__report` ON `campaign_line_item_ads`.`id` <-- HERE = `campaign_line_item_ads__report`.`ad_id` WHERE (`campaign_line_item_ads__report`.`date` >= '2007-06-01') class Ad(models.Model): id = models.IntegerField(primary_key=True) campaign_line_item = models.ForeignKey(CampaignLineItem) dfp_id = models.IntegerField(null=True, blank=True) name = models.CharField(blank=True, maxlength=765) class Meta: db_table = 'campaign_line_item_ads' ordering = ['name'] def __str__(self): return self.name class Report(models.Model): id = models.IntegerField(primary_key=True) date = models.DateField(null=True, blank=True) ad = models.ForeignKey(Ad, to_field='dfp_id') <-- Here measure = models.IntegerField(null=True, blank=True) class Meta: db_table = 'reports' }}} nobody Steven Wagner <stevenwagner@gmail.com> to_field, qs-rf-fixed 0 0 0 0 0 0
4858 2007-07-12 21:04:18 2008-04-27 02:50:16 2019-06-24 01:06:52.857373 Accepted closed Database layer (models, ORM)     master fixed Add support for ~ to Q objects for negation At present there's no quick way to negate a Q object, so if you need something that {{{.filter()}}} and {{{.exclude()}}} can't do, such as {{{Q(A) AND ((NOT Q(B) OR Q(C))}}}, it's a bit awkward as you have to use {{{QNot(Q(B))}}}. Attached patch would allow {{{Q(A) & (~Q(B) | Q(C))}}} using the bitwise NOT, similar to the bitwise AND and OR already in use. nobody Collin Grady <cgrady@the-magi.us> qs-rf-fixed 0 1 0 0 0 0
5012 2007-07-29 23:44:23 2008-04-27 02:50:16 2019-06-24 01:08:32.606280 Accepted closed Database layer (models, ORM)     master fixed Allow QuerySets to handle offsets without limits and negative slicing This patch allows `QuerySet`s to: 1. use negative slicing (with the caveat that they require explicit ordering) and 2. use offsets without limits (eg `Entries.objects.all()[5:]`) So really it's two separate features, but negative slicing was the feature I was trying to implement and to make it work in a logical way it required fixing offsets without limits. Feature 2 requires a change to the db backends. All except Oracle (because the comment in `django.db.backends.oracle.base::get_limit_offset_sql` says it's handled in `./query.py` but that file doesn't exist) and MS-SQL (because it never worked there to begin with). nobody SmileyChris qs-rf-fixed 0 1 0 0 0 0
5020 2007-07-30 19:45:01 2008-04-27 02:50:16 2019-06-24 01:08:37.745175 Accepted closed Database layer (models, ORM)     master fixed select_related() implicit joins Add support for implicitly selecting fields to join with. e.g. !MyModel.objects.all().select_related('myforeignkey!__user') See also: [http://groups.google.com/group/django-developers/browse_thread/thread/3b33bfe1e625b4ad/06b0a5f39e08d17d#06b0a5f39e08d17d] nobody David Cramer <dcramer@gmail.com> qs-rf-fixed 0 1 0 0 1 0
5261 2007-08-26 03:55:17 2008-04-27 02:50:16 2019-06-24 01:11:15.840928 Accepted closed Database layer (models, ORM)     master fixed exclude on an empty Q object results in invalid SQL This is a minor corner case, but as it results in invalid SQL, I figured it should be fixed. sqlite3: {{{ >>> Proposal.objects.exclude(Q()) Traceback (most recent call last): File "<console>", line 1, in <module> File ".\django\db\models\query.py", line 107, in __repr__ return repr(self._get_data()) File ".\django\db\models\query.py", line 480, in _get_data self._result_cache = list(self.iterator()) File ".\django\db\models\query.py", line 188, in iterator cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File ".\django\db\backends\util.py", line 19, in execute return self.cursor.execute(sql, params) File ".\django\db\backends\sqlite3\base.py", line 94, in execute return Database.Cursor.execute(self, query, params) OperationalError: near ")": syntax error >>> }}} postgresql: {{{ >>> Proposal.objects.exclude(Q()) Traceback (most recent call last): File "<console>", line 1, in <module> File ".\django\db\models\query.py", line 107, in __repr__ return repr(self._get_data()) File ".\django\db\models\query.py", line 480, in _get_data self._result_cache = list(self.iterator()) File ".\django\db\models\query.py", line 188, in iterator cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File ".\django\db\backends\util.py", line 19, in execute return self.cursor.execute(sql, params) ProgrammingError: syntax error at or near ")" LINE 1: ...l"."updated" FROM "propmgr_proposal" WHERE ((NOT ())) ORDER ... ^ >>> }}}   django@dougma,com exclude Q, qs-rf-fixed 0 0 0 0 0 0
5295 2007-08-29 20:03:42 2008-04-27 02:50:16 2019-06-24 01:11:48.024893 Accepted closed Database layer (models, ORM)     master fixed Inner Join and order_by bug I found a problem using an inner join; these are some of my classes: {{{ class Egreso(models.Model): id_egreso = models.AutoField(primary_key=True, db_index=True, db_column="id_egreso") id_usuario = models.ForeignKey(Usuario, db_index=True, db_column="id_usuario") fecha_ingreso = models.DateTimeField(auto_now=True) class Proveedor_combustible(models.Model): nombre = models.CharField(maxlength=200, unique=True) def __unicode__(self): return self.nombre class Combustible(models.Model): id_egreso = models.ForeignKey(Egreso, db_index=True, db_column="id_egreso") numero_factura = models.PositiveIntegerField(null=True) proveedor = models.ForeignKey(Proveedor_combustible, db_column="proveedor") precio = models.CharField(maxlength=50) def __unicode__(self): return self.numero_factura class Meta: unique_together = ('numero_factura', 'proveedor'), }}} I want to execute a inner join and ordering the results using the right table, I always just did raw queries but now I tried to understand better the django api. This is the query I executed: {{{ Combustible.objects.filter(id_egreso__id_usuario=id_usuario).order_by('gestion_combustible.fecha_ingreso') }}} However it fails because Django use an alias for the inner join; here is the SQL query that Django shows: {{{ SELECT "gestion_combustible"."id","gestion_combustible"."id_egreso","gestion_combustible"."numero_factura","gestion_combustible"."proveedor","gestion_combustible"."precio" FROM "gestion_combustible" INNER JOIN "gestion_egreso" AS "gestion_combustible__id_egreso" ON "gestion_combustible"."id_egreso" = "gestion_combustible__id_egreso"."id_egreso" WHERE ("gestion_combustible__id_egreso"."id_usuario" = '1') ORDER BY "gestion_egreso"."fecha_ingreso" ASC }}} As you can see the 2nd table is called gestion_egreso but the alias is called gestion_combustible_id_egreso so the ORDER BY should be done using the alias name not the field name. So far, the field name is used so it fails. The… anonymous MarioGonzalez <gonzalemario @t gmail.com> qs-rf-fixed 0 1 0 1 0 0
5321 2007-09-02 10:39:19 2008-04-27 02:50:16 2019-06-24 01:12:05.729724 Accepted closed Database layer (models, ORM)     master fixed PostgreSQL fails on a ValuesQuerySet which is ordered by a field not in the fields list This bug was found by accident while trying to provide a control test for #2939. Basically, the failing test is: {{{ #!python Article.objects.values('pub_date').distinct() }}} Which fails on Postgres with `for SELECT DISTINCT, ORDER BY expressions must appear in select list` nobody SmileyChris qs-rf-fixed 0 0 0 0 0 0
5324 2007-09-03 07:44:41 2008-04-27 02:50:16 2019-06-24 01:12:07.788984 Accepted closed Core (Other)     master fixed queryset exclude fails across a many-to-many list If you try to exclude items from a queryset across a m2m link, it fails to give the expected result. For instance, assuming I have users, some of whom are in group Editors, some in group Sales, and most are not in a group at all. {{{ #!python from django.contrib.auth.models import User user_qs = User.objects.all() # all users non_editor_users = user_qs.exclude(groups__name='Editors') # should be all users excluding those in group Editors }}} The set wrongly returned is actually the set of users who are in Sales but not in Editors - it fails to include those users who have no group at all. The reason is the sql clause generated, which is doing {{{ FROM "auth_user" LEFT OUTER JOIN "auth_user_groups" AS "m2m_auth_user__groups" ON "auth_user"."id" = "m2m_auth_user__groups"."user_id" INNER JOIN "auth_group" AS "auth_user__groups" ON "m2m_auth_user__groups"."group_id" = "auth_user__groups"."id" WHERE ((NOT ("auth_user__groups"."name" = %s))) ORDER BY "auth_user"."username" ASC', ['Editors'] }}} A workaround for this was posted some time back in http://groups.google.com/group/django-users/browse_thread/thread/81eb405071037248/2beb073a93fd68b7 I can't find a ticket for it - please excuse me if it's a duplicate. I guess #2091 might be related under the hood. nobody Robert Bunting <robert@exoweb.net> exclude m2m many-to-many, qs-rf-fixed 0 0 0 0 0 0
5325 2007-09-03 13:04:04 2008-04-27 02:50:16 2019-06-24 01:12:08.390113 Unreviewed closed Documentation     master fixed max_length should be maxlength when i copy/pasted this line from the documentation and tryed to reset my app i found the following mistake: gender = models.CharField('''max_length'''=1, choices=GENDER_CHOICES) should be gender = models.CharField('''maxlength'''=1, choices=GENDER_CHOICES) jacob tine.klancar@delo.si   0 0 0 0 0 0
5352 2007-09-06 23:03:26 2008-04-27 02:51:30 2019-06-24 01:12:25.814729 Accepted closed Database layer (models, ORM)     master fixed queryset doesn't honor slicing limits I noticed this issue today when slicing a query set. {{{ >>> mylist = UserProfile.objects.all()[:20] >>> mylist[20] # Should raise index error <UserProfile: UserProfile object> >>> mylist[2055] <UserProfile: UserProfile object> >>> len(mylist) 20 >>> mylist[20] # Only raises IndexError after I call len() on the queryset Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.5/site-packages/django/db/models/query.py", line 155, in __getitem__ return self._result_cache[k] IndexError: list index out of range }}} nobody pjs@petersanchez.com qs-rf-fixed 0 0 0 0 0 0
5555 2007-09-20 10:41:53 2008-04-27 02:50:16 2019-06-24 01:14:40.891559 Accepted closed Database layer (models, ORM)     master fixed Django fails to do .dates query on sqlite {{{ In [12]: d=Post.objects.dates('date_published', 'month') In [14]: d Out[14]: [datetime.datetime(2007, 9, 1, 0, 0)] In [13]: d[0] --------------------------------------------------------------------------- <class 'sqlite3.OperationalError'> Traceback (most recent call last) /home/farcaller/develop/web/fw/<ipython console> in <module>() /usr/lib/python2.5/site-packages/django/db/models/query.py in __getitem__(self, k) 155 else: 156 try: --> 157 return list(self._clone(_offset=k, _limit=1))[0] 158 except self.model.DoesNotExist, e: 159 raise IndexError, e.args /usr/lib/python2.5/site-packages/django/db/models/query.py in __iter__(self) 112 113 def __iter__(self): --> 114 return iter(self._get_data()) 115 116 def __getitem__(self, k): /usr/lib/python2.5/site-packages/django/db/models/query.py in _get_data(self) 480 def _get_data(self): 481 if self._result_cache is None: --> 482 self._result_cache = list(self.iterator()) 483 return self._result_cache 484 /usr/lib/python2.5/site-packages/django/db/models/query.py in iterator(self) 661 qn(self._field.column))), sql, group_by, self._order) 662 cursor = connection.cursor() --> 663 cursor.execute(sql, params) 664 665 has_resolve_columns = hasattr(self, 'resolve_columns') /usr/lib/python2.5/site-packages/django/db/backends/util.py in execute(self, sql, params) 17 start = time() 18 try: ---> 19 return self.cursor.execute(sql, params) 20 finally: 21 stop = time() /usr/lib/python2.5/site-packages/django/db/backends/sqlite3/base.py in execute(self, query, params) 127 def execute(self, query, params=()): 128 query = self.convert_query(query, len(params)) --> 129 return Database.Cursor.execute… nobody Vladimir Pouzanov <farcaller@gmail.com> qs-rf-fixed 0 0 0 0 0 0
5707 2007-10-08 17:37:24 2008-04-27 02:50:16 2019-06-24 01:16:19.350965 Accepted closed Database layer (models, ORM)     master fixed Aliases truncated to 64 characters on Postgres With a large join or long table names, postgres will truncate the aliases of the tables to 64 characters resulting in duplicate table names on the query. This makes the query unexecutable. One solution is to shorten long alias names. I wrote something that modifies the alias when it is produced in db/models/query.py, but unfortunately, the join conditions get the alias as well, so the change will probably have to ultimately go into the SortedDict class to truncate and make the names unique in 64 characters there. An alternate solution would be to prefix the aliases with incrementing numbers since the truncation will still preserve unique names for the aliases. nobody jhenry@theonion.com qs-rf-fixed 0 0 0 0 0 0
5796 2007-10-22 21:01:54 2008-04-27 02:50:16 2019-06-24 01:17:17.067886 Accepted closed Database layer (models, ORM)     master fixed Make Q() return a boolean value based on it's length The goal would be to allow you to do a boolean check on a Q() object to see if it actually contains any statements. >>> x = Q() >>> x >>> <django.db.models.query.Q object at 0x275a410> >>> bool(x) >>> True This would return False, and thus allow you to check the Q() instance to see if it actually has values. Django falls back just fine with empty Q() objects, this is just a small nicety. nobody dcramer qs-rf-fixed 0 0 0 0 0 0
5817 2007-10-25 13:17:23 2008-04-27 02:50:16 2019-06-24 01:17:30.587866 Fixed on a branch closed Core (Other)     master fixed Support inheritance for model option classes This currently is not possible: {{{ class BaseMeta(object): app_label = "myapp" class Company(models.Model): class Meta(BaseMeta): pass }}} The reason is that db.models.options.Options.contribute_to_class() uses !__dict!__ to determine which attributes have been given. It attempts to delete from !__dict!__, which apparently is not allowed for new-style classes, but !__dict!__ will not include attributes of superclasses anyway. I attached a simple patch that uses dir() instead - if been using it for a while and there don't seem to be any problems. Note that the patch will *not* allow custom meta attributes by prefixing them with !__: {{{metakritik.site: 'class Meta' got invalid attribute(s): _BaseMeta__myopt}}} nobody miracle2k qs-rf-fixed 0 1 0 0 0 0
5987 2007-11-19 22:10:09 2008-04-27 02:50:16 2019-06-24 01:19:20.688567 Accepted closed Database layer (models, ORM)     master fixed __iter__ on a QuerySet doesn't return an efficient iterator For a loop such as: {{{ for item in Model.objects.all(): print item # or whatever }}} the first line eats up all system memory for sufficiently large Models. Replacing it with Model.objects.all().iterator() improves the situation a lot. Why doesn't __iter__ return iterator()? (I see that __iter__ can use a cache. Is there a reason not to compute the cache on-the-fly?) nobody kenneth.arnold@gmail.com iterator __iter__ qs-rf-fixed 0 0 0 0 0 0
6018 2007-11-23 10:49:26 2008-04-27 02:50:16 2019-06-24 01:19:40.817111 Accepted closed Database layer (models, ORM)     master fixed [patch] depth handling in fill_table_cache broken when using select_related(depth=1).extra() As reported by marcin@elksoft.pl in #3275: There is a bug in the way depth is handled in fill_table_cache, see ''the attached patch'' for a test case. When you specify a non-zero depth fill_table_cache goes one relationship too deep which causes get_cached_row not to handle all the columns from select_related. This bug shows up when you use extra on that Query``Set: the extra fields to select should immediately follow columns handled by get_cached_row, but instead they get data from the relationship that fill_table_cache added and get_cached_row skipped. ---- I'm re-posting this bug (and his patches) here because #3275 is, essentially, an unrelated ticket; IMHO this here patch should go into mainline ASAP. nobody Matthias Urlichs <smurf@smurf.noris.de> qs-rf-fixed 0 1 0 0 0 0
6074 2007-12-01 12:09:39 2008-04-27 02:50:16 2019-06-24 01:20:17.011820 Accepted closed Database layer (models, ORM)     master fixed QOr doesn't handle two empty ResultSets correctly {{{ >>> from django.db.models import Q >>> from django.contrib.auth.models import User >>> User.objects.filter( Q( id__in=[] ) | Q( id__in=[] ) ) }}} Should be empty queryset, but is not whe generated WHERE clause is empty, the problem seems to be around django/db/models/query.py:725 raphael Honza_Kral or Q sql sprintdec01 qs-rf-fixed 0 1 0 0 0 0
6088 2007-12-01 21:09:36 2008-04-27 02:50:16 2019-06-24 01:20:26.029970 Accepted closed Database layer (models, ORM)     master fixed get_previous_in_order broken There's a bug in the SQL generated when calling get_previous_in_order. Luckily looks like a quick fix from where I'm sitting. Just need to change the ordering to DESC from ASC. nobody James Wheare <django@sparemint.com> qs-rf-fixed 0 1 0 0 0 0
6154 2007-12-07 18:50:06 2008-04-27 02:50:16 2019-06-24 01:21:08.563253 Accepted closed Database layer (models, ORM)     master fixed Q objects don't work properly when using spanned relationships {{{ >>> from wcenter.models import Website, Domain >>> from django.db.models import Q >>> websites = Website.objects.filter(pk__in=[182,183]) >>> d = Domain.objects.get(name='mydomain') >>> websites [<Website: 182>, <Website: 183] }}} Until now, that's fine. Now let's try the following: {{{ >>> q = websites.filter(Q(domain=d) | Q(websitealias__domain=d)) >>> q [<Website: 182>, <Website: 182>] }}} This is the bug. Why is website 183 gone? Here's the SQL (I am not an SQL expert, but maybe Django should use a LEFT JOIN instead of an INNER JOIN): {{{ >>> def show_sql(q): ... cols, sql, args = q._get_sql_clause() ... return "SELECT %s %s" % (', '.join(cols), sql % tuple(args)) ... >>> show_sql(q) 'SELECT `wcenter_website`.`id`, `wcenter_website`.`domain_id`, [...] FROM `wcenter_website` INNER JOIN `wcenter_websitealias` AS `wcenter_website__websitealias` ON `wcenter_website`.`id` = `wcenter_website__websitealias`.`website_id` WHERE (`wcenter_website`.`id` IN (182,183) AND (`wcenter_website`.`domain_id` = 2 OR `wcenter_website__websitealias`.`domain_id` = 2))' >>> show_sql(websites) 'SELECT `wcenter_website`.`id`, `wcenter_website`.`domain_id`, [...] FROM `wcenter_website` WHERE (`wcenter_website`.`id` IN (182,183))' }}} I think the second website is missing because it doesn't have any website aliases: {{{ >>> websites[0].websitealias_set.all() [<WebsiteAlias>, <WebsiteAlias>] >>> websites[1].websitealias_set.all() [] }}} It looks like a LEFT JOIN would solve the problem: {{{ mysql> SELECT `wcenter_website`.`id`, `wcenter_website`.`domain_id` FROM `wcenter_website` LEFT JOIN `wcenter_websitealias` AS `wcenter_website__websitealias` ON `wcenter_website`.`id` = `wcenter_website__websitealias`.`website_id` WHERE (`wcenter_website`.`id` IN (182,183) AND (`wcenter_website`.`domain_id` = 2)); +-----+-----------+ | id | domain_id | +-----+-----------+ | 182 | 2 | | 182 | 2 | | 183 | 2 | +-----+-----------+ 3 rows in set (0.00 sec) … nobody Thomas Steinacher <tom@eggdrop.ch> qs-rf-fixed 0 0 0 0 0 0
6177 2007-12-11 05:58:36 2008-04-27 02:50:16 2019-06-24 01:21:23.484997 Fixed on a branch closed Database layer (models, ORM)     master fixed Only managers have a none() method (not Querysets) For compatibility with `QuerySet`. {{{ >>> User.objects.all().values().none() Traceback (most recent call last): File "<console>", line 1, in ? AttributeError: 'ValuesQuerySet' object has no attribute 'none' }}} nobody gwilson qs-rf-fixed 0 0 0 0 0 0
6180 2007-12-11 13:35:25 2008-04-27 02:50:16 2019-06-24 01:21:25.400838 Accepted closed Database layer (models, ORM)     master fixed DateQuerySet fails with LIMIT (on psycopg2) [http://www.djangoproject.com/documentation/db-api/#dates-field-kind-order-asc DateQuerySets] fail when limiting, the set needs to be resolved before accessing any single object. This fails: {{{ Order.objects.dates('created_at', 'month')[0] }}} with: {{{ <class 'psycopg2.ProgrammingError'> Traceback (most recent call last) /home/hukka/dev/tarjontajakysynta/<ipython console> in <module>() /usr/lib/python2.5/site-packages/django/db/models/query.py in __getitem__(self, k) 155 else: 156 try: --> 157 return list(self._clone(_offset=k, _limit=1))[0] 158 except self.model.DoesNotExist, e: 159 raise IndexError, e.args /usr/lib/python2.5/site-packages/django/db/models/query.py in __iter__(self) 112 113 def __iter__(self): --> 114 return iter(self._get_data()) 115 116 def __getitem__(self, k): /usr/lib/python2.5/site-packages/django/db/models/query.py in _get_data(self) 480 def _get_data(self): 481 if self._result_cache is None: --> 482 self._result_cache = list(self.iterator()) 483 return self._result_cache 484 /usr/lib/python2.5/site-packages/django/db/models/query.py in iterator(self) 661 qn(self._field.column))), sql, group_by, self._order) 662 cursor = connection.cursor() --> 663 cursor.execute(sql, params) 664 665 has_resolve_columns = hasattr(self, 'resolve_columns') /usr/lib/python2.5/site-packages/django/db/backends/util.py in execute(self, sql, params) 16 start = time() 17 try: ---> 18 return self.cursor.execute(sql, params) 19 finally: 20 stop = time() <class 'psycopg2.ProgrammingError'>: syntax error at or near "GROUP" LINE 1: ...r"."created_at") FROM "companies_order" LIMIT 1 GROUP BY 1... }}} This works: {{{ list(Order.objects.dates('created_at… nobody anonymous DateQuerySet dates psycopg2 qs-rf-fixed 0 0 0 0 0 0
6203 2007-12-13 13:41:34 2008-04-27 02:50:16 2019-06-24 01:21:40.003243 Accepted closed Database layer (models, ORM)     master fixed .count() not working with DateQuerySet returned from .dates() The problem is the following: Readout.objects.dates('timestamp', 'day').count() -> returns 2712 len(Readout.objects.dates('timestamp', 'day')) -> returns 12 I've been using len(), but then noticed that the documentation for count() suggests using count() instead for performance reasons. I didn't expect to see different results, though. :-) nobody olau@iola.dk qs-rf-fixed 0 0 0 0 0 0
6658 2008-02-25 04:31:31 2008-04-27 02:50:16 2019-06-24 01:26:34.790016 Fixed on a branch closed Database layer (models, ORM)     master fixed Unexpected select_related() behaviour select_related() sometimes seems to break queries with multiple chained .exclude's. Let's say we're having the following example: {{{ Thread.objects.exclude(forum__type = 'fcin').exclude(forum__type = 'stin').exclude(forum__type = 'suin').exclude(forum__type = 'fc').order_by('-creationDate')[:8] }}} returns: {{{ u'SELECT `forum_thread`.`id`,`forum_thread`.`forum_id`,`forum_thread`.`headline`,`forum_thread`.`author_id`,`forum_thread`.`author_user_id`,`forum_thread`.`text`,`forum_thread`.`creationDate`,`forum_thread`.`updateDate`,`forum_thread`.`hitCount` FROM `forum_thread` INNER JOIN `forum_forum` AS `forum_thread__forum` ON `forum_thread`.`forum_id` = `forum_thread__forum`.`id` WHERE ((NOT (`forum_thread__forum`.`type` = fcin)) AND (NOT (`forum_thread__forum`.`type` = stin)) AND (NOT (`forum_thread__forum`.`type` = suin)) AND (NOT (`forum_thread__forum`.`type` = fc))) ORDER BY `forum_thread`.`creationDate` DESC LIMIT 8 ' }}} resulting in three results {{{ Thread.objects.select_related().exclude(forum__type = 'fcin').exclude(forum__type = 'stin').exclude(forum__type = 'suin').exclude(forum__type = 'fc').order_by('-creationDate')[:8] }}} returns: {{{ u'SELECT `forum_thread`.`id`,`forum_thread`.`forum_id`,`forum_thread`.`headline`,`forum_thread`.`author_id`,`forum_thread`.`author_user_id`,`forum_thread`.`text`,`forum_thread`.`creationDate`,`forum_thread`.`updateDate`,`forum_thread`.`hitCount`,`forum_forum`.`id`,`forum_forum`.`parent_id`,`forum_forum`.`name`,`forum_forum`.`description`,`forum_forum`.`type`,`forum_forum`.`hitCount`,`forum_forum`.`forumFCTeam_id`,`forum_forum`.`forumFCPlayer_id`,`community_userprofile`.`id`,`community_userprofile`.`gender`,`community_userprofile`.`birthdaydate`,`community_userprofile`.`city`,`community_userprofile`.`zip`,`community_userprofile`.`picture`,`community_userprofile`.`organisation`,`community_userprofile`.`taskInOrganisation`,`community_userprofile`.`ICQ`,`community_userprofile`.`MSN`,`community_userprofile`.`Skype`,`community_userprofile… nobody panni@fragstore.net select_related, exclude qs-rf-fixed 0 0 0 0 0 0
7087 2008-04-25 20:01:23 2008-04-27 00:45:17 2019-06-24 01:31:18.931116 Unreviewed closed Database layer (models, ORM)     queryset-refactor fixed QuerySet.dates bug in Oracle The DateQuery.results_iter method doesn't account for the possibility of extra selects and just returns the first column from the results. When the query is subscripted in Oracle, that ends up being the row number. mtredinnick ikelly   0 1 0 0 0 0
7093 2008-04-26 19:04:53 2008-04-27 01:09:11 2019-06-24 01:31:22.670103 Unreviewed closed Translations     master fixed Typo in russian djangojs translation There is a single typo, in the "Choose a time" string. Suggested patch included.. nobody Anossov typo 0 1 0 0 0 0
7094 2008-04-27 12:26:29 2008-04-27 15:33:22 2019-06-24 01:31:23.289320 Accepted closed contrib.admin     newforms-admin fixed Ordering in the admin has no effect after [7477] After doing a merge from trunk I have noticed that ordering in ```ChangeList``` is not taking affect. I have used pdb to determine that the correct data is being passed into ```order_by``` on the queryset, but not sure what is tripping it up. Creating a ticket so this issue is not lost and so that others are aware and may find a solution before me. nobody brosner   0 0 0 0 0 0

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE "tickets_full" (
        id int primary key,
        created datetime,
        changetime datetime,
        last_pulled_from_trac datetime,
        stage text,
        status text,
        component text,
        type text,
        severity text,
        version text,
        resolution text,
        summary text,
        description text,
        owner text,
        reporter text,
        keywords text,
        easy boolean,
        has_patch boolean,
        needs_better_patch boolean,
        needs_tests boolean,
        needs_docs boolean,
        ui_ux boolean
    );