Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-122

Impossible to save data to image/binary/varbinary

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Can't Fix
    • Affects Version/s: 2.0.4
    • Fix Version/s: None
    • Component/s: Platforms
    • Labels:
      None
    • Environment:
      XAMP, MsSQL-Server 2008, PHP 5.3.x, MS pdo_sqlsrv_vc6_ts.dll

      Description

      When trying to insert a value into a Column with type 'image', 'binary' or 'varbinary' the SQLServer states that this is not possible.
      When trying to insert into 'binary' or 'varbinary' the error message is:
      => Implicit conversion from nvarchar(max) datatype to varbinary(max) is not allowed.

      When trying to insert into 'image' the error message is:
      => Operand collision: nvarchar(max) is incompatible with image.

      Doctrine prepares the image/binary/varbinary column in the statements as nvarchar(max) which is wrong.

      The cause of this error is that in the MsSQLPlatform::getVarcharTypeDeclarationSQLSnippet($length, $fixed),
      or in the datatype mapping which is to 'text'.

      The documentation for the MsSQLServer states following conversions (http://207.46.16.252/de-de/library/ms187928.aspx):

      *char => binary/varbinary : Explicit conversion
      nchar/nvarchar => image : IMPOSSIBLE

      So the solution would be, either to leave the datatype blank or use the char/varchar datatype when saving into image/binary/varbinary, which would cause an extra datatype as those would collide with 'text' I guess.

        Issue Links

          Activity

          Hide
          Martin Weise added a comment -

          Ok... Thank you for your help. Hopefully MS will fix this...

          Show
          Martin Weise added a comment - Ok... Thank you for your help. Hopefully MS will fix this...
          Hide
          Steve Müller added a comment -

          I will close this for now as we cannot fix this driver bug. This might be reopended as soon as Microsoft fixes the bug in a newer version and we maybe can handle it properly.

          Show
          Steve Müller added a comment - I will close this for now as we cannot fix this driver bug. This might be reopended as soon as Microsoft fixes the bug in a newer version and we maybe can handle it properly.
          Hide
          Steve Müller added a comment -

          Martin Weise There is nothing you can do about when using pdo_sqlsrv. We added a notice to the docs to stick with sqlsrv if possible instead and skipped the BLOB related tests in the test suite. See: https://github.com/doctrine/dbal/commit/637ef6a1826a6937a5ab4fc4c73b8ede46732a73

          Show
          Steve Müller added a comment - Martin Weise There is nothing you can do about when using pdo_sqlsrv. We added a notice to the docs to stick with sqlsrv if possible instead and skipped the BLOB related tests in the test suite. See: https://github.com/doctrine/dbal/commit/637ef6a1826a6937a5ab4fc4c73b8ede46732a73
          Hide
          Martin Weise added a comment -

          Hi @all

          Sorry for the long delay, but the project I am working on, did not update Doctrine for a long time and I started with a the latest version on another project only a month ago. Therefore I could not provide any further feedback and due the fact, that there were some Xmas things going on...

          Anyway, it seems that the reason for this 'bug' is found. Is there anything I can do to help you ?

          Show
          Martin Weise added a comment - Hi @all Sorry for the long delay, but the project I am working on, did not update Doctrine for a long time and I started with a the latest version on another project only a month ago. Therefore I could not provide any further feedback and due the fact, that there were some Xmas things going on... Anyway, it seems that the reason for this 'bug' is found. Is there anything I can do to help you ?
          Hide
          Steve Müller added a comment - - edited

          btw: See: http://sqlsrvphp.codeplex.com/SourceControl/latest#pdo_sqlsrv/pdo_stmt.cpp and search for "// TODO: This will eventually be changed to SQLSRV_PHPTYPE_STREAM when output streaming is implemented.". Then you know why varbinary/lob binding does not work.

          Show
          Steve Müller added a comment - - edited btw: See: http://sqlsrvphp.codeplex.com/SourceControl/latest#pdo_sqlsrv/pdo_stmt.cpp and search for "// TODO: This will eventually be changed to SQLSRV_PHPTYPE_STREAM when output streaming is implemented.". Then you know why varbinary/lob binding does not work.

            People

            • Assignee:
              Steve Müller
              Reporter:
              Martin Weise
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: