Changeset 902
- Timestamp:
- 09/11/07 18:11:53 (1 year ago)
- Files:
-
- trunk/src/main/php/net/stubbles/rdbms/persistence/creator/stubDatabaseCreator.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/rdbms/persistence/MockNoTableAnnotationPersistable.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/rdbms/persistence/creator/stubDatabaseCreatorTestCase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/rdbms/persistence/creator/stubDatabaseCreator.php
r899 r902 109 109 continue; 110 110 } else { 111 // well, if we could check the return value this could be customized a bit...112 111 $column = new stubDatabaseTableColumn(); 113 112 $columnName = str_replace('get', '', $method->getName()); 114 113 $column->setName(strtolower($columnName{0}) . substr($columnName, 1)); 115 $column->setType('VARCHAR'); 116 $column->setSize(255); 114 $returnType = $method->getReturnType(); 115 if (null === $returnType) { 116 // no type hint or returns null -> ignore method 117 continue; 118 } 119 120 if ($returnType instanceof stubReflectionClass) { 121 // not supported yet 122 throw new stubDatabaseCreatorException('Returning classes from entity getter methods is currently not supported. Sorry. :('); 123 } 124 125 switch (strtolower($returnType)) { 126 case 'int': 127 case 'integer': 128 $column->setType('INT'); 129 $column->setSize(10); 130 break; 131 132 case 'double': 133 case 'float': 134 $column->setType('FLOAT'); 135 $column->setSize(10); 136 break; 137 138 case 'bool': 139 case 'boolean': 140 $column->setType('TINYINT'); 141 $column->setSize(1); 142 break; 143 144 default: 145 $column->setType('VARCHAR'); 146 $column->setSize(255); 147 } 117 148 } 118 149 … … 123 154 $this->connection->query(stubDatabaseQueryBuilderFactory::create($this->connection)->createTable($tableDescription)); 124 155 } catch (stubException $se) { 125 throw new stubDatabaseCreatorException('Can not create table for ' . $ fqClassName, $se);156 throw new stubDatabaseCreatorException('Can not create table for ' . $entityClass->getFullQualifiedClassName(), $se); 126 157 } 127 158 } trunk/src/test/php/net/stubbles/rdbms/persistence/MockNoTableAnnotationPersistable.php
r899 r902 64 64 /** 65 65 * method that has a no annotation 66 * 67 * @return string 66 68 */ 67 69 public function getDefaultValue() 68 70 { 69 71 return $this->defaultValue; 72 } 73 74 /** 75 * method that has a no annotation 76 * 77 * @return int 78 */ 79 public function getIntValue() 80 { 81 return 313; 82 } 83 84 /** 85 * method that has a no annotation 86 * 87 * @return bool 88 */ 89 public function getBoolValue() 90 { 91 return true; 92 } 93 94 /** 95 * method that has a no annotation 96 * 97 * @return float 98 */ 99 public function getFloatValue() 100 { 101 return 3.13; 70 102 } 71 103 … … 80 112 return 'ignored'; 81 113 } 114 115 /** 116 * this method is ignored because it has no return doc annotation 117 */ 118 public function getIgnored2() 119 { 120 return 'ignored2'; 121 } 82 122 } 83 123 ?> trunk/src/test/php/net/stubbles/rdbms/persistence/creator/stubDatabaseCreatorTestCase.php
r899 r902 116 116 $this->assertEqual($tableDescription->getName(), 'MockNoTableAnnotationPersistables'); 117 117 $columns = $tableDescription->getColumns(); 118 $this->assertEqual(count($columns), 3);118 $this->assertEqual(count($columns), 6); 119 119 $this->assertEqual($columns[1]->getName(), 'id'); 120 120 $this->assertEqual($columns[1]->getType(), 'INT'); … … 126 126 $this->assertEqual($columns[3]->getType(), 'VARCHAR'); 127 127 $this->assertEqual($columns[3]->getSize(), 255); 128 $this->assertEqual($columns[4]->getName(), 'intValue'); 129 $this->assertEqual($columns[4]->getType(), 'INT'); 130 $this->assertEqual($columns[4]->getSize(), 10); 131 $this->assertEqual($columns[5]->getName(), 'boolValue'); 132 $this->assertEqual($columns[5]->getType(), 'TINYINT'); 133 $this->assertEqual($columns[5]->getSize(), 1); 134 $this->assertEqual($columns[6]->getName(), 'floatValue'); 135 $this->assertEqual($columns[6]->getType(), 'FLOAT'); 136 $this->assertEqual($columns[6]->getSize(), 10); 128 137 } 129 138
