Open willpoorman opened 6 years ago
I personally ever used the model, but I was aware of some hardcoding.
I did a quick search, but this seems to be the only place:
./classes/model/temporal.php: protected static $_primary_key = array('id', 'temporal_start', 'temporal_end');
./classes/model/temporal.php: ->where('id', $id)
./classes/model/temporal.php: ->where('id', $id)
./classes/model/temporal.php: array('id', $this->id),
./classes/model/temporal.php: return $query->where('id', $this->id)
looking forward to a PR. :+1:
If a model exists where 'id' is not a column and is replaced with any number of other columns as the primary key (disregarding the necessary temporal_start and temporal_end columns that are part of the pk), the following functions fail, since their queries hardcode the use of the 'id' column:
find_revisions_between, find_revision, restore, and purge
Say that Model_Foo extends Model_Temporal and it as a primary key of:
So instead of "id", it uses "foo" + "bar". Well the find() function handles this just fine when you pass an array for a compound key
find(array('foo' => 1, 'bar' => 2))
:But the column "id" is hard coded into the query in the functions listed at the top: Example issue from find_revision():
Example issue from restore():
Suggested fix: Do something similar to what find() does to deal with compound keys. Here's a fix I have written up for find_revision:
This fix should be able to be thrown into find_revision and find_revisions_between. It will probably need to be bit different for restore and purge but it should be similar. I'll try to implement the fix and create a pull request from my fork when I get the chance. But wanted to make sure the issue was known before I forget about it.