Cheers,Pedro--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.---You received this message because you are subscribed to the Google Groups "sqlalchemy" group.To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/5581edb1-3cbe-2179-f925-dbeaaa7523b8%40cern.ch.Attachments:
- signature.asc
Hi, I was wondering if there's some way to create some sort of a "virtual" model which is not based on an actual table? Use case: I have a model (e.g. `Room`) which contains a `data` JSONB attribute/column which is supposed to store plugin-specific data. I would like plugin code to be able to create a "virtual" model which references `Room` 1-to-1 and injects a `plugin_data` backref into it. That means I would be able to do `room.plugin_data.user`, for instance, which would use `room.data['user_id']` to fetch a `User` object.
Spyne contains some work towards that goal.
I added an example[1]. What works: the Preferences object gets
serialized to json and stored as jsonb. It's also deserialized
from json to an instance when read. It's implemented as a generic
UserDefinedType[2].
Disclaimer: I'm the author of Spyne.
I hope it helps!
Best,
Burak
[4]: https://docs.sqlalchemy.org/en/13/orm/session_api.html#sqlalchemy.orm.attributes.flag_dirt
[5]:
https://www.postgresql.org/docs/12/functions-json.html#FUNCTIONS-JSON-PROCESSING-TABLE