martsberger / django-pivot

A module for pivoting Django Querysets
MIT License
209 stars 16 forks source link

Column values that contain spaces don't work (and doc might improve a smidgeon) #26

Closed bernd-wechner closed 11 months ago

bernd-wechner commented 1 year ago

I really like that's been done here.

I gave it a quick spin though on some test models and immediately had it crash. Turns out that is the column values have spaces in them if bombs with:

ValueError: Column aliases cannot contain whitespace characters, quotation marks, semicolons, or SQL comments.

which happens when you try to apply the annotations.

Row values can tolerate spaces.

The small improvement I'd make to the doc is in the basic intro:

The pivot function

Pivot tables are generated by the pivot function, which takes a Model and 3 attribute names, to make a pivot table like the example above:

Where I'd simply describe what each argument actually does. I'm sort of inferring at present so would not call thus definitive but on suggestion:

The pivot function

Pivot tables are generated by the pivot function, which takes a Model and 3 attribute names (the first provides values for the row keys, the second values for the column keys and the third the values in the table), to make a pivot table like the example above:

I mean it is inferred, I'm a fan of more explicit statement.

martsberger commented 11 months ago

Looks like aliases not allowing spaces was a security fix in Django 4.0.4. https://docs.djangoproject.com/en/4.2/releases/4.0.4/

I'm not yet sure what the workaround should be.