From cde291a831c509467fdbf0aba369b7bc613218c0 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Wed, 7 Jul 2021 22:21:13 +0100 Subject: [PATCH 1/2] Add additional integer type support Signed-off-by: Will Jones --- docs/book/sql-ddl.md | 3 ++ src/Sql/Ddl/Column/Double.php | 14 +++++++++ src/Sql/Ddl/Column/SmallInteger.php | 11 +++++++ src/Sql/Ddl/Column/TinyInteger.php | 11 +++++++ test/unit/Sql/Ddl/Column/DoubleTest.php | 25 ++++++++++++++++ test/unit/Sql/Ddl/Column/SmallIntegerTest.php | 30 +++++++++++++++++++ test/unit/Sql/Ddl/Column/TinyIntegerTest.php | 30 +++++++++++++++++++ 7 files changed, 124 insertions(+) create mode 100644 src/Sql/Ddl/Column/Double.php create mode 100644 src/Sql/Ddl/Column/SmallInteger.php create mode 100644 src/Sql/Ddl/Column/TinyInteger.php create mode 100644 test/unit/Sql/Ddl/Column/DoubleTest.php create mode 100644 test/unit/Sql/Ddl/Column/SmallIntegerTest.php create mode 100644 test/unit/Sql/Ddl/Column/TinyIntegerTest.php diff --git a/docs/book/sql-ddl.md b/docs/book/sql-ddl.md index 7aa64503e..4ea698399 100644 --- a/docs/book/sql-ddl.md +++ b/docs/book/sql-ddl.md @@ -171,12 +171,15 @@ Column (generic) | `$name = null` Date | `$name` DateTime | `$name` Decimal | `$name`, `$precision`, `$scale = null` +Double | `$name`, `$digits`, `$decimal` Float | `$name`, `$digits`, `$decimal` (Note: this class is deprecated as of 2.4.0; use Floating instead) Floating | `$name`, `$digits`, `$decimal` Integer | `$name`, `$nullable = false`, `default = null`, `array $options = array()` +SmallInteger | `$name`, `$nullable = false`, `$default = null`, `array $options = array()` Text | `$name`, `$length`, `nullable = false`, `$default = null`, `array $options = array()` Time | `$name` Timestamp | `$name` +TinyInteger | `$name`, `$nullable = false`, `$default = null`, `array $options = array()` Varbinary | `$name`, `$length` Varchar | `$name`, `$length` diff --git a/src/Sql/Ddl/Column/Double.php b/src/Sql/Ddl/Column/Double.php new file mode 100644 index 000000000..871181d0e --- /dev/null +++ b/src/Sql/Ddl/Column/Double.php @@ -0,0 +1,14 @@ +getExpressionData() + ); + } +} diff --git a/test/unit/Sql/Ddl/Column/SmallIntegerTest.php b/test/unit/Sql/Ddl/Column/SmallIntegerTest.php new file mode 100644 index 000000000..fbaa41868 --- /dev/null +++ b/test/unit/Sql/Ddl/Column/SmallIntegerTest.php @@ -0,0 +1,30 @@ +getName()); + } + + /** + * @covers \Laminas\Db\Sql\Ddl\Column\Column::getExpressionData + */ + public function testGetExpressionData() + { + $column = new SmallInteger('foo'); + self::assertEquals( + [['%s %s NOT NULL', ['foo', 'SMALLINT'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], + $column->getExpressionData() + ); + } +} diff --git a/test/unit/Sql/Ddl/Column/TinyIntegerTest.php b/test/unit/Sql/Ddl/Column/TinyIntegerTest.php new file mode 100644 index 000000000..3a19b05cf --- /dev/null +++ b/test/unit/Sql/Ddl/Column/TinyIntegerTest.php @@ -0,0 +1,30 @@ +getName()); + } + + /** + * @covers \Laminas\Db\Sql\Ddl\Column\Column::getExpressionData + */ + public function testGetExpressionData() + { + $column = new TinyInteger('foo'); + self::assertEquals( + [['%s %s NOT NULL', ['foo', 'TINYINT'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], + $column->getExpressionData() + ); + } +} From 51cf905d6246d752ba719daa86eea33ddda30432 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Thu, 8 Jul 2021 10:42:17 +0100 Subject: [PATCH 2/2] Fix covers annotation in TinyIntegerTest Signed-off-by: Will Jones --- test/unit/Sql/Ddl/Column/TinyIntegerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/Sql/Ddl/Column/TinyIntegerTest.php b/test/unit/Sql/Ddl/Column/TinyIntegerTest.php index 3a19b05cf..b80cd3548 100644 --- a/test/unit/Sql/Ddl/Column/TinyIntegerTest.php +++ b/test/unit/Sql/Ddl/Column/TinyIntegerTest.php @@ -8,7 +8,7 @@ class TinyIntegerTest extends TestCase { /** - * @covers \Laminas\Db\Sql\Ddl\Column\SmallInteger::__construct + * @covers \Laminas\Db\Sql\Ddl\Column\TinyInteger::__construct */ public function testObjectConstruction() {