[TYPO3-core] FYI: Raised DBAL version from 1.1.5 to 1.1.6

Xavier Perseguers typo3 at perseguers.ch
Fri May 28 08:42:25 CEST 2010


Hi,

FYI, DBAL has been updated in trunk (rev. 7704)

Most important change since 1.1.5:

- Mapping of table alias now works

Description:

In DBAL you may remap table name and field names:

$TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping'] = array(
	'tt_news' => array(
		'mapTableName' => 'ext_tt_news',
		'mapFieldNames' => array(
			'uid' => 'news_uid',
		),
	),
	'tx_templavoila_datastructure' => array(
		'mapTableName' => 'tx_templavoila_ds',
	),
);

This is commonly used with Oracle where identifiers cannot have more than 30 characters.

This makes possible to write a statement like

	SELECT uid FROM tt_news

and have it dynamically rewritten as

	SELECT news_uid FROM ext_tt_news

with the above example.

The problem was that whenever an alias was used for the table name, the rewrite process did not work anymore:

	SELECT foo.uid FROM tt_news AS foo

was rewritten to

	SELECT foo.uid FROM ext_tt_news AS foo

that is, the column 'uid' was not remapped.

This is now possible and it works even for totally insane queries such as:

	SELECT pages.uid
	FROM tt_news AS pages
	INNER JOIN tt_news_cat_mm AS cat_mm ON cat_mm.uid_local = pages.uid
	WHERE pages.pid IN (
		SELECT uid FROM pages WHERE deleted = 0 AND cat_mm.uid_local != 100
	)

Taking for granted that any table (tt_news, tt_news_cat_mm or pages) might need remapping and as you see, tt_news is first aliased as "pages" while the inner query makes a query on the real table 
"pages". That is, visibility scope of the alias has been taken into account.

Thanks to Michael Miousse for having reported the bug and provided the very first version of the patch.

-- 
Xavier Perseguers
http://xavier.perseguers.ch/en


More information about the TYPO3-team-core mailing list