Closed (fixed)
Project:
Schema
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Feb 2010 at 04:30 UTC
Updated:
30 Jun 2017 at 20:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
work77 commentedHi. Is foreign keys support in the pipeline for Schema or not so much? Or does it support it already and I'm just doing something wrong, because it seems to be ignoring my foreign keys? Thanks.
mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (i686)
Comment #2
liam morlandHere is a patch to add this feature to MySQL. I will write the PostgreSQL version once we have an agreed solution for MySQL. I believe this will only work on MySQL > 5.0.
Comment #3
liam morlandReroll.
Comment #4
joachim commentedThanks for the patch, but I don't really understand what it's doing. We're adding data to an array, but it's not getting output anywhere... so what is it for?
Could we have more commenting that just this please? I've no idea what this is doing.
Avoid abbreviated variable names.
Comment #5
liam morlandThis information is needed when schema is used with views_schema, which supports foreign keys (see #2127311: Create foreign key definitions). I will provide an updated patch shortly.
Comment #6
liam morlandI used
$resto match the code that is already there. That pattern is used three times in that file already. Would you like me to follow the existing pattern or use something else?Comment #7
liam morlandIs this acceptable as the comment?
Comment #8
joachim commented> I used $res to match the code that is already there. That pattern is used three times in that file already. Would you like me to follow the existing pattern or use something else?
Ah, I hadn't seen that. In which case, stick with what's there.
> Is this acceptable as the comment?
Yup, that's fine.
I was a bit concerned also that we're adding to the array this function returns without documenting it, but inspect() has no docblock at all (!!!). Also, now I've had a bit of a poke around at it, I see that it returns an array that's in the same format as Schema API. So I've added a docblock explaining that in a separate commit.
One thing that I'm not clear on though. Schema API's docs say this about the foreign key section:
> // For documentation purposes only; foreign keys are not created in the
> // database.
That sounds like tables created by Drupal from Schema API definitions will never have foreign keys set. Given that, I'm confused as to when this patch's feature will actually be used.
Comment #9
liam morlandBy using schema with views_schema, we are making Views of non-Drupal database tables. The foreign keys are needed for the joins that the View needs to do.
Comment #10
liam morlandRe-roll with updated comment.
Comment #11
joachim commentedHmm that sounds a lot like what Data module does... have you considered building on that instead? Schema is more of a reporting module for developers; it's not something I'd typically expect to be used in production.
Comment #12
liam morlandI hadn't known about the data module when I wrote our system. It is an internal-facing site anyway. It's been working well for us.
Comment #13
liam morlandThe Schema project page says:
To be complete, foreign keys need to be part of that.
Comment #15
joachim commented> To be complete, foreign keys need to be part of that.
Yup, agreed.
Thanks for the rerolls -- committed!
Comment #16
liam morlandThanks!