niwibe/djorm-pgarray — pull request #44 by maennel (2014-10-01 22:32:05+00:00)
Title: Query for substrings within an ArrayField

Hi Andrey,
I thought it could be useful to be able to query for an array item's substrings. It would be cool if you could have a look at it and let me know if you like it.

Basically, this PR adds the possibility to query for the contents of a (Text-)ArrayField by applying the standard Django field lookups `contains`, `startswith`, and `endswith` (and their case-insensitive relatives).
The syntax was kept as standardized as possible since it was extended "only" by prepending the "any_" keyword. When applied, it looks as follows:

```
# Class declaration
class SomeModel(models.Model):
arrayfield = TextArrayField()

# Data setup
sm = SomeModel.objects.create(arrayfield=['some', 'content'])

# Querying
queried_sm = SomeModel.objects.get(arrayfield__any_contains='om')

# At this point sm and queried_sm are equal!
```

Notice however, that I didn't really pay attention to anything security-related. So it could be, that there is some SQL-injection vulnerability, since there is pretty much raw SQL being inserted.
-Manuel