contao/import — Issue #2548: foreignkey interferes with child database
Author: importer
Created: 2011-11-29 19:45:48+00:00
State: open
Labels: backend, Defect

Hi Leo

I have the following situation:
The Child Table in parentView has each entry associated with a page, so I have a field called 'page' with inputType=>'pageTree'.

![](table-parentview-bug-1.jpg)

1. I made this field have a foreignKey => tl_page.title so that instead of the ID, it would display the nice page TITLE when in the filter at the top of the parentView
2. Also, this field 'page' completely ignores any ['eval']['root'] = array(1,5,4) setting (maybe its because I'm root, but it should still honour the root setting regardless of login, right?)

Because of situation (1) above, the following is now happening. In the SQL you generate you insert the foreignKey into the Query and because the foreignkey field has the same name as that in the child table, TITLE, this causes the child table's value to be overwritten by the parent lookup. Can you not make the AS section contain a table_field mashup to prevent this from happening.

```
SELECT *, (SELECT title FROM tl_page WHERE tl_tree.page=tl_page.id) AS title FROM tl_tree WHERE pid=? ORDER BY title, date DESC
```

When I display the TITLE in the parentView() it displays the page title instead.

NOTE: This only happens when the page field (in tl_tree) has been set as the FILTER, so it groups the values by it, which then adds this SQL to the foreignKey table and overrides the title.

![](table-parentview-bug-2.jpg)

[Download the attachments](http://www.contao.org/tl_files/tickets/2548.zip "Download the attachments of this ticket")

--- _Originally created by thyon on September 20th, 2010, at 10:51am (ID 2548)_