Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
WrdVdb opened this issue Jan 9, 2024 · 2 comments

Comments

@WrdVdb
Copy link

WrdVdb commented Jan 9, 2024

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.

@WrdVdb
Copy link
Author

WrdVdb commented Jan 9, 2024

--- /dev/null
+++ ../src/Platforms/SQLServerPlatform.php
@@ -1548,6 +1548,7 @@
             'uniqueidentifier' => Types::GUID,
             'varbinary'        => Types::BINARY,
             'varchar'          => Types::STRING,
+            'sysname'          => Types::STRING,
         ];
     }
 

@derrabus
Copy link
Member

Please send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants