﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18221	"Add ""Length"" database function"	Danilo Bargen	nobody	"Maybe I'm blind, but I can't find a way to use aggregation functions on the length of a database field.

I want to achieve the following:

{{{
#!sql
SELECT MAX(LENGTH(name)) AS max_name_length FROM table;
}}}

The natural way to do this with the Django ORM would be something like this:

{{{
#!python
Model.objects.annotate(name_length=Length('name')).aggregate(Max('name_length'))
}}}

Unfortunately there is no such `Length()` function. A workaround of doing the annotation would be using `extra(select={'name_length': 'LENGTH(name)'})`, but then the aggregation doesn't work anymore.

My suggestion would be to add such a `Length()` function."	New feature	closed	Database layer (models, ORM)	1.3	Normal	wontfix			Unreviewed	0	0	0	0	1	0
