Skip to content

Dbtype sysname missing for SQLServerPlatform (when using change data capture) #6259

@WrdVdb

Description

@WrdVdb

Bug Report

We have enabled cdc (change data capture) on our SQLserver database. And now we get the error

Unknown database type sysname requested, Doctrine\DBAL\Platforms\SQLServer2012Platform may not support it.

doctrine/dbal 3.7.2

Summary

Dump of field:

array:12 [
  "table_name" => "change_tables"
  "schema_name" => "cdc"
  "name" => "capture_instance"
  "type" => "sysname"
  "length" => "256"
  "notnull" => "1"
  "default" => null
  "scale" => "0"
  "precision" => "0"
  "autoincrement" => "0"
  "collation" => "Latin1_General_CI_AS"
  "comment" => null
]

When I add "'sysname' => Types::STRING," to the file vendor/doctrine/dbal/src/Platforms/SQLServerPlatform.php the problem is fixed.

$this->doctrineTypeMapping = [
            'bigint'           => Types::BIGINT,
            'binary'           => Types::BINARY,
            'bit'              => Types::BOOLEAN,
            'blob'             => Types::BLOB,
            'char'             => Types::STRING,
            'date'             => Types::DATE_MUTABLE,
            'datetime'         => Types::DATETIME_MUTABLE,
            'datetime2'        => Types::DATETIME_MUTABLE,
            'datetimeoffset'   => Types::DATETIMETZ_MUTABLE,
            'decimal'          => Types::DECIMAL,
            'double'           => Types::FLOAT,
            'double precision' => Types::FLOAT,
            'float'            => Types::FLOAT,
            'image'            => Types::BLOB,
            'int'              => Types::INTEGER,
            'money'            => Types::INTEGER,
            'nchar'            => Types::STRING,
            'ntext'            => Types::TEXT,
            'numeric'          => Types::DECIMAL,
            'nvarchar'         => Types::STRING,
            'real'             => Types::FLOAT,
            'smalldatetime'    => Types::DATETIME_MUTABLE,
            'smallint'         => Types::SMALLINT,
            'smallmoney'       => Types::INTEGER,
            'text'             => Types::TEXT,
            'time'             => Types::TIME_MUTABLE,
            'tinyint'          => Types::SMALLINT,
            'uniqueidentifier' => Types::GUID,
            'varbinary'        => Types::BINARY,
            'varchar'          => Types::STRING,
            'sysname'          => Types::STRING,
        ];

How to reproduce

Error happens after enabling cdc in the database.

Expected behaviour

No errors when saving records.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions