Django

Code

Ticket #5796 (closed: fixed)

Opened 7 months ago

Last modified 3 weeks ago

Make Q() return a boolean value based on it's length

Reported by: dcramer Assigned to: nobody
Component: Database wrapper Version: SVN
Keywords: qs-rf-fixed Cc:
Triage Stage: Accepted Has patch: 0
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

Description

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.

Attachments

Change History

10/22/07 19:49:39 changed by mtredinnick

  • keywords set to qs-rf-fixed.
  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

Thanks to the magic of time machines, this is already true with Q objects on the queryset-refactor branch. This ticket will be closed when the branch is merged into trunk.

04/26/08 21:50:16 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [7477]) Merged the queryset-refactor branch into trunk.

This is a big internal change, but mostly backwards compatible with existing code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658


Add/Change #5796 (Make Q() return a boolean value based on it's length)




Change Properties
Action