|
|
@@ -638,6 +638,40 @@ SQL;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Test describing a table with postgres function defaults
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testDescribeTableFunctionDefaultValue()
|
|
|
+ {
|
|
|
+ $this->_needsConnection();
|
|
|
+ $connection = ConnectionManager::get('test');
|
|
|
+ $sql = <<<SQL
|
|
|
+CREATE TABLE schema_function_defaults (
|
|
|
+ "id" SERIAL,
|
|
|
+ year INT DEFAULT DATE_PART('year'::text, NOW()),
|
|
|
+ PRIMARY KEY("id")
|
|
|
+);
|
|
|
+SQL;
|
|
|
+ $connection->execute($sql);
|
|
|
+ $schema = new SchemaCollection($connection);
|
|
|
+ $result = $schema->describe('schema_function_defaults');
|
|
|
+ $connection->execute('DROP TABLE schema_function_defaults');
|
|
|
+
|
|
|
+ $expected = [
|
|
|
+ 'type' => 'integer',
|
|
|
+ 'default' => "date_part('year'::text, now())",
|
|
|
+ 'null' => true,
|
|
|
+ 'precision' => null,
|
|
|
+ 'length' => 10,
|
|
|
+ 'comment' => null,
|
|
|
+ 'unsigned' => null,
|
|
|
+ 'autoIncrement' => null,
|
|
|
+ ];
|
|
|
+ $this->assertEquals($expected, $result->getColumn('year'));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Column provider for creating column sql
|
|
|
*
|
|
|
* @return array
|