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

PDOException: String data, right truncation when insert a long string #169

Closed
kevinchl opened this Issue Oct 7, 2016 · 6 comments

Comments

Projects
None yet
6 participants
@kevinchl
Copy link

kevinchl commented Oct 7, 2016

Hi all,

I have try to insert a long string into database, but experience the exception: [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation

I am using php7.0.8 and tried both PDO_SQLSRV and SQLSRV for linux driver...

I notice that the issue happen

  • When using prepare statement -> execute.
  • The connection is establish in UTF-8 character set.
  • The string need to long enough ( > 2600 bytes )

Table Schema:

CREATE TABLE dummy_message
(
    id INT PRIMARY KEY NOT NULL IDENTITY,
    message NVARCHAR(MAX)
);

I have prepare PHP script to describe the problem: https://gist.github.com/kevinchl/88edf9b51d79605dd7e32cfac0d04778

Current result:

Fatal error: Uncaught PDOException: SQLSTATE[22001]: [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation in test.php
Stack trace:
#0 /home/vagrant/code/test.php(16): PDOStatement->execute(Array)
#1 /home/vagrant/code/test.php(35): test_insert('Gluten-free Die...')
#2 {main}
  thrown in /home/vagrant/code/test.php on line 16

@kevinchl kevinchl changed the title [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation PDOException: String data, right truncation when insert a long string Oct 7, 2016

@Hadis-Fard Hadis-Fard added the linux label Oct 20, 2016

@meet-bhagdev

This comment has been minimized.

Copy link
Contributor

meet-bhagdev commented Oct 25, 2016

@kevinchl We are looking into this

@ethan-tr

This comment has been minimized.

Copy link

ethan-tr commented Nov 14, 2016

@meet-bhagdev Will a release with a fix for this issue and #163 be available soon?

@PetrSpacek

This comment has been minimized.

Copy link

PetrSpacek commented Nov 18, 2016

We confirm the issue on Ubuntu 14.04, php7.0.10 compiled with PDO_SQLSRV and SQLSRV for linux drivers.
Looking forward see a fix for this.

@scarja

This comment has been minimized.

Copy link

scarja commented Nov 22, 2016

We also confirm this issue running PHP 7.0.8-0ubuntu0.16.04.3 . Any planned resolution time? Field type text in our case.

@meet-bhagdev

This comment has been minimized.

Copy link
Contributor

meet-bhagdev commented Nov 22, 2016

This should be fixed with our latest release. You can upgrade using PECL: https://github.com/Microsoft/msphpsql/tree/PHP-7.0-Linux#install

If you need the binaries, we will be releasing them soon on GitHub

@scarja

This comment has been minimized.

Copy link

scarja commented Nov 23, 2016

Confirmed that release 4.0.7.0 fixes this issue.

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