core.orm.types.json_type
Attributes
Classes
A JSONB based type that coerces None's to empty dictionaries. |
Module Contents
- class core.orm.types.json_type.JSON(*args, **kwargs)[source]
Bases:
_Base
A JSONB based type that coerces None’s to empty dictionaries.
That is, this JSONB column does not have NULL values, it only has falsy values (an empty dict).
- process_bind_param(value: dict[str, Any] | None, dialect: sqlalchemy.engine.interfaces.Dialect) dict[str, Any] [source]
Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngine
object, and from there to the DBAPIexecute()
method.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
This operation should be designed with the reverse operation in mind, which would be the process_result_value method of this class.
- Parameters:
value – Data to operate upon, of any type expected by this method in the subclass. Can be
None
.dialect – the
Dialect
in use.
- process_result_value(value: dict[str, Any] | None, dialect: sqlalchemy.engine.interfaces.Dialect) dict[str, Any] [source]
Receive a result-row column value to be converted.
Subclasses should implement this method to operate on data fetched from the database.
Subclasses override this method to return the value that should be passed back to the application, given a value that is already processed by the underlying
TypeEngine
object, originally from the DBAPI cursor methodfetchone()
or similar.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
- Parameters:
value – Data to operate upon, of any type expected by this method in the subclass. Can be
None
.dialect – the
Dialect
in use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.