pgsync
pgsync copied to clipboard
Is there support currently for polymorphic relationships?
For example, I have inventory space that can be owned by an individual or an organization, the table looks something like this:
space_id | owner_type | owner_id |
---|---|---|
1234 | user | 5554 |
1235 | organization | 5554 |
Is this type of relationship currently supported in pgsync?
If not I would propose adding a scope
parameter. Something like below would work but could be handled by separate fields for the column name & the column value.
"children": [
{
"table": "user"
"through_tables": [
{
"table": "inventory_space_map",
"scope": {
"owner_type": "user",
},
"foreignKey": "owner_id",
}
]
}
]
I looked through the open & closed issues for polymorphic
, scope
, etc but didn't find anything.
I don't write python very often but would be willing to help out to get this feature added if it's something worth adding.
- polymorphic tables are not supported in the schema.
- However, I think this is something that can be acheived with the plugin.
- This is effectively applying a WHERE clause on the result set.
- There is a plugins example described here and I am happy to write one for your use case if you want.
PS: I do like the scope and idea of including this in the schema. I just wondered if there was already an existing solution before adding more code which is increasing in complexity these days.
- polymorphic tables are not supported in the schema.
- However, I think this is something that can be acheived with the plugin.
- This is effectively applying a WHERE clause on the result set.
- There is a plugins example described here and I am happy to write one for your use case if you want.
I would appreciate if you could write a plugin - is there a repository of "supported" plugins to add it to maybe?
I'll be honest. I don't understand enough of your use case to write a plugin. Do you have a repo somewhere I can contribute to?