private function _testConstraintFKLookup() { $doc = simplexml_load_string($this->xml); $schema = $doc->schema; $table1 = $schema->table[0]; $table1_t1id = $table1->column[0]; $table1_t2id = $table1->column[1]; $table2 = $schema->table[1]; $table2_t2id = $table2->column[0]; $foreign = format_constraint::foreign_key_lookup($doc, $schema, $table1, $table1_t2id); $this->assertEquals($schema, $foreign['schema']); $this->assertEquals($table2, $foreign['table']); $this->assertEquals($table2_t2id, $foreign['column']); }
public static function column_type($db_doc, $node_schema, $node_table, $node_column, &$foreign = NULL) { // if the column is a foreign key, solve for the foreignKey type if (isset($node_column['foreignTable'])) { $foreign = format_constraint::foreign_key_lookup($db_doc, $node_schema, $node_table, $node_column); $foreign_type = static::un_auto_increment($foreign['column']['type']); if (static::is_serial($foreign_type)) { return static::convert_serial($foreign_type); } return $foreign_type; } // if there's no type specified, that's a problem if (!isset($node_column['type'])) { throw new Exception("column missing type -- " . $table['name'] . "." . $column['name']); } // get the type of the column, ignoring any possible auto-increment flag $type = static::un_auto_increment($node_column['type']); // if the column type matches an enum type, inject the enum declaration here if ($node_type = mysql5_type::get_type_node($db_doc, $node_schema, $type)) { return mysql5_type::get_enum_type_declaration($node_type); } // translate serials to their corresponding int types if (static::is_serial($type)) { return static::convert_serial($type); } // nothing special about this type return $type; }