sequelize/sequelize · error · Error
${this._getDialect().name} does not support the BINARY optio
Error message
${this._getDialect().name} does not support the BINARY option for data types with a length greater than 4000. What it means
Thrown by the IBMi STRING data-type override's toSql when the binary option is set and the declared length exceeds 4000. IBMi/Db2 maps STRING+binary to VARCHAR(n) FOR BIT DATA, which has a hard 4000-byte ceiling; longer binary strings must use BLOB.
Source
Thrown at packages/ibmi/src/_internal/data-types-overrides.ts:58
}
return `BLOB(${this.options.length})`;
}
return 'BLOB(1M)';
}
}
export class STRING extends BaseTypes.STRING {
toSql() {
const length = this.options.length ?? 255;
if (this.options.binary) {
if (length <= 4000) {
return `VARCHAR(${length}) FOR BIT DATA`;
}
throw new Error(
`${this._getDialect().name} does not support the BINARY option for data types with a length greater than 4000.`,
);
}
if (length <= 4000) {
return `VARCHAR(${length})`;
}
return `CLOB(${length})`;
}
}
export class CHAR extends BaseTypes.CHAR {
toSql() {
if (this.options.binary) {
return `CHAR(${this.options.length ?? 255}) FOR BIT DATA`;
}
View on GitHub (pinned to 7e1deec499)
Solutions
- Reduce the length to <= 4000 for the binary string column.
- Switch the column to DataTypes.BLOB for binary payloads larger than 4000 bytes.
- Split the data or store a reference/identifier instead of a long binary blob.
Example fix
// before
DataTypes.STRING({ length: 8000, binary: true })
// after
DataTypes.BLOB Defensive patterns
Strategy: validation
Validate before calling
if (attr.binary && typeof attr.length === 'number' && attr.length > 4000) {
throw new Error('IBMi STRING binary length cannot exceed 4000; use BLOB');
} Type guard
function isValidIbmiBinaryString(attr) {
return !attr.binary || attr.length == null || attr.length <= 4000;
} Prevention
- Cap binary STRING length at 4000 on IBMi.
- Use BLOB for larger binary payloads.
- Review model definitions when porting from other dialects.
When it happens
Trigger: Defining a model attribute as DataTypes.STRING({ length: 8000, binary: true }) (or STRING.BINARY with length>4000) and triggering DDL generation (sync/autoMigrate).
Common situations: Porting a model from MySQL/Postgres with a long binary string column, or assuming STRING.BINARY scales to any length.
Related errors
- ${dialect.name} does not support unconstrained DECIMAL types
- RANGE has not been implemented in this dialect.
- ENUM has not been implemented in the ${this._getDialect().na
- LENGTH value ${this.options.length} is not supported. Expect
- Moving tables between schemas is not supported by ${this.dia
AI-assisted analysis of sequelize/sequelize@7e1deec499 (2026-08-03).
Data as JSON: /data/errors/f5fa4590ee330fc5.json.
Report an issue: GitHub.