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

NVARCHAR(MAX) length for portableTableColumnDefiniton should not be divided #6038

Open
MaximilianSpeer opened this issue May 15, 2023 · 0 comments

Comments

@MaximilianSpeer
Copy link

Bug Report

When introspecting a schema from an SqlServer database a nvarchar(max) a TypeError is raised.
Apparently this happens because the length of an nvarchar is divided by two in the SQLServerSchemaManager::getPortableTableColunmnDefinition. As the MAX length is read as -1 this leads to a float length (-0.5).

This can be simply reproduced by introspecting a SqlServer database schema containing a nvarchar(max) column.

derrabus pushed a commit that referenced this issue Jan 20, 2024
<!-- Fill in the relevant information below to help triage your pull
request. -->

|      Q       |   A
|------------- | -----------
| Type         | bug
| Fixed issues | #6038

#### Summary

As described in the mentioned issue, `-0.5` from `-1 / 2` will raise
type error when trying to `setLength`

```
Argument #1 ($length) must be of type ?int, float given
```

https://github.com/doctrine/dbal/blob/8bc0d9ae42f20af54120396ef7a1b3248479c2b5/src/Schema/Column.php#L78

This PR check if length is `-1` and keep it as is before perform
division.
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