I'm using Django and am getting an error that says "This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'".
My database structure is approximately as follows:
class ImageTag(models.Model):
start_image = models.ForeignKey(Image)
stop_image = models.ForeignKey(Image)
tag = models.TextField(null=True)
class Image(models.Model):
[things we don't really care about right now]
What I'm trying to do is get the unique Image objects (note: not values, I need the actual objects) that occur in the start_image field of all ImageTag objects. How I'm doing this:
tag_match = [filtering all tags based on a query]
ids = tag_match.values('start_image').distinct() #get the distinct image ids
images = Image.objects.filter(id__in=ids) #get the actual image objects
This was the easiest and most straightforward way I could see to get the unique Image objects that have an ImageTag object associated with it, but my database backend doesn't support it. I've seen a few suggestions as to how to get around this using raw SQL, but I'd really like to avoid that if possible because the differences between our dev setups and our production setup (why this is a problem in the first place) make it really hard to know what actually will and won't work.
Some kind of Django workaround to this problem would be most appreciated.