Skip to content

Mssql type TEXT with length #237

Closed
Closed
@leo-schick

Description

@leo-schick

I have the following MSSQL table:

CREATE TABLE LiquidityPlanning.Parameters
(
	Id int IDENTITY(1,1) NOT NULL,
	Name nvarchar(80) NOT NULL,
	Description text NULL,
	Value int NULL,
	DefaultValue int NULL
);

This generates the following file:

from sqlalchemy import Column, Identity, Integer, MetaData, TEXT, Table, Unicode

metadata = MetaData()


t_Parameters = Table(
    'Parameters', metadata,
    Column('Id', Integer, Identity(start=1, increment=1), nullable=False),
    Column('Name', Unicode(80), nullable=False),
    Column('Description', TEXT(2147483647, 'SQL_Latin1_General_CP1_CI_AS')),
    Column('Value', Integer),
    Column('DefaultValue', Integer),
    schema='LiquidityPlanning'
)

The length of the TEXT type is not necessary. Length 2147483647 is the max length of a 4 byte integer. I my opinion, the max length should not be put into the SQLAlchemy model in this case.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions