Project

General

Profile

Actions

Bug #15089

closed

MySQL-error in single_table_view caused by missing table_aliases (typo3_src-3.8)

Added by citeq about 19 years ago. Updated over 18 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2005-10-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

this error concerns any self-referring database relations, i.e. an mm-table where uid_local and uid_foreign both refer to the same "parent"-table - a feature used in the civserv-extension to realise hierarchical relations between records in the same table, e.g. organisation-objects.

the error occurs regularly: if you have a sysfolder where you store records from such a parent-table and working in the BE you chose first "list only this table" and then you chose the field bearing the hierarchical relation via "set field" you get the MySQL-error: Not unique table/alias: 'tx_civserv_organisation'

the error only comes up with the DBAL-improved typo3_src-3.8, older versions just displayed "n/a" under the same conditions.

this is the result of the typo3-DBAL-Syntax in the from-clause:
"table1, mm-table, table2".
if table1 and table2 are identical (which means they have an identical name) MySQL gets upset.

the solution could be - i hope - to use table-aliases when generating the query.

all the above said concerns the extension "O.S.I.R.I.S." (extkey "civserv") which uses self-referring database relations to be able to sort organisation- or navigation-objects hierarchically.

for a look into the database-structure check the attached dump-file for:
tx_civserv_organisation and
tx_civserv_organisation_or_structure_mm
(issue imported from #M1649)


Files

typo3_osiris100_test.zip (564 KB) typo3_osiris100_test.zip Administrator Admin, 2005-10-18 09:21
1649-1.patch (1.35 KB) 1649-1.patch Administrator Admin, 2005-12-22 19:28
Actions #1

Updated by Karsten Dambekalns almost 19 years ago

First of all, trying to install this extension showed another bug, which has now been fixed - tables with fields that had a plain type like "tinytext" could not be installed.

Now on to the actual bug.

Actions #2

Updated by Karsten Dambekalns almost 19 years ago

The SQL used by civserv has some illegal stuff, that might provoke some errors:
FROM `tx_civserv_organisation` WHERE ! `deleted` AND ! `hidden`

The backticks are added by DBAL, but still - with DBAL one HAS to use NOT or deleted=0 in such cases. Otherwise a logical operator (like !) will most probably be used on an integer, causing errors on RDBMS like PostgreSQL (which knows a boolean type).

Anyway, back to the bug...

Actions #3

Updated by Karsten Dambekalns almost 19 years ago

Ok, now I could reproduce this and will work on a fix.

Actions #4

Updated by Karsten Dambekalns almost 19 years ago

Ok, this is not a DBAL (as in "tx_dbal") error but happens with the plain core as well. The resulting query will always be illegal when local and foreign table are the same. A suggested fix will be discussed with the core developers.

Actions #5

Updated by Karsten Dambekalns almost 19 years ago

The issue has been fixed at a different place (t3lib_befunc) by Christian Jul Jensen yesterday - independently from this one.

Anyway, a fix for this bug (which can easily be triggered by any extension author using the affected method exec_SELECT_mm_query) has been written and will be put into CVS as soon as possible.

Actions

Also available in: Atom PDF