Closed Anaphory closed 3 years ago
Property on the column object wouldn't work, because the column doesn't know about the table(Schema) it's part of. So, something like Dataset.foreign_key_target(col)
would be the best I can think of now. This should return a pair (Table
, Column
), though, I think.
Oops, so that should have been:
class Dataset:
...
def foreign_key_target(self, table, col):
return table, column
...
i.e. we also need to know the table of the foreign key.
And yes, considering the cognitive dissonance that we need to look up column names in columnReference
, and not CLDF terms, that should be made simpler with such a method.
I have just tried to update some script to impement what we clarified in the preparation for 1.1, that explicit foreign keys have precedence and do not need to point to ID columns. The best way I could come up with (commas for tuple unpacking, because all the RHSs of the assigment are length-1 lists)
That's quite a chunk for something that should be a core operation. Did I overlook something? If not, could we get something better, such as a property on the column object?