Closed mjvotaw closed 2 weeks ago
Thanks for sending this our way — it's actually a little bit more complicated than however. Notably, you could have a world in which different foreign key constraints have different ways of uniquely identifying a row in a target table. For example:
Unfortunately condenser is not built for these more complicated schemas, unlike Tonic's built-in subsetter which handles your case, the above case, and an additional variety of others. We'd happily look at a pull request however!
Been assessing the tool for use with our stack and also ran into this issue. Just wondering if this issue also occurs with the premium database subsetter? Thanks!
I noticed this just now while testing this tool against a client's database. They have several tables that each contain 2 columns that are referenced in foreign key relationships. Consider the following tables:
subset_downstream generates the following query:
Which then throws the following error:
It looks like the issue stems from the fact that
pk_columns
is only set once, instead of being set for each object inreferencing_tables
. This might be a naive solution, but simply addingpk_columns = r['target_columns']
before the query is built results in the data being properly copied to the destination db.