[CDBI] construct sucks.

Ryan Tate lists at ryantate.com
Sun Aug 27 20:05:28 BST 2006

Uh, has anyone else ever noticed that ->construct kind of blows rocks?

Specifically, if you ->construct an object that's already in the
LiveObject index, CDBI will throw away perfectly good fresh data about
the object -- columns not present at all in the indexed version -- and
just hand you whatever incomplete object it has sitting around?

This behavior I discovered using 0.96, but it seems to have been
carried forward to the latest CDBI, based on eyeballing the code.

This will bite you if you have an essential column inflating to a
particular object, then you try and construct that object after
retrieving it using custom SQL. In my case, I have two classes related
many_to_many, but in one class each object also keeps a reference to
one particular object from the other class because the one is special
among the many related from that class. This particular object was
auto-inflating but I needed to construct it later from some custom SQL
retrieving all the other related objects (and some special info stored
in the mapping table).

Anyway, I'll probably code a patch, if only for myself, and perhaps
file it with an RT bug, unless someone knows this to be By Design.
Also, I'd love to hear how DBIx::Class handles this.

More information about the ClassDBI mailing list