Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Priority: Minor » Critical

Note that we are fixing this because #914458: Remove the format delete reassignment "feature" have delegated formats to contrib which has no clue where filter is. Patch in a few minutes.

chx’s picture

Status: Active » Needs review
FileSize
5.72 KB

Edit: thanks goes to DamZ for the modules/system/system.api.php hunk.

Damien Tournoud’s picture

Status: Needs review » Reviewed & tested by the community

This is a great addition, and will allow contrib to implement filter manipulation more easily if it proves to be necessary. The concept of foreign key is SQL specific, but this information can be used regardless of the way the fields are actually stored.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, field_foreign_key.patch, failed testing.

chx’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
6.49 KB

Note that all 77 failures were one notice during update. Fixed that.

moshe weitzman’s picture

Priority: Critical » Normal
moshe weitzman’s picture

Priority: Normal » Critical

Oops - wrong issue

vlad.leo’s picture

#5: field_foreign_key.patch queued for re-testing.

Dries’s picture

Status: Reviewed & tested by the community » Needs work
+++ modules/field/field.crud.inc	2010-09-17 22:04:13 +0000
@@ -79,6 +79,13 @@
+ * - foreign keys (array)
+ *    An associative array of relations ('my_relation' => specification). Each
+ *    specification is an array containing the name of the referenced table
+ *    ('table'), and an array of column mappings ('columns'). Column mappings
+ *    are defined by key pairs ('source_column' => 'referenced_column').
+ *    Currently this has limited usefulness as you can not specify another
+ *    field as related, only existing data in SQL tables, like filter formats.

This doesn't explain it for me. What is the purpose? What is a column mapping? What is a source column and what is a referenced column? I think we can do a better job documenting this feature -- especially if it is perceived as 'critical'.

chx’s picture

Status: Needs work » Reviewed & tested by the community

This is a word for word copy from the schema documentation in current HEAD. Fixing that is a different issue.

Edit: http://api.drupal.org/api/group/schemaapi/7

yched’s picture

Then file fields need to be updated as well ? fid column is a FK to the file table.

hilarudeens’s picture

#2: field_foreign_key.patch queued for re-testing.

sun’s picture

Status: Reviewed & tested by the community » Needs review
+++ modules/field/field.crud.inc	2010-09-17 22:04:13 +0000
@@ -79,6 +79,13 @@
+ *    Currently this has limited usefulness as you can not specify another
+ *    field as related, only existing data in SQL tables, like filter formats.

This limitation could be easily resolved by squeezing a drupal_alter() into the process, no?

Powered by Dreditor.

catch’s picture

Status: Needs review » Reviewed & tested by the community
chx’s picture

Title: Foreign key support is missing from text module » Foreign key support is missing from text and file module
FileSize
6.91 KB

@yched yes THANKS!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, field_foreign_key.patch, failed testing.

chx’s picture

Status: Needs work » Needs review

#15: field_foreign_key.patch queued for re-testing.

chx’s picture

Status: Needs review » Reviewed & tested by the community

Bot fluke.

sun’s picture

Status: Reviewed & tested by the community » Needs work
+++ modules/field/field.crud.inc	2010-09-24 19:55:02 +0000
@@ -79,6 +79,13 @@
+ * - foreign keys (array)
+ *    An associative array of relations ('my_relation' => specification). Each
+ *    specification is an array containing the name of the referenced table
+ *    ('table'), and an array of column mappings ('columns'). Column mappings
+ *    are defined by key pairs ('source_column' => 'referenced_column').
+ *    Currently this has limited usefulness as you can not specify another
+ *    field as related, only existing data in SQL tables, like filter formats.

Still contains the phpDoc that Dries already rejected. That said, I think it is wrong to duplicate hook_schema() documentation in field.crud.inc. We should simply refer to hook_schema() here (which badly needs to be improved; separate issue), and if a dead-simple drupal_alter() really cannot be done within this patch, then we also keep that last sentence after referring to hook_schema().

+++ modules/field/modules/text/text.install	2010-09-24 19:55:02 +0000
@@ -56,5 +56,11 @@ function text_field_schema($field) {
+      $field['type'] . '_' . 'format' => array(

+++ modules/file/file.install	2010-09-24 19:56:42 +0000
@@ -35,6 +35,12 @@ function file_field_schema($field) {
+      'fid' => array(

Shouldn't the foreign key of File field also use the field type as prefix to prevent potential clashes? I.e., 'file_fid'?

Powered by Dreditor.

chx’s picture

Assigned: chx » Unassigned
chx’s picture

Status: Needs work » Needs review

I have no idea what to do with the issue. Linking to hook_schema is not a healthy option idea because although the concepts are explained the same way (which is currently broken but that's not this issue) but they are not the same at all, I would believe. There is a significant difference: the left hand side of the foreign key is not necessarily in SQL. Tricky, eh?

As for $type , i only use din text because it used one function for three types and i grew uneasy. Likely overkill there too.

chx’s picture

Status: Needs review » Reviewed & tested by the community

I am asking Dries to look at this again. As I said, there have been no valid concerns voiced so far. The comment can (and probably needs to) be fixed in a folllowup but that's not a critical. If we let this doxygen in to hook_schema previously, there is no reason it should block a critical.

sun’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
8.24 KB

grml...

chx’s picture

Status: Needs review » Reviewed & tested by the community

Works for me. (Everything works for me. Get this in and Drupal 7 out!)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, drupal.field-foreign-keys.23.patch, failed testing.

chx’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
7.09 KB

Fixed the tests

Status: Reviewed & tested by the community » Needs work

The last submitted patch, field_foreign_key.patch, failed testing.

tobiasb’s picture

Status: Needs work » Needs review

#26: field_foreign_key.patch queued for re-testing.

chx’s picture

Status: Needs review » Reviewed & tested by the community

Sigh. Another bot fluke.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

OK, committed to CVS HEAD. I'm still not 100% convinced about this but in the spirit of making progress, it seems best to move forward with this. We can nitpick about it in the Drupal 8 development cycle.

David_Rothstein’s picture

Head 2 Head issue is here: #935278: Update for foreign key support missing from text and file module

(Hopefully one of the last ones!)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

yched’s picture

Priority: Critical » Normal
Status: Closed (fixed) » Needs review
FileSize
2.16 KB

Followup doc patch, to update the phpdoc and sample function body for hook_field_schema() accordingly.

Status: Needs review » Needs work

The last submitted patch, hook_field_schema_FK_doc.patch, failed testing.

moshe weitzman’s picture

I prefer: "foreign keys": (optional) An array of Schema API column defintions

yched’s picture

A doc-only patch cannot introduce test fails. Looks like HEAD is broken...

@moshe : "An array of Schema API column definitions" ?
To me that sounds like array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ...)

The intent here is "what you would place in the 'foreign keys' entry in a regular hook_schema()".

sun’s picture

+++ modules/field/field.api.php
@@ -219,7 +219,7 @@ function hook_field_info_alter(&$info) {
- *   - columns: An array of Schema API column specifications, keyed by column
+ *   - "columns": An array of Schema API column specifications, keyed by column

Without quotes is correct, so please revert. See http://drupal.org/node/1354 for details.

sun’s picture

Status: Needs work » Needs review

#34: hook_field_schema_FK_doc.patch queued for re-testing.

yched’s picture

I thought that keys composed of two words (space, not underscore : foreign keys) needed to be enclosed in quotes. If that's not the case, then here it is without quotes.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

OK, we are good.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

yched’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.