Skip to content

Commit d2c45cb

Browse files
committed
Rename Real type to SmallFloat
1 parent ac30dbf commit d2c45cb

21 files changed

+40
-56
lines changed

docs/en/reference/types.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ or ``null`` if no data is present.
125125
it approximates precision which can lead to false assumptions in
126126
applications.
127127

128-
real
128+
smallfloat
129129
+++++
130130

131131
Maps and converts single precision floating-point values.
@@ -580,7 +580,7 @@ Please also notice the mapping specific footnotes for additional information.
580580
| | +--------------------------+ | |
581581
| | | **SQLite** | | |
582582
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
583-
| **real** | ``float`` | **MySQL** | *all* | ``FLOAT`` ``UNSIGNED`` [10] |
583+
| **smallfloat** | ``float`` | **MySQL** | *all* | ``FLOAT`` ``UNSIGNED`` [10] |
584584
| | +--------------------------+---------+----------------------------------------------------------+
585585
| | | **PostgreSQL** | *all* | ``REAL`` |
586586
| | +--------------------------+ | |

src/Platforms/AbstractMySQLPlatform.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ public function getFloatDeclarationSQL(array $column): string
649649
/**
650650
* {@inheritDoc}
651651
*/
652-
public function getRealFloatDeclarationSQL(array $column): string
652+
public function getSmallFloatDeclarationSQL(array $column): string
653653
{
654654
return 'FLOAT' . $this->getUnsignedDeclaration($column);
655655
}
@@ -735,7 +735,7 @@ protected function initializeDoctrineTypeMappings(): void
735735
'datetime' => Types::DATETIME_MUTABLE,
736736
'decimal' => Types::DECIMAL,
737737
'double' => Types::FLOAT,
738-
'float' => Types::REAL,
738+
'float' => Types::SMALLFLOAT,
739739
'int' => Types::INTEGER,
740740
'integer' => Types::INTEGER,
741741
'json' => Types::JSON,

src/Platforms/AbstractPlatform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,7 @@ public function getFloatDeclarationSQL(array $column): string
18781878
}
18791879

18801880
/** @param mixed[] $column */
1881-
public function getRealFloatDeclarationSQL(array $column): string
1881+
public function getSmallFloatDeclarationSQL(array $column): string
18821882
{
18831883
return 'REAL';
18841884
}

src/Platforms/DB2Platform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function initializeDoctrineTypeMappings(): void
5252
'decimal' => Types::DECIMAL,
5353
'double' => Types::FLOAT,
5454
'integer' => Types::INTEGER,
55-
'real' => Types::REAL,
55+
'real' => Types::SMALLFLOAT,
5656
'smallint' => Types::SMALLINT,
5757
'time' => Types::TIME_MUTABLE,
5858
'timestamp' => Types::DATETIME_MUTABLE,

src/Platforms/OraclePlatform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ protected function initializeDoctrineTypeMappings(): void
750750
'nvarchar2' => Types::STRING,
751751
'pls_integer' => Types::BOOLEAN,
752752
'raw' => Types::BINARY,
753-
'real' => Types::REAL,
753+
'real' => Types::SMALLFLOAT,
754754
'rowid' => Types::STRING,
755755
'timestamp' => Types::DATETIME_MUTABLE,
756756
'timestamptz' => Types::DATETIMETZ_MUTABLE,

src/Platforms/PostgreSQLPlatform.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ protected function initializeDoctrineTypeMappings(): void
701701
'double' => Types::FLOAT,
702702
'double precision' => Types::FLOAT,
703703
'float' => Types::FLOAT,
704-
'float4' => Types::REAL,
704+
'float4' => Types::SMALLFLOAT,
705705
'float8' => Types::FLOAT,
706706
'inet' => Types::STRING,
707707
'int' => Types::INTEGER,
@@ -717,7 +717,7 @@ protected function initializeDoctrineTypeMappings(): void
717717
'serial' => Types::INTEGER,
718718
'serial4' => Types::INTEGER,
719719
'serial8' => Types::BIGINT,
720-
'real' => Types::REAL,
720+
'real' => Types::SMALLFLOAT,
721721
'smallint' => Types::SMALLINT,
722722
'text' => Types::TEXT,
723723
'time' => Types::TIME_MUTABLE,

src/Platforms/SQLServerPlatform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ protected function initializeDoctrineTypeMappings(): void
10571057
'ntext' => Types::TEXT,
10581058
'numeric' => Types::DECIMAL,
10591059
'nvarchar' => Types::STRING,
1060-
'real' => Types::REAL,
1060+
'real' => Types::SMALLFLOAT,
10611061
'smalldatetime' => Types::DATETIME_MUTABLE,
10621062
'smallint' => Types::SMALLINT,
10631063
'smallmoney' => Types::INTEGER,

src/Platforms/SQLitePlatform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ protected function initializeDoctrineTypeMappings(): void
459459
'ntext' => 'string',
460460
'numeric' => 'decimal',
461461
'nvarchar' => 'string',
462-
'real' => 'real',
462+
'real' => 'smallfloat',
463463
'serial' => 'integer',
464464
'smallint' => 'smallint',
465465
'string' => 'string',

src/Types/RealFloatType.php renamed to src/Types/SmallFloatType.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
88

9-
final class RealFloatType extends Type
9+
class SmallFloatType extends Type
1010
{
1111
/**
1212
* {@inheritDoc}
1313
*/
1414
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
1515
{
16-
return $platform->getRealFloatDeclarationSQL($column);
16+
return $platform->getSmallFloatDeclarationSQL($column);
1717
}
1818

1919
/**

src/Types/Type.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ abstract class Type
3838
Types::GUID => GuidType::class,
3939
Types::INTEGER => IntegerType::class,
4040
Types::JSON => JsonType::class,
41-
Types::REAL => RealFloatType::class,
4241
Types::SIMPLE_ARRAY => SimpleArrayType::class,
42+
Types::SMALLFLOAT => SmallFloatType::class,
4343
Types::SMALLINT => SmallIntType::class,
4444
Types::STRING => StringType::class,
4545
Types::TEXT => TextType::class,

src/Types/Types.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ final class Types
2626
public const GUID = 'guid';
2727
public const INTEGER = 'integer';
2828
public const JSON = 'json';
29-
public const REAL = 'real';
3029
public const SIMPLE_ARRAY = 'simple_array';
30+
public const SMALLFLOAT = 'smallfloat';
3131
public const SMALLINT = 'smallint';
3232
public const STRING = 'string';
3333
public const TEXT = 'text';

tests/Functional/Driver/PgSQL/ResultTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ public static function typedValueProvider(): Generator
144144
yield 'boolean true' => ['BOOLEAN', true, Types::BOOLEAN];
145145
yield 'boolean false' => ['BOOLEAN', false, Types::BOOLEAN];
146146
yield 'float' => ['DOUBLE PRECISION', 47.11, Types::FLOAT];
147-
yield 'real' => ['REAL', 47.11, Types::REAL];
147+
yield 'real' => ['REAL', 47.11, Types::SMALLFLOAT];
148148
yield 'negative float with exponent' => ['DOUBLE PRECISION', -8.15e10, Types::FLOAT];
149-
yield 'negative real with exponent' => ['REAL', -8.15e5, Types::REAL];
149+
yield 'negative real with exponent' => ['REAL', -8.15e5, Types::SMALLFLOAT];
150150
yield 'double' => ['DOUBLE PRECISION', 47.11, Types::FLOAT];
151151
yield 'decimal' => ['NUMERIC (6, 2)', '47.11', Types::DECIMAL];
152152
yield 'binary' => ['BYTEA', chr(0x8b), Types::BINARY];

tests/Functional/Schema/MySQLSchemaManagerTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Doctrine\DBAL\Types\BlobType;
1818
use Doctrine\DBAL\Types\FloatType;
1919
use Doctrine\DBAL\Types\JsonType;
20-
use Doctrine\DBAL\Types\RealFloatType;
20+
use Doctrine\DBAL\Types\SmallFloatType;
2121
use Doctrine\DBAL\Types\Type;
2222
use Doctrine\DBAL\Types\Types;
2323

@@ -378,16 +378,16 @@ public function testListUnsignedFloatTypeColumns(): void
378378
$table = new Table($tableName);
379379

380380
$table->addColumn('col_unsigned', Types::FLOAT, ['unsigned' => true]);
381-
$table->addColumn('col_real_unsigned', Types::REAL, ['unsigned' => true]);
381+
$table->addColumn('col_smallfloat_unsigned', Types::SMALLFLOAT, ['unsigned' => true]);
382382

383383
$this->dropAndCreateTable($table);
384384

385385
$columns = $this->schemaManager->listTableColumns($tableName);
386386

387387
self::assertInstanceOf(FloatType::class, $columns['col_unsigned']->getType());
388-
self::assertInstanceOf(RealFloatType::class, $columns['col_real_unsigned']->getType());
388+
self::assertInstanceOf(SmallFloatType::class, $columns['col_smallfloat_unsigned']->getType());
389389
self::assertTrue($columns['col_unsigned']->getUnsigned());
390-
self::assertTrue($columns['col_real_unsigned']->getUnsigned());
390+
self::assertTrue($columns['col_smallfloat_unsigned']->getUnsigned());
391391
}
392392

393393
public function testJsonColumnType(): void

tests/Functional/Schema/PostgreSQLSchemaManagerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public function testListNegativeColumnDefaultValue(): void
415415
$table->addColumn('col_integer', Types::INTEGER, ['default' => -1]);
416416
$table->addColumn('col_bigint', Types::BIGINT, ['default' => -1]);
417417
$table->addColumn('col_float', Types::FLOAT, ['default' => -1.1]);
418-
$table->addColumn('col_real', Types::REAL, ['default' => -1.1]);
418+
$table->addColumn('col_smallfloat', Types::SMALLFLOAT, ['default' => -1.1]);
419419
$table->addColumn('col_decimal', Types::DECIMAL, [
420420
'precision' => 2,
421421
'scale' => 1,
@@ -431,7 +431,7 @@ public function testListNegativeColumnDefaultValue(): void
431431
self::assertEquals(-1, $columns['col_integer']->getDefault());
432432
self::assertEquals(-1, $columns['col_bigint']->getDefault());
433433
self::assertEquals(-1.1, $columns['col_float']->getDefault());
434-
self::assertEquals(-1.1, $columns['col_real']->getDefault());
434+
self::assertEquals(-1.1, $columns['col_smallfloat']->getDefault());
435435
self::assertEquals(-1.1, $columns['col_decimal']->getDefault());
436436
self::assertEquals('(-1)', $columns['col_string']->getDefault());
437437
}

tests/Functional/Schema/SchemaManagerFunctionalTestCase.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use Doctrine\DBAL\Types\DecimalType;
3030
use Doctrine\DBAL\Types\FloatType;
3131
use Doctrine\DBAL\Types\IntegerType;
32-
use Doctrine\DBAL\Types\RealFloatType;
32+
use Doctrine\DBAL\Types\SmallFloatType;
3333
use Doctrine\DBAL\Types\StringType;
3434
use Doctrine\DBAL\Types\TextType;
3535
use Doctrine\DBAL\Types\TimeType;
@@ -867,16 +867,16 @@ public function testListTableFloatTypeColumns(): void
867867
$table = new Table($tableName);
868868

869869
$table->addColumn('col_float', Types::FLOAT);
870-
$table->addColumn('col_real_float', Types::REAL);
870+
$table->addColumn('col_smallfloat', Types::SMALLFLOAT);
871871

872872
$this->dropAndCreateTable($table);
873873

874874
$columns = $this->schemaManager->listTableColumns($tableName);
875875

876876
self::assertInstanceOf(FloatType::class, $columns['col_float']->getType());
877-
self::assertInstanceOf(RealFloatType::class, $columns['col_real_float']->getType());
877+
self::assertInstanceOf(SmallFloatType::class, $columns['col_smallfloat']->getType());
878878
self::assertFalse($columns['col_float']->getUnsigned());
879-
self::assertFalse($columns['col_real_float']->getUnsigned());
879+
self::assertFalse($columns['col_smallfloat']->getUnsigned());
880880
}
881881

882882
/** @param mixed[] $data */

tests/Functional/TypeConversionTest.php

+2-18
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function setUp(): void
3636
$table->addColumn('test_text', Types::TEXT, ['notnull' => false]);
3737
$table->addColumn('test_json', Types::JSON, ['notnull' => false]);
3838
$table->addColumn('test_float', Types::FLOAT, ['notnull' => false]);
39-
$table->addColumn('test_real', Types::REAL, ['notnull' => false]);
39+
$table->addColumn('test_smallfloat', Types::SMALLFLOAT, ['notnull' => false]);
4040
$table->addColumn('test_decimal', Types::DECIMAL, ['notnull' => false, 'scale' => 2, 'precision' => 10]);
4141
$table->setPrimaryKey(['id']);
4242

@@ -92,23 +92,7 @@ public static function floatProvider(): iterable
9292
{
9393
return [
9494
'float' => [Types::FLOAT, 1.5],
95-
];
96-
}
97-
98-
#[DataProvider('realFloatProvider')]
99-
public function testIdempotentConversionToRealFloat(string $type, mixed $originalValue): void
100-
{
101-
$dbValue = $this->processValue($type, $originalValue);
102-
103-
self::assertIsFloat($dbValue);
104-
self::assertEquals($originalValue, $dbValue);
105-
}
106-
107-
/** @return mixed[][] */
108-
public static function realFloatProvider(): iterable
109-
{
110-
return [
111-
'real' => [Types::REAL, 1.5],
95+
'smallfloat' => [Types::SMALLFLOAT, 1.5],
11296
];
11397
}
11498

tests/Platforms/AbstractMySQLPlatformTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public static function getGeneratesFloatDeclarationSQL(): iterable
624624
/**
625625
* {@inheritDoc}
626626
*/
627-
public static function getGeneratesRealFloatDeclarationSQL(): iterable
627+
public static function getGeneratesSmallFloatDeclarationSQL(): iterable
628628
{
629629
return [
630630
[[], 'FLOAT'],

tests/Platforms/AbstractPlatformTestCase.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -979,14 +979,14 @@ public static function getGeneratesFloatDeclarationSQL(): iterable
979979
}
980980

981981
/** @param mixed[] $column */
982-
#[DataProvider('getGeneratesRealFloatDeclarationSQL')]
983-
public function testGeneratesRealFloatDeclarationSQL(array $column, string $expectedSql): void
982+
#[DataProvider('getGeneratesSmallFloatDeclarationSQL')]
983+
public function testGeneratesSmallFloatDeclarationSQL(array $column, string $expectedSql): void
984984
{
985-
self::assertSame($expectedSql, $this->platform->getRealFloatDeclarationSQL($column));
985+
self::assertSame($expectedSql, $this->platform->getSmallFloatDeclarationSQL($column));
986986
}
987987

988988
/** @return mixed[][] */
989-
public static function getGeneratesRealFloatDeclarationSQL(): iterable
989+
public static function getGeneratesSmallFloatDeclarationSQL(): iterable
990990
{
991991
return [
992992
[[], 'REAL'],

tests/Platforms/OraclePlatformTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public function testInitializesDoctrineTypeMappings(): void
322322
self::assertSame(Types::DATE_MUTABLE, $this->platform->getDoctrineTypeMapping('date'));
323323

324324
self::assertTrue($this->platform->hasDoctrineTypeMappingFor('real'));
325-
self::assertSame(Types::REAL, $this->platform->getDoctrineTypeMapping('real'));
325+
self::assertSame(Types::SMALLFLOAT, $this->platform->getDoctrineTypeMapping('real'));
326326
}
327327

328328
public function testGetVariableLengthStringTypeDeclarationSQLNoLength(): void

tests/Platforms/SQLServerPlatformTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ public function testInitializesDoctrineTypeMappings(): void
732732
self::assertSame(Types::FLOAT, $this->platform->getDoctrineTypeMapping('float'));
733733

734734
self::assertTrue($this->platform->hasDoctrineTypeMappingFor('real'));
735-
self::assertSame(Types::REAL, $this->platform->getDoctrineTypeMapping('real'));
735+
self::assertSame(Types::SMALLFLOAT, $this->platform->getDoctrineTypeMapping('real'));
736736

737737
self::assertTrue($this->platform->hasDoctrineTypeMappingFor('double'));
738738
self::assertSame(Types::FLOAT, $this->platform->getDoctrineTypeMapping('double'));

tests/Types/RealFloatTest.php renamed to tests/Types/SmallFloatTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
namespace Doctrine\DBAL\Tests\Types;
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
8-
use Doctrine\DBAL\Types\RealFloatType;
8+
use Doctrine\DBAL\Types\SmallFloatType;
99
use PHPUnit\Framework\MockObject\MockObject;
1010
use PHPUnit\Framework\TestCase;
1111

12-
class RealFloatTest extends TestCase
12+
class SmallFloatTest extends TestCase
1313
{
1414
private AbstractPlatform&MockObject $platform;
15-
private RealFloatType $type;
15+
private SmallFloatType $type;
1616

1717
protected function setUp(): void
1818
{
1919
$this->platform = $this->createMock(AbstractPlatform::class);
20-
$this->type = new RealFloatType();
20+
$this->type = new SmallFloatType();
2121
}
2222

2323
public function testFloatConvertsToPHPValue(): void

0 commit comments

Comments
 (0)