public function testListTableColumns() { $table = new \Doctrine\DBAL\Schema\Table('list_table_columns'); $table->addColumn('id', 'integer', array('notnull' => true)); $table->addColumn('test', 'string', array('length' => 255, 'notnull' => false)); $table->addColumn('foo', 'text', array('notnull' => true)); $table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false)); $table->addColumn('baz1', 'datetime'); $table->addColumn('baz2', 'time'); $table->addColumn('baz3', 'date'); $this->_sm->dropAndCreateTable($table); $columns = $this->_sm->listTableColumns('list_table_columns'); $this->assertArrayHasKey('id', $columns); $this->assertEquals('id', strtolower($columns['id']->getname())); $this->assertType('Doctrine\\DBAL\\Types\\IntegerType', $columns['id']->gettype()); $this->assertEquals(false, $columns['id']->getunsigned()); $this->assertEquals(true, $columns['id']->getnotnull()); $this->assertEquals(null, $columns['id']->getdefault()); $this->assertType('array', $columns['id']->getPlatformOptions()); $this->assertArrayHasKey('test', $columns); $this->assertEquals('test', strtolower($columns['test']->getname())); $this->assertType('Doctrine\\DBAL\\Types\\StringType', $columns['test']->gettype()); $this->assertEquals(255, $columns['test']->getlength()); $this->assertEquals(false, $columns['test']->getfixed()); $this->assertEquals(false, $columns['test']->getnotnull()); $this->assertEquals(null, $columns['test']->getdefault()); $this->assertType('array', $columns['test']->getPlatformOptions()); $this->assertEquals('foo', strtolower($columns['foo']->getname())); $this->assertType('Doctrine\\DBAL\\Types\\TextType', $columns['foo']->gettype()); $this->assertEquals(false, $columns['foo']->getunsigned()); $this->assertEquals(false, $columns['foo']->getfixed()); $this->assertEquals(true, $columns['foo']->getnotnull()); $this->assertEquals(null, $columns['foo']->getdefault()); $this->assertType('array', $columns['foo']->getPlatformOptions()); $this->assertEquals('bar', strtolower($columns['bar']->getname())); $this->assertType('Doctrine\\DBAL\\Types\\DecimalType', $columns['bar']->gettype()); $this->assertEquals(null, $columns['bar']->getlength()); $this->assertEquals(10, $columns['bar']->getprecision()); $this->assertEquals(4, $columns['bar']->getscale()); $this->assertEquals(false, $columns['bar']->getunsigned()); $this->assertEquals(false, $columns['bar']->getfixed()); $this->assertEquals(false, $columns['bar']->getnotnull()); $this->assertEquals(null, $columns['bar']->getdefault()); $this->assertType('array', $columns['bar']->getPlatformOptions()); $this->assertEquals('baz1', strtolower($columns['baz1']->getname())); $this->assertType('Doctrine\\DBAL\\Types\\DateTimeType', $columns['baz1']->gettype()); $this->assertEquals(true, $columns['baz1']->getnotnull()); $this->assertEquals(null, $columns['baz1']->getdefault()); $this->assertType('array', $columns['baz1']->getPlatformOptions()); $this->assertEquals('baz2', strtolower($columns['baz2']->getname())); $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); $this->assertEquals(true, $columns['baz2']->getnotnull()); $this->assertEquals(null, $columns['baz2']->getdefault()); $this->assertType('array', $columns['baz2']->getPlatformOptions()); $this->assertEquals('baz3', strtolower($columns['baz3']->getname())); $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); $this->assertEquals(true, $columns['baz3']->getnotnull()); $this->assertEquals(null, $columns['baz3']->getdefault()); $this->assertType('array', $columns['baz3']->getPlatformOptions()); }
/** * constructor * @param string $table_name * @param Connection $conn */ public function __construct($table_name, \Doctrine\DBAL\Connection $conn) { $this->conn = $conn; $this->table_name = $table_name; $this->quoted_table_name = $this->conn->quoteIdentifier($this->table_name); $this->sm = $this->conn->getSchemaManager(); if (!$this->sm->tablesExist([$table_name])) { throw Schema\SchemaException::tableDoesNotExist($table_name); } foreach ($this->sm->listTableColumns($this->table_name) as $colum) { $this->columns[$colum->getName()] = $colum; $this->column_types[$colum->getName()] = $colum->getType()->getName(); } }
/** * Create array of all the fields for a table * * @param string $table Table Name * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema * @param string $database * @param bool $ignoreIndexNames * * @return array */ public function generate($table, $schema, $database, $ignoreIndexNames) { $this->database = $database; $columns = $schema->listTableColumns($table); if (empty($columns)) { return []; } $indexGenerator = new IndexGenerator($table, $schema, $ignoreIndexNames); $fields = $this->setEnum($this->getFields($columns, $indexGenerator), $table); $fields = $this->getMultiFieldIndexes($fields, $indexGenerator); return $fields; }
/** * Create array of all the fields for a table * * @param string $table Table Name * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema * @param string $database * * @return array|bool */ public function generate($table, $schema, $database) { $this->database = $database; $columns = $schema->listTableColumns($table); if (empty($columns)) { return false; } $indexParser = new IndexParser($table, $schema); $fields = $this->setEnum($this->getFields($columns, $indexParser), $table); $indexes = $this->getMultiFieldIndexes($indexParser); return array_merge($fields, $indexes); }
public function testCommentStringsAreQuoted() { if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement() && $this->_conn->getDatabasePlatform()->getName() != 'mssql') { $this->markTestSkipped('Database does not support column comments.'); } $table = new Table('my_table'); $table->addColumn('id', 'integer', array('comment' => "It's a comment with a quote")); $table->setPrimaryKey(array('id')); $this->_sm->createTable($table); $columns = $this->_sm->listTableColumns("my_table"); $this->assertEquals("It's a comment with a quote", $columns['id']->getComment()); }
/** * Create array of all the fields for a table * * @param string $table Table Name * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema * @param string $database * @param bool $ignoreIndexNames * * @return array|bool */ public function generate($table, $schema, $database, $ignoreIndexNames) { $this->defaultConnection = DB::getDefaultConnection(); $this->database = $database; $columns = $schema->listTableColumns($table); if (empty($columns)) { return false; } $indexGenerator = new IndexGenerator($table, $schema, $ignoreIndexNames); $fields = $this->setEnum($this->getFields($columns, $indexGenerator), $table); $fields = $this->getTableProperty($fields, $table); $indexes = $this->getMultiFieldIndexes($indexGenerator); return array_merge($fields, $indexes); }
/** * */ public function generateForm() { $ignoredColumns = [$this->instance->getKeyName(), Model::CREATED_AT, Model::UPDATED_AT, 'deleted_at']; $columns = $this->schemaManager->listTableColumns($this->table); $textareas = []; foreach ($columns as $column) { if (in_array($column->getName(), $ignoredColumns)) { continue; } $formItem = $this->generateFormItem($column); if ($column->getType()->getName() === 'text') { $textareas[] = $formItem; } else { $this->formItems[] = $formItem; } } $this->formItems = array_merge($this->formItems, $textareas); }
/** * @group DBAL-42 */ public function testAutomaticallyAppendCommentOnMarkedColumns() { if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) { $this->markTestSkipped('Database does not support column comments.'); } $table = new \Doctrine\DBAL\Schema\Table('column_comment_test2'); $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); $table->addColumn('obj', 'object', array('comment' => 'This is a comment')); $table->addColumn('arr', 'array', array('comment' => 'This is a comment')); $table->setPrimaryKey(array('id')); $this->_sm->createTable($table); $columns = $this->_sm->listTableColumns("column_comment_test2"); $this->assertEquals(3, count($columns)); $this->assertEquals('This is a comment', $columns['id']->getComment()); $this->assertEquals('This is a comment', $columns['obj']->getComment(), "The Doctrine2 Typehint should be stripped from comment."); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\ObjectType', $columns['obj']->getType(), "The Doctrine2 should be detected from comment hint."); $this->assertEquals('This is a comment', $columns['arr']->getComment(), "The Doctrine2 Typehint should be stripped from comment."); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\ArrayType', $columns['arr']->getType(), "The Doctrine2 should be detected from comment hint."); }
public function testListTableColumns() { $table = $this->createListTableColumns(); $this->_sm->dropAndCreateTable($table); $columns = $this->_sm->listTableColumns('list_table_columns'); $this->assertArrayHasKey('text', $columns); $this->assertEquals('text', strtolower($columns['text']->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\StringType', $columns['text']->gettype()); $this->assertEquals('ts', strtolower($columns['ts']->getname())); $this->assertInstanceOf('Crate\\DBAL\\Types\\TimestampType', $columns['ts']->gettype()); $this->assertEquals('num_float_double', strtolower($columns['num_float_double']->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\FloatType', $columns['num_float_double']->gettype()); $this->assertArrayHasKey('num_short', $columns); $this->assertEquals('num_short', strtolower($columns['num_short']->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\SmallIntType', $columns['num_short']->gettype()); $this->assertArrayHasKey('num_int', $columns); $this->assertEquals('num_int', strtolower($columns['num_int']->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\IntegerType', $columns['num_int']->gettype()); $this->assertArrayHasKey('num_long', $columns); $this->assertEquals('num_long', strtolower($columns['num_long']->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\BigIntType', $columns['num_long']->gettype()); $this->assertEquals('obj', strtolower($columns['obj']->getname())); $this->assertInstanceOf('Crate\\DBAL\\Types\\MapType', $columns['obj']->gettype()); $this->assertEquals("obj['id']", strtolower($columns["obj['id']"]->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\IntegerType', $columns["obj['id']"]->gettype()); $this->assertEquals("obj['name']", strtolower($columns["obj['name']"]->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\StringType', $columns["obj['name']"]->gettype()); $this->assertEquals('obj2', strtolower($columns['obj2']->getname())); $this->assertInstanceOf('Crate\\DBAL\\Types\\MapType', $columns['obj2']->gettype()); $this->assertEquals("obj2['id']", strtolower($columns["obj2['id']"]->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\IntegerType', $columns["obj2['id']"]->gettype()); $this->assertEquals("obj2['name']", strtolower($columns["obj2['name']"]->getname())); $this->assertInstanceOf('Doctrine\\DBAL\\Types\\StringType', $columns["obj2['name']"]->gettype()); $this->assertEquals('arr_float', strtolower($columns['arr_float']->getname())); $this->assertInstanceOf('Crate\\DBAL\\Types\\ArrayType', $columns['arr_float']->gettype()); $this->assertEquals('arr_str', strtolower($columns['arr_str']->getname())); $this->assertInstanceOf('Crate\\DBAL\\Types\\ArrayType', $columns['arr_str']->gettype()); $this->assertEquals('arr_obj', strtolower($columns['arr_obj']->getname())); $this->assertInstanceOf('Crate\\DBAL\\Types\\ArrayType', $columns['arr_obj']->gettype()); }
/** * @group DBAL-44 */ public function testColumnDefaultLifecycle() { $table = new Table("col_def_lifecycle"); $table->addColumn('id', 'integer', array('primary' => true, 'autoincrement' => true)); $table->addColumn('column1', 'string', array('default' => null)); $table->addColumn('column2', 'string', array('default' => false)); $table->addColumn('column3', 'string', array('default' => true)); $table->addColumn('column4', 'string', array('default' => 0)); $table->addColumn('column5', 'string', array('default' => '')); $table->addColumn('column6', 'string', array('default' => 'def')); $table->setPrimaryKey(array('id')); $this->_sm->dropAndCreateTable($table); $columns = $this->_sm->listTableColumns('col_def_lifecycle'); $this->assertNull($columns['id']->getDefault()); $this->assertNull($columns['column1']->getDefault()); $this->assertSame('', $columns['column2']->getDefault()); $this->assertSame('1', $columns['column3']->getDefault()); $this->assertSame('0', $columns['column4']->getDefault()); $this->assertSame('', $columns['column5']->getDefault()); $this->assertSame('def', $columns['column6']->getDefault()); $diffTable = clone $table; $diffTable->changeColumn('column1', array('default' => false)); $diffTable->changeColumn('column2', array('default' => null)); $diffTable->changeColumn('column3', array('default' => false)); $diffTable->changeColumn('column4', array('default' => null)); $diffTable->changeColumn('column5', array('default' => false)); $diffTable->changeColumn('column6', array('default' => 666)); $comparator = new Comparator(); $this->_sm->alterTable($comparator->diffTable($table, $diffTable)); $columns = $this->_sm->listTableColumns('col_def_lifecycle'); $this->assertSame('', $columns['column1']->getDefault()); $this->assertNull($columns['column2']->getDefault()); $this->assertSame('', $columns['column3']->getDefault()); $this->assertNull($columns['column4']->getDefault()); $this->assertSame('', $columns['column5']->getDefault()); $this->assertSame('666', $columns['column6']->getDefault()); }
public function generateFieldsFromTable() { $columns = $this->schema->listTableColumns($this->tableName); $fields = []; foreach ($columns as $column) { switch ($column->getType()->getName()) { case 'integer': $fieldInput = $this->generateIntFieldInput($column->getName(), 'integer', $column); $type = 'number'; break; case 'smallint': $fieldInput = $this->generateIntFieldInput($column->getName(), 'smallInteger', $column); $type = 'number'; break; case 'bigint': $fieldInput = $this->generateIntFieldInput($column->getName(), 'bigInteger', $column); $type = 'number'; break; case 'boolean': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'boolean'); $type = 'text'; break; case 'datetime': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'dateTime'); $type = 'date'; break; case 'datetimetz': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'dateTimeTz'); $type = 'date'; break; case 'date': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'date'); $type = 'date'; break; case 'time': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'time'); $type = 'text'; break; case 'decimal': $fieldInput = $this->generateDecimalInput($column, 'decimal'); $type = 'number'; break; case 'float': $fieldInput = $this->generateFloatInput($column); $type = 'number'; break; case 'string': $fieldInput = $this->generateStringInput($column); $type = 'text'; break; case 'text': $fieldInput = $this->generateTextInput($column); $type = 'textarea'; break; default: $fieldInput = $this->generateTextInput($column); $type = 'text'; } if (strtolower($column->getName()) == 'password') { $type = 'password'; } elseif (strtolower($column->getName()) == 'email') { $type = 'email'; } if (!empty($fieldInput)) { // $fieldInput .= $this->checkForDefault($column); // $fieldInput .= $this->checkForNullable($column); // $fieldInput .= $this->checkForUnique($column); $fields[] = GeneratorUtils::processFieldInput($fieldInput, $type, ''); } } return $fields; }
/** * {@see AbstractSchemaManager::listTableColumns} */ public function listTableColumns($table, $database = null) { return $this->manager->listTableColumns($this->replacePrefix($table), $database); }
/** * @return array */ private function listColumns() { return $this->schema->listTableColumns($this->table); }
public function generateFieldsFromTable() { $this->schema->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); $columns = $this->schema->listTableColumns($this->tableName); $fields = []; foreach ($columns as $column) { switch ($column->getType()->getName()) { case 'integer': $fieldInput = $this->generateIntFieldInput($column->getName(), 'integer', $column); if (strpos($column->getName(), '_id') > 0) { $type = 'select'; $tableSourceName = $this->checkForForeignKeySourceTable($column->getName()); $columnName = DataBaseHelper::getColumnFromTable($tableSourceName); if ($tableSourceName != '') { $type .= ':' . $tableSourceName . ':' . $columnName; } } else { $type = 'number'; } break; case 'tinyint': $fieldInput = $this->generateIntFieldInput($column->getName(), 'tinyInteger', $column); $type = 'checkbox'; break; case 'smallint': $fieldInput = $this->generateIntFieldInput($column->getName(), 'smallInteger', $column); $type = 'number'; break; case 'bigint': $fieldInput = $this->generateIntFieldInput($column->getName(), 'bigInteger', $column); $type = 'number'; break; case 'boolean': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'boolean'); $type = 'checkbox'; break; case 'datetime': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'dateTime'); $type = 'date'; break; case 'datetimetz': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'dateTimeTz'); $type = 'date'; break; case 'date': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'date'); $type = 'date'; break; case 'time': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'time'); $type = 'text'; break; case 'decimal': $fieldInput = $this->generateDecimalInput($column, 'decimal'); $type = 'number'; break; case 'float': $fieldInput = $this->generateFloatInput($column); $type = 'number'; break; case 'string': $fieldInput = $this->generateStringInput($column); $type = 'text'; break; case 'text': $fieldInput = $this->generateTextInput($column); $type = 'textarea'; break; default: $fieldInput = $this->generateTextInput($column); $type = 'text'; } if (strtolower($column->getName()) == 'password') { $type = 'password'; } elseif (strtolower($column->getName()) == 'email') { $type = 'email'; } if (!empty($fieldInput)) { // $fieldInput .= $this->checkForDefault($column); // $fieldInput .= $this->checkForNullable($column); // $fieldInput .= $this->checkForUnique($column); $fields[] = GeneratorUtils::processFieldInput($fieldInput, $type, $this->getValidations($column)); } } return $fields; }
public function testListTableColumns() { $columns = $this->sm->listTableColumns('points'); $this->assertArrayHasKey('point', $columns); $this->assertEquals('point', strtolower($columns['point']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeometryType', $columns['point']->getType()); $this->assertEquals(false, $columns['point']->getUnsigned()); $this->assertEquals(true, $columns['point']->getNotnull()); $this->assertEquals(null, $columns['point']->getDefault()); $this->assertInternalType('array', $columns['point']->getPlatformOptions()); $this->assertEquals('POINT', $columns['point']->getCustomSchemaOption('geometry_type')); $this->assertEquals(0, $columns['point']->getCustomSchemaOption('srid')); // --- $this->assertArrayHasKey('point_2d', $columns); $this->assertEquals('point_2d', strtolower($columns['point_2d']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeometryType', $columns['point_2d']->getType()); $this->assertEquals(false, $columns['point_2d']->getUnsigned()); $this->assertEquals(true, $columns['point_2d']->getNotnull()); $this->assertEquals(null, $columns['point_2d']->getDefault()); $this->assertInternalType('array', $columns['point_2d']->getPlatformOptions()); $this->assertEquals('POINT', $columns['point_2d']->getCustomSchemaOption('geometry_type')); $this->assertEquals(3785, $columns['point_2d']->getCustomSchemaOption('srid')); // --- $this->assertArrayHasKey('point_3dz', $columns); $this->assertEquals('point_3dz', strtolower($columns['point_3dz']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeometryType', $columns['point_3dz']->getType()); $this->assertEquals(false, $columns['point_3dz']->getUnsigned()); $this->assertEquals(true, $columns['point_3dz']->getNotnull()); $this->assertEquals(null, $columns['point_3dz']->getDefault()); $this->assertInternalType('array', $columns['point_3dz']->getPlatformOptions()); $this->assertEquals('POINTZ', $columns['point_3dz']->getCustomSchemaOption('geometry_type')); $this->assertEquals(3785, $columns['point_3dz']->getCustomSchemaOption('srid')); // --- $this->assertArrayHasKey('point_3dm', $columns); $this->assertEquals('point_3dm', strtolower($columns['point_3dm']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeometryType', $columns['point_3dm']->getType()); $this->assertEquals(false, $columns['point_3dm']->getUnsigned()); $this->assertEquals(true, $columns['point_3dm']->getNotnull()); $this->assertEquals(null, $columns['point_3dm']->getDefault()); $this->assertInternalType('array', $columns['point_3dm']->getPlatformOptions()); $this->assertEquals('POINTM', $columns['point_3dm']->getCustomSchemaOption('geometry_type')); $this->assertEquals(3785, $columns['point_3dm']->getCustomSchemaOption('srid')); // --- $this->assertArrayHasKey('point_2d_nosrid', $columns); $this->assertEquals('point_4d', strtolower($columns['point_4d']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeometryType', $columns['point_4d']->getType()); $this->assertEquals(false, $columns['point_4d']->getUnsigned()); $this->assertEquals(true, $columns['point_4d']->getNotnull()); $this->assertEquals(null, $columns['point_4d']->getDefault()); $this->assertInternalType('array', $columns['point_4d']->getPlatformOptions()); $this->assertEquals('POINTZM', $columns['point_4d']->getCustomSchemaOption('geometry_type')); $this->assertEquals(3785, $columns['point_4d']->getCustomSchemaOption('srid')); // --- $this->assertArrayHasKey('point_2d_nullable', $columns); $this->assertEquals('point_2d_nullable', strtolower($columns['point_2d_nullable']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeometryType', $columns['point_2d_nullable']->getType()); $this->assertEquals(false, $columns['point_2d_nullable']->getUnsigned()); $this->assertEquals(false, $columns['point_2d_nullable']->getNotnull()); //$this->assertEquals('NULL::geometry', $columns['point_2d_nullable']->getDefault()); $this->assertInternalType('array', $columns['point_2d_nullable']->getPlatformOptions()); $this->assertEquals('POINT', $columns['point_2d_nullable']->getCustomSchemaOption('geometry_type')); $this->assertEquals(3785, $columns['point_2d_nullable']->getCustomSchemaOption('srid')); // --- $this->assertArrayHasKey('point_2d_nosrid', $columns); $this->assertEquals('point_2d_nosrid', strtolower($columns['point_2d_nosrid']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeometryType', $columns['point_2d_nosrid']->getType()); $this->assertEquals(false, $columns['point_2d_nosrid']->getUnsigned()); $this->assertEquals(true, $columns['point_2d_nosrid']->getNotnull()); $this->assertEquals(null, $columns['point_2d_nosrid']->getDefault()); $this->assertInternalType('array', $columns['point_2d_nosrid']->getPlatformOptions()); $this->assertEquals('POINT', $columns['point_2d_nosrid']->getCustomSchemaOption('geometry_type')); $this->assertEquals(0, $columns['point_2d_nosrid']->getCustomSchemaOption('srid')); // --- $this->assertArrayHasKey('point_geography_2d', $columns); $this->assertEquals('point_geography_2d', strtolower($columns['point_geography_2d']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeographyType', $columns['point_geography_2d']->getType()); $this->assertEquals(false, $columns['point_geography_2d']->getUnsigned()); $this->assertEquals(true, $columns['point_geography_2d']->getNotnull()); $this->assertEquals(null, $columns['point_geography_2d']->getDefault()); $this->assertInternalType('array', $columns['point_geography_2d']->getPlatformOptions()); $this->assertEquals('POINT', $columns['point_geography_2d']->getCustomSchemaOption('geometry_type')); $this->assertEquals(4326, $columns['point_geography_2d']->getCustomSchemaOption('srid')); // --- $this->assertArrayHasKey('point_geography_2d_srid', $columns); $this->assertEquals('point_geography_2d_srid', strtolower($columns['point_geography_2d_srid']->getName())); $this->assertInstanceOf('Jsor\\Doctrine\\PostGIS\\Types\\GeographyType', $columns['point_geography_2d_srid']->getType()); $this->assertEquals(false, $columns['point_geography_2d_srid']->getUnsigned()); $this->assertEquals(true, $columns['point_geography_2d_srid']->getNotnull()); $this->assertEquals(null, $columns['point_geography_2d_srid']->getDefault()); $this->assertInternalType('array', $columns['point_geography_2d_srid']->getPlatformOptions()); $this->assertEquals('POINT', $columns['point_geography_2d_srid']->getCustomSchemaOption('geometry_type')); $this->assertEquals(4326, $columns['point_geography_2d_srid']->getCustomSchemaOption('srid')); }
/** * Get table columns. * * @param string $table * @param string|null $database * @return \Doctrine\DBAL\Schema\Column[] */ public function getColumns($table, $database = null) { return $this->schema->listTableColumns($table, $database); }