Skip to Main Content

Programming Languages & Frameworks

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Node, Oracle, Sequelize

user545194Sep 18 2024 — edited Sep 18 2024

Env. Oracle 21C, Node v20, node-oracledb 6.6.0, Sequelize 6.37

I am developing a REST API with the above mentioned technologies. All good, except for one topic.

Apparently Sequelize creates the table and column names in lowercase with double quotes. Is there a way to make Sequelize create to uppercase without double quotes?

This post has been answered by Hasan Jamil-Oracle on Sep 19 2024
Jump to Answer

Comments

Hasan Jamil-Oracle Sep 19 2024
Answer

Hi ,

Below are the few things you can try to avoid getting the lowercase tables and column names.

For tables, you can use the option `tableName` in your model definition (refer https://sequelize.org/docs/v6/core-concepts/model-basics/#providing-the-table-name-directly):

sequelize.define(
  'User',
  {
	// ... (attributes)
  },
  {
	tableName: 'USERS',
  },
);

Please note that sequelize by default pluralizes the table name. Take care of that while you set tableName to avoid unnecessary issues.

Another way is to set the quoteIdentifiers options to false (refer: https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-constructor-constructor).

Please note that this feature is going to be removed in version 7 of Sequelize due to various vulnerabilities that comes with it. This is not recommended by Sequelize, but it can be done.

// Instantiate Sequelize with quoteIdentifiers as false
const sequelize = new Sequelize('<serviceName>', '<userName>', '<password>', {dialect: 'oracle', host: '<hostname>', quoteIdentifiers: false});

I would suggest to avoid doing this unless extremely necessary. Sequelize has lots of internal objects that map to tables, columns, etc. Doing this might create inconsistency and lead to failures.

Hope it helps :)

Marked as Answer by user545194 · Sep 20 2024
user545194 Sep 20 2024

Hi, @hasan-jamil-oracle

Thanks a lot for the information! Greatly appreciated. Option 1 is of course the preferred method. I'll go through the Sequelize docs to fully understand that part.

Cheers!

1 - 2

Post Details

Added on Sep 18 2024
2 comments
176 views