Zend\Db\Metadata: Added AbstractSource, fully functional MysqlMetadata#1485
Conversation
|
If I eliminate the fetch methods from So |
|
A thought I had would be an Object structure, where each object is responsible for instantiating its descendants. It would allow, say, a Schema object to be passed to a function, which would have all the components of that available to it. The source would return assoc arrays, and would be passed down to each object during instantiation A simplified example <?php
class Metadata
{
public function getSchema($schemaName)
{
$schema = new Schema($schemaName);
return $schema;
}
// an ease-of-use function to get just a table name
public function getTable($tableName, $schemaName)
{
return $this->getSchema($schemaName)->getTable($tableName);
}
}
class Schema
{
// This is the only place a Table ever gets instantiated
public function getTable($tableName)
{
$options = $this->source->fetchTable($this->name, $tableName);
return new Table($tableName, $options);
}
} |
|
I was going to extend I tried cleaning up the code building the SQL in MysqlMetadata, but don't like the result. What do you think about using Select objects? We might do Select object in InformationSchema, but leave the platform specific ones unquoted (for readability). |
|
I don't see any value in using Select objects. Their purpose is primarily for SQL abstraction, which inside of our Metadata objects, we don't really care about. Once we write the right SQL, it likely will never need to change. Lets chat on IRC |
…data Leftbrained feature/db metadata
The changes are listed below, they are mostly examples and are not fully propagated to the various classes, For instance, I haven't updated the MetadataInterface to reflect changes, nor updated other sources to reflect the changes in functionality.
If the changes are OK, I'll update to properly add the full functionality. I figured I'd let @ralphschindler take a look at this before I did any more.
Metadata\Metadata
MetadataInterfacemethods to pass through to source correctly.Metadata\Source
AbstractSourceHandles instantiation of Objects, while sub-classes are responsible for fetching of data.
AbstractTableObject).Metadata\Object
numericUnsignedproperty to columnsAllows the storage of errata data in the
AbstractSource->datapropertyConstraintObject->typeChanged
'PRIMARY'to'PRIMARY KEY'as that follows the standardColumnObject->isNullable()alias forColumnObject->getIsNullable()ColumnObject->isNumericUnsigned()alias forColumnObject->getIsNumericUnsigned()