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

SqlserverSchema return colum length double the actual size #11295

Closed
1 of 3 tasks
dmromanov opened this issue Oct 7, 2017 · 4 comments
Closed
1 of 3 tasks

SqlserverSchema return colum length double the actual size #11295

dmromanov opened this issue Oct 7, 2017 · 4 comments

Comments

@dmromanov
Copy link
Contributor

dmromanov commented Oct 7, 2017

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.5.3.

  • Platform and Target: Windows, MS SQL Server 2012.

What you did

I've created a fixture with a string field having a limit of 50 characters.

// extra columns were truncated
class BakeArticlesFixture extends TestFixture
{
    public $fields = [
        'title' => ['type' => 'string', 'length' => 50, 'null' => false],
    ];
}

What happened

During unit-testing, the table's object reported, that the "title" field has a length of 100 characters.

$schema = $table->getSchema();

What you expected to happen

The length of the field to be reported as 50 characters.

AppVeyor's build log
Affects cakephp/bake/pull/335

@markstory
Copy link
Member

This is likely caused by SQLServer telling us that the field is double the length it actually is because SQLServer uses ucs2/utf16 internally. There might not be a way around this.

@dmromanov
Copy link
Contributor Author

Can't we just divide the value by 2?

@markstory
Copy link
Member

Can't we just divide the value by 2?

We could. We'd have to make sure the columns where NVARCHAR / NCHAR and not the standard VARCHAR/CHAR columns as only types with the N prefix have the double length issue.

@markstory
Copy link
Member

Closing as there is a pull request open now.

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