History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ZF-2921
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Simon Mundy
Reporter: Giacomo Tesio
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Allow defining of the schema separator in Zend_Db_Adapter

Created: 19/Mar/08 08:50 AM   Updated: 03/Sep/08 12:00 AM
Component/s: Zend_Db, Zend_Db_Select, Zend_Db_Table
Affects Version/s: 1.5.0
Fix Version/s: Next Minor Release

Time Tracking:
Original Estimate: 1 hour
Original Estimate - 1 hour
Remaining Estimate: 1 hour
Remaining Estimate - 1 hour
Time Spent: Not Specified
Remaining Estimate - 1 hour

File Attachments: 1. File library_Zend_Db.diff (4 kb)
2. File patch.Zend_Db (3 kb)


Fix Version Priority: Should Have


 Description  « Hide
To simulate the schema system in RDBMS which don't support it (as MySQL, where SCHEMA is a DATABASE) I thought to patch the Zend_Db_Adapter_Abstract by adding a protected attribute called Zend_Db_Adapter_Abstract::$_schemaSeparator (default to '.') and a public method Zend_Db_Adapter_Abstract::getSchemaSeparator()

Then by simply changing the '.' string with a call to Zend_Db_Adapter_Abstract::getSchemaSeparator() in the following methods:
Zend_Db_Table_Abstract::_setupMetadata()
Zend_Db_Table_Abstract::_setupTableName()
Zend_Db_Table_Abstract::_setupPrimaryKey()
Zend_Db_Table_Abstract::insert()
Zend_Db_Table_Abstract::update
Zend_Db_Table_Abstract::delete()
Zend_Db_Select::__toString()
Zend_Db_Select::_join()

So you could extend an Adapter (eg MySQLi) by definig the attribute $schemaSeparator (say with '_') and you get a sort of schema management analogue of PostgreSQL one (for example), to group table in namespaces.

I've also build a patch you could find in http://dev.tesio.it/patch.Zend_Db

The work estimate contain simply adding the patch to the core CVS and testing more widely...



 All   Comments   Work Log   Change History   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Giacomo Tesio - 19/Mar/08 08:51 AM
The patch I wrote...

Wil Sinclair - 25/Mar/08 08:25 PM
Please categorize/fix as needed.

Giacomo Tesio - 08/Apr/08 09:40 AM
I realized that, when using such a feature, you should set Adapter::$autoQuoteIdentifiers = FALSE: otherwise, a "virtual schema" called "schema" and a table named "test_table" with an Adapter::$_schemaSeparator = '' you would get a query quoting the table as `schema`_`test_table` which is clearly wrong.

To make it work better I'm wondering of a protected _schemaSperatator setter (say Adapter::_setSchemaSeparator(string $separator, boolean $explodeIdentifiers = false) )

$explodeIdentifiers set a protected Adapter boolean attribute (defined true by default in Zend_Db_Adapter_Abstract) which enable / disable the explode() call in Zend_Db_Adapter_Abstract::_quoteIdentifierAs()

What do you think about this?


Giacomo Tesio - 09/Apr/08 02:43 AM
Here an updated Patch which fix a little bug in Zend_Db_Adapter_Abstract::_joinUsing() and follow the contributer guide (aka, built using svn diff)