Remove double quotes from a Table Name using SEQUELIZE Nodejs

Yatish Bathla

I have created an Account table in the PostgreSQL database using SEQUELIZE in Nodejs. I have used npx commands to create the tables.

$ npx sequelize db:create
$ npx sequelize db:migrate

By default, the table is created with double-quotes. For example, If I want to check the entries in the Account table, the sql command is as follows:

SELECT * FROM "Account";

I want to remove the double-quotes from the table name i.e.

SELECT * FROM Account;

In Sequelize Manual, I have found an option (options.quoteIdentifiers) which states that "Set to false to make table names and attributes case-insensitive on Postgres and skip double quoting of them."

When I applied this option in my code, still the Account table is created with double-quotes. I am not sure whether I commit any mistake. Please check my code below. Thanks in advance.

var sequelize = new Sequelize(dbConfig.DB, dbConfig.USER, dbConfig.PASSWORD,
  options.quoteIdentifiers = false, 
  {
  host: dbConfig.HOST,
  dialect: dbConfig.dialect,
  pool: {
    max: dbConfig.pool.max,
    min: dbConfig.pool.min,
    acquire: dbConfig.pool.acquire,
    idle: dbConfig.pool.idle
  }
},
);
module.exports = (sequelize, DataTypes) => {
  const Account = sequelize.define('Account', {
    epprojectname: DataTypes.STRING,
    username: DataTypes.STRING,
    projectid: DataTypes.STRING,
    vendorparameters: DataTypes.STRING,
    credentials: DataTypes.STRING,
    author: DataTypes.STRING,
    localnumber: DataTypes.STRING,
    loginid: DataTypes.INTEGER,
  }, {
    freezeTableName: true,
  },
  );
Manesh

You have used "=" instead of ":". You can replace the equal sign with colon and try again

const sequelize = new Sequelize(dbConfig.DB, dbConfig.USER, dbConfig.PASSWORD, {
  host: dbConfig.HOST,
  dialect: dbConfig.dialect,
  operatorsAliases: false,
  quoteIdentifiers: false,
  freezeTableName: true,
  pool: {
    max: dbConfig.pool.max,
    min: dbConfig.pool.min,
    acquire: dbConfig.pool.acquire,
    idle: dbConfig.pool.idle
  }
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to remove double quotes from Sequelize query?

Remove 'included' Table Name from response - Sequelize

sequalize.js - How to remove double quotes from sequelize generated query

remove double quotes using a macro

remove double quotes from field

Remove double quotes from dictionary

remove double quotes from json string using sed

remove double quotes from csv while using open csv

How to remove double quotes from a pyspark dataframe column using regex

Cannot remove double quotes from a list element using python

Remove double quotes from text inside JSON using Python and Regex

How to remove the double quotes of the column name in JSON?

Remove quotes from column name

How to remove double quotes from file but not inside the double quotes

How to remove double quotes from column name while saving dataframe in csv in spark?

Using regex in python to remove double quotes with exclusions

Remove double quotes enclosing numbers using regex

Remove double quotes from the return of a function in PostgreSQL

remove double quotes from first element of the list

remove escaped double quotes from string golang

Remove double quotes from path variable in PowerShell

JSON string from Gson: remove double quotes

Remove double quotes from JSON String

Remove Double Quotes from JSON Property

Remove double quotes from function body

To remove double quotes from date string in SQL

Remove double quotes from JSON string value

How to remove double quotes from a csv file

Remove double quotes from json object in Postgres