Skip to content

Cannot write custom JSONB Type Decorator #402

@asgoel

Description

@asgoel
  • GINO version: 0.8.0
  • Python version: 3.5.4
  • asyncpg version: 0.17.0
  • aiocontextvars version: 0.2.0
  • PostgreSQL version: 10

Description

We have a custom JSONB Type decorator that modifies our JSONB that comes out of our database a little bit:

class CustomJSONB(sqlalchemy.types.TypeDecorator):

  impl = sqlalchemy.dialects.postgresql.JSONB

  def process_bind_param(self, value, _):
    if value is None:
      return None
    return some_modification_to_value(value)

  def process_result_value(self, value, _):
    if value is None:
      return None
    return some_modification_to_value(value)

  def coerce_compared_value(self, op, value):
    # Tells the expression generator to not to try and coerce comparison values using the processors
    # defined above. Instead, it will use the default JSON comparison operators, which is what we
    # want.
    return self.impl.coerce_compared_value(op, value)

I'm not seeing my custom process_result_value function running. I believe it's because of this commit here: 6e929b4

Why is there special JSONB handling for the result processor? My bind processor works just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDescribes a bug in the system.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions