creatoro / jelly

A flexible ORM for Kohana 3.1+
http://jelly.jonathan-geiger.com
MIT License
72 stars 13 forks source link

Polymorphism support #68

Open leth opened 13 years ago

leth commented 13 years ago

I am working on it!

I've got rudimentary field inheritance working, but I haven't attempted anything which touches the database yet :P I'll post a link to the branch once I've got something worth sharing.

As always, comments suggestions and feature requests are welcome :)

creatoro commented 13 years ago

Cool :)

leth commented 13 years ago

I've published my branch. I've only gone far enough to support loading models directly, nothing complex yet.

It's a long way off being finished though, and I have the suspicion that there remain better ways of doing things.

There are 3 unit tests on polymorphic modes, currently, the third tests for behaviour I've not implemented yet so only passes for the simplest dataset item.

leth commented 13 years ago

I've made some design decisions which feel kind of major, I'd appreciate some comments on my ideas:

Field inheritance

Subclass discovery

In order for a single db query to return instances of a class and its subclasses we'll need to explicitly join their tables. Therefore we need to know in advance which tables to join.

Since we can't find a list of all subclasses (because they may have not yet been autoloaded) I've decided that subclasses must be explicitly registered in the initialize(...) method.

leth commented 13 years ago

I've pushed subclass detection in query results. It's a bit hacky, but the tests pass now :)

As always, comments welcome!

creatoro commented 13 years ago

Nice work, keep going. I'll go through it when we're ready with the 3.2 branch,