Generated entity with MAX length are translated by 0 #5233

Open
opened 2026-01-22 15:02:10 +01:00 by admin · 3 comments
Owner

Originally created by @ajira86 on GitHub (Aug 25, 2016).

Hello,

In the context of a large project, I generated multiple entities from a MS SQL database.
I notice that all fields nvarchar(MAX) were translated in annotation attribute length=0 like this:

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=0, nullable=true)
     */
    protected $name;

Shouldn't be better to remove the length limit in this case ?

Originally created by @ajira86 on GitHub (Aug 25, 2016). Hello, In the context of a large project, I generated multiple entities from a MS SQL database. I notice that all fields nvarchar(MAX) were translated in annotation attribute length=0 like this: ``` /** * @var string * * @ORM\Column(name="name", type="string", length=0, nullable=true) */ protected $name; ``` Shouldn't be better to remove the length limit in this case ?
admin added the BugMissing Tests labels 2026-01-22 15:02:10 +01:00
Author
Owner

@Ocramius commented on GitHub (Aug 25, 2016):

@ajira86 a removed length would result in a length=255 by default. Also, seems like a schema introspection issue. Can this be isolated into the DBAL code that causes it, and then reported there in more detail?

@Ocramius commented on GitHub (Aug 25, 2016): @ajira86 a removed length would result in a `length=255` by default. Also, seems like a schema introspection issue. Can this be isolated into the DBAL code that causes it, and then reported there in more detail?
Author
Owner

@ajira86 commented on GitHub (Aug 29, 2016):

Thank you for your reply, I was not excepting this default value.

Can this be isolated into the DBAL code that causes it, and then reported there in more detail?

How can I get this kind of report ?

FYI: I'm using Symfony and the module leaseweb/doctrine-pdo-dblib as DBAL driver for the use of FreeTDS

@ajira86 commented on GitHub (Aug 29, 2016): Thank you for your reply, I was not excepting this default value. > Can this be isolated into the DBAL code that causes it, and then reported there in more detail? How can I get this kind of report ? FYI: I'm using Symfony and the module leaseweb/doctrine-pdo-dblib as DBAL driver for the use of FreeTDS
Author
Owner

@Ocramius commented on GitHub (Aug 29, 2016):

@ajira86 you'd need to debug it and figure out what the DatabaseDriver does, then figure out if the MAX is cast to 0 by the DBAL or by the driver itself.

@Ocramius commented on GitHub (Aug 29, 2016): @ajira86 you'd need to debug it and figure out what the [`DatabaseDriver`](https://github.com/doctrine/doctrine2/blob/31a0c02b066764ec7b55eedc5f3cab78235a4e4b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php) does, then figure out if the `MAX` is cast to `0` by the DBAL or by the driver itself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5233