I am trying to sync a Sequelize model with my database, but I can't get over this error.
Using Sequelize as my ORM, database is Oracle express:21.3.0-xe
This is the error:
Executing (default): DECLARE CONS_NAME VARCHAR2(200); BEGIN BEGIN EXECUTE IMMEDIATE 'ALTER TABLE "ENROLLMENT_REQUESTS" MODIFY "PDF" BLOB NOT NULL'; EXCEPTION WHEN OTHERS THEN IF SQLCODE = -1442 OR SQLCODE = -1451 THEN EXECUTE IMMEDIATE 'ALTER TABLE "ENROLLMENT_REQUESTS" MODIFY "PDF" BLOB '; ELSE RAISE; END IF; END; END;
Error synchronizing models: DatabaseError [SequelizeDatabaseError]:
ORA-22296: invalid ALTER TABLE option for conversion of LONG datatype to LOB
ORA-06512: at line 1
ORA-06512: at line 1
The column in the Sequelize model is defined like this:
pdfDocument: {
type: DataTypes.BLOB,
allowNull: false,
field: 'PDF'
}
The column in my database is defined like this:
- Column name:
PDF
- Data type:
BLOB
- Nullable: No
In my Sequelize instance I am using (it's a dev environment - so I'm not using migrations):
const syncDB = async () => {
try {
await sequelize.sync({alter: true});
console.log("All models were synchronized successfully.");
} catch (error) {
console.error("Error synchronizing models:", error);
}
};
I am not able to understand why it is trying to transform LONG into LOB. Where is the LONG data type coming from? And why LOB and not directly BLOB, as I defined the column as BLOB in both DB and Sequelize?
Any advice would be much kindly appreciated :))) Thank you!
I am trying to sync a Sequelize model with my database, but I can't get over this error.
Using Sequelize as my ORM, database is Oracle express:21.3.0-xe
This is the error:
Executing (default): DECLARE CONS_NAME VARCHAR2(200); BEGIN BEGIN EXECUTE IMMEDIATE 'ALTER TABLE "ENROLLMENT_REQUESTS" MODIFY "PDF" BLOB NOT NULL'; EXCEPTION WHEN OTHERS THEN IF SQLCODE = -1442 OR SQLCODE = -1451 THEN EXECUTE IMMEDIATE 'ALTER TABLE "ENROLLMENT_REQUESTS" MODIFY "PDF" BLOB '; ELSE RAISE; END IF; END; END;
Error synchronizing models: DatabaseError [SequelizeDatabaseError]:
ORA-22296: invalid ALTER TABLE option for conversion of LONG datatype to LOB
ORA-06512: at line 1
ORA-06512: at line 1
The column in the Sequelize model is defined like this:
pdfDocument: {
type: DataTypes.BLOB,
allowNull: false,
field: 'PDF'
}
The column in my database is defined like this:
- Column name:
PDF
- Data type:
BLOB
- Nullable: No
In my Sequelize instance I am using (it's a dev environment - so I'm not using migrations):
const syncDB = async () => {
try {
await sequelize.sync({alter: true});
console.log("All models were synchronized successfully.");
} catch (error) {
console.error("Error synchronizing models:", error);
}
};
I am not able to understand why it is trying to transform LONG into LOB. Where is the LONG data type coming from? And why LOB and not directly BLOB, as I defined the column as BLOB in both DB and Sequelize?
Any advice would be much kindly appreciated :))) Thank you!
Share edited Feb 10 at 12:14 marc_s 755k184 gold badges1.4k silver badges1.5k bronze badges asked Feb 10 at 11:41 DianaDiana 11 silver badge1 bronze badge1 Answer
Reset to default 1Oracle Database tries an implicit conversion of datatypes if it's mentioned in ALTER TABLE <table_name> MODIFY ...
which can be a problem with BLOBs
.
Please see: this PR
If you are in your dev environment and testing something, you can use sequelize.sync({force: true})
if you are working with EMPTY TABLE.
Once the PR is merged, you can update Sequelize to new version with the commits included and work with your app.
P.S. you can also patch your seqeulize module with changes done in PR and use {alter: true}