blockchain column handles int args
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import dataclasses
|
import dataclasses
|
||||||
import math
|
import math
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from sqlalchemy import TypeDecorator, BIGINT
|
from sqlalchemy import TypeDecorator, BIGINT
|
||||||
from sqlalchemy.dialects.postgresql import BYTEA, JSONB
|
from sqlalchemy.dialects.postgresql import BYTEA, JSONB
|
||||||
@@ -24,8 +25,8 @@ class Blockchain(TypeDecorator):
|
|||||||
impl = BIGINT
|
impl = BIGINT
|
||||||
cache_ok = True
|
cache_ok = True
|
||||||
|
|
||||||
def process_bind_param(self, value: NativeBlockchain, dialect):
|
def process_bind_param(self, value: Union[NativeBlockchain,int], dialect):
|
||||||
return value.id
|
return value if type(value) is int else value.id
|
||||||
|
|
||||||
def process_result_value(self, value: int, dialect):
|
def process_result_value(self, value: int, dialect):
|
||||||
return NativeBlockchain.for_id(value)
|
return NativeBlockchain.for_id(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user