interchange / TableEditor

25 stars 4 forks source link

many_to_many relations scan #36

Closed gregapompe closed 9 years ago

gregapompe commented 9 years ago

Use DBIx::Class::IntrospectableM2M instead of file parsing

racke commented 9 years ago

Interesting idea. We have to determine whether this module is still working (last release 2008). But file parsing is indeed suboptimal.

racke commented 9 years ago

The problem is that the schema needs to support it. Instead of parsing files manually, we could use https://metacpan.org/pod/PPI.

gregapompe commented 9 years ago

Yeah I noticed that later, so M"M is not an good option. It's really a shame that you can't retrieve that info from DBIC (as a separate attr, not normal relation, since it's not). If something is set, it should be retrievable.

SysPete commented 9 years ago

This needs fixing in some way since current m2m relationship parser is completely broken for Order class in ic6s:

Failed to eval relationship parameters (See L<DBIx::Class::Relationship::Base/add_to_$rel> for further details.=cut# much of this was cargo-culted from DBIx::Class::Relationship::ManyToManysub add_to_comments {my $self = shift): Global symbol "$rel" requires explicit package na
me at (eval 364)[/home/syspete/camp11/applications/TableEditor/lib/TableEdit/ClassInfo.pm:386] line 1, <$fh> line 352.
BEGIN not safe after errors--compilation aborted at (eval 364)[/home/syspete/camp11/applications/TableEditor/lib/TableEdit/ClassInfo.pm:386] line 1, <$fh> line 352.
 at /home/syspete/camp11/applications/TableEditor/lib/TableEdit/ClassInfo.pm line 389, <$fh> line 352.
racke commented 9 years ago

Short term we can try to fix this by skipping POD. I suggest to contact DBIx::Class mailinglist for a long term solution.

SysPete commented 9 years ago

I've added some method modifiers which make basic m2m relation data available via $resultset->result_class->_table_editor_m2m_metadata. You get something like:

{
    products => { local => "navigation_products", foreign => "product" },
    attributes => { local => "navigation_attributes", foreign => "attribute" },
}
SysPete commented 9 years ago

@gregapompe I'm not going to change any of the existing m2m handling code for now as I'd like your opinion on this commit 1st.

gregapompe commented 9 years ago

This looks great. So this extends all classes automatically to save m2m info on "compile" time if I understand correctly? If this is the case it's exactly what i wanted (next best thing if that is not acceptable for DBIC folks).

SysPete commented 9 years ago

Just committed change which removes all old 'read the file' stuff and uses the new introspection code. Seems to work perfectly.