Migrating from class :: DBI to DBIx :: Class

I am currently studying DBIx :: Class to port the current application from the :: DBI class. Honestly, I'm a little disappointed with regard to DBIx :: Class when it comes to setting up result classes, with Class :: DBI I can set up metadata on models just by calling the on function without a code generator and so on to my question ... can I do the same with DBIX :: Class also, it seems that client-side triggers are not supported in DBIx :: Class or am I not looking at the wrong documents?

+3
source share
1 answer

Triggers can be implemented by overriding the corresponding method (new / create / update / delete, etc.) in the Result class and calling the parent (through $self->next::method()) inside it, before or after your code. Admittedly, this is a bit awkward compared to before / after triggers in :: DBI class.

Regarding metadata - are you talking about temporary columns on an object? that is, data that will not be stored in the database row. They can be easily added using one of the modules Class :: Accessor :: * on CPAN

One of the most difficult changes when switching from CDBI to DBIC is the idea from the point of view of ResultSets - often what would be implemented using the Class method in CDBI becomes a method on ResultSet - and the code may need to be reorganized significantly, it is not always simple conversion from one to another.

+5
source

Source: https://habr.com/ru/post/1735779/


All Articles