django の組み込みコメント モデルに関する簡単なクエリがあり、heroku の postgreSQL データベースで以下のエラーが発生します。
DatabaseError: operator does not exist: integer = text LINE 1:
... INNER JOIN "django_comments" ON ("pi ns_pin"."id" = "django_...
^
HINT: No operator matches the given name and argument type(s).
You might need to add explicit type casts.
グーグルで調べた後、このエラーはdjangoで何度も対処されているようですが、まだ取得しています(関連するすべての問題は3〜5年前にクローズされました)。私はdjangoバージョン1.4とtastypieの最新ビルドを使用しています。
クエリは orm フィルターの下で作成され、私の開発データベース (sqlite3) と完全に連携します。
class MyResource(ModelResource):
comments = fields.ToManyField('my.api.api.CmntResource', 'comments', full=True, null=True)
def build_filters(self, filters=None):
if filters is None:
filters = {}
orm_filters = super(MyResource, self).build_filters(filters)
if 'cmnts' in filters:
orm_filters['comments__user__id__exact'] = filters['cmnts']
class CmntResource(ModelResource):
user = fields.ToOneField('my.api.api.UserResource', 'user', full=True)
site_id = fields.CharField(attribute = 'site_id')
content_object = GenericForeignKeyField({
My: MyResource,
}, 'content_object')
username = fields.CharField(attribute = 'user__username', null=True)
user_id = fields.CharField(attribute = 'user__id', null=True)
生のSQLを書かずにこのエラーを回避した経験のある人はいますか?