2017-10-10 19 views
0

を更新し、オブジェクトを更新しようとするとエラーが発生しました:ピーウィー非同期予想外のキーワードピーウィー非同期を使用している間

Traceback (most recent call last): 
    File "./src/models/module.py", line 74, in run 
    await self._stage_alert_attach(target_alert) 
    File "./src/models/module.py", line 293, in _stage_alert_attach 
    await target_alert.attach(unattached_issues) 
    File "./src/models/alert.py", line 127, in attach 
    await issue.attach(self) 
    File "./src/models/issue.py", line 81, in attach 
    await self.async_save() 
    File "./src/models/base.py", line 40, in async_save 
    return await self._manager.update(self, only=self.dirty_fields) 
    File "/usr/local/lib/python3.6/site-packages/peewee_async.py", line 227, in update 
    query = obj.update(**field_dict).where(obj._pk_expr()) 
TypeError: update() got an unexpected keyword argument 'alert_id' 

フィールドは、基本クラスで定義されているので、私は何が起こっているかを把握することはできません。

class BaseIssue(BaseModel): 
    # Database fields 
    id = peewee.PrimaryKeyField() 
    module_id = peewee.IntegerField() 
    model = peewee.CharField(index=True) 
    model_id = peewee.CharField(index=True) 
    status = peewee.CharField(index=True) 
    metadata = JSONField() 
    alert_id = peewee.IntegerField(null=True) 
    created_at = peewee.DateTimeField(default=datetime.datetime.now) 
    solved_at = peewee.DateTimeField(null=True) 
    expired_at = peewee.DateTimeField(null=True) 

    class Meta: 
     def db_table_func(model_cls): return "Issues" 

alert代わりのalert_idと外部キーとしてそれを使用してを使用しようとしましたが、(今のアラートキーワードで)同じエラーを得ました。

この基本クラスは継承され、再び継承されるDefaultIssueクラスを作成するため、継承に問題があると思います。何らかの理由でupdate()メソッドがこのパラメータを期待していません。ここで

が右self.async_save()呼び出し前にオブジェクト__dict__とフィールドの印刷です:私が提供できる任意のより多くの情報がある場合

>>> obj.__dict__ 

{ 
    "_data": { 
    "created_at": datetime.datetime(2017, 10, 10, 17, 6, 8, 47075), 
    "id": 2, 
    "module_id": 3, 
    "model": "transaction", 
    "model_id": "23765771", 
    "status": "active", 
    "metadata": { 
     "transaction_id": 23765771, 
     "boleto_url": None, 
     "boleto_barcode": None 
    }, 
    "alert_id": None, 
    "solved_at": None, 
    "expired_at": None 
    }, 
    "_dirty": set(), 
    "_obj_cache": {}, 
    "_logger": <Logger Issue 2 (INFO)> 
} 

>>> obj._meta.fields 

{ 
    "id": <peewee.PrimaryKeyField object at 0x7f49fdb2e198>, 
    "module_id": <peewee.IntegerField object at 0x7f49fdb2e3c8>, 
    "model": <peewee.CharField object at 0x7f49fdb2e710>, 
    "model_id": <peewee.CharField object at 0x7f49fdb2e7f0>, 
    "status": <peewee.CharField object at 0x7f49fdb2e860>, 
    "metadata": <playhouse.postgres_ext.JSONField object at 0x7f49fdb2e8d0>, 
    "alert_id": <peewee.IntegerField object at 0x7f49fdb2e940>, 
    "created_at": <peewee.DateTimeField object at 0x7f49fdb2e9b0>, 
    "solved_at": <peewee.DateTimeField object at 0x7f49fdb2ea20>, 
    "expired_at": <peewee.DateTimeField object at 0x7f49fdb2ea90> 
} 

、してくださいお願いします。もう何をすべきかわからない。

答えて

0

私はとても馬鹿です。ちょうど私は更新メソッドをオーバーライドして気づいた。

関連する問題