Directus schema apply can't handle varchar(max)

Datbase mssql
Directus Version: 11.13.2
Directus cannot handle nvarchar(-1) which should be nvarchar(max) instead;
Expected behaviour is to apply schema with a column that is nvarchar max

ALTER TABLE [tbl_ordernotes] ALTER COLUMN [ordernote_value] nvarchar(-1) null - Incorrect syntax near ')'.

schema.yaml

...
    schema:
      name: ordernote_value
      table: tbl_ordernotes
      data_type: varchar
      default_value: null
      max_length: -1
      numeric_precision: null
      numeric_scale: null
      is_nullable: true
      is_unique: false
      is_indexed: false
      is_primary_key: false
      is_generated: false
      generation_expression: null
      has_auto_increment: false
      foreign_key_table: null
      foreign_key_column: null
...

i tried changing it max_length: "MAX", defaults to nvarchar(255) which is not what i want.

https://github.com/directus/directus/blob/main/packages/schema/src/dialects/mssql.ts line 67: if (['nvarchar', 'nchar', 'ntext'].includes(rawColumn.data_type)) { // If the DB says the length is -1 (which MSSQL does for MAX), // Directus explicitly returns -1 here. return max_length === -1 ? max_length : max_length / 2; }

created am issue here. I think updating the code on the apply is the play here : https://github.com/directus/directus/issues/26235

1 Answer

1

Lets continue this conversation over on Directus schema apply can't handle varchar(max) :slight_smile: I’ll mark it as resolved here so we don’t end up crossing our streams here