-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Labels
good first issueFor issues. An issue that is a good choice for first-time contributors.For issues. An issue that is a good choice for first-time contributors.type: featureDEPRECATED: replace with the "feature" issue typeDEPRECATED: replace with the "feature" issue type
Description
When I use raw queries (read use case below), I need to include database/schema name in the query. I noticed that I can retrieve it from sequelize.config.database, but this is not documented thus a rather dangerous approach I suppose. So I'm requesting if it is possible to expose the option as a function.
Of course, I know that I can just pass the string along from where the options are supplied, but I think it would be more convenient if we can retrieve it from the sequelize instance since we have it already?
Dialect: MySQL (I'm not sure if this is dialect specific)
My use case
Get current AUTO_INCREMENT value of a table from information_schema:
let databaseName// = ???
let tableName = sequelize.models.MyTable.name
let autoIncrementValue
sequelize.query(`
SELECT AUTO_INCREMENT
FROM information_schema.TABLES
WHERE
TABLE_SCHEMA = '${databaseName}'
AND TABLE_NAME = '${tableName}'
`, {
type: Sequelize.QueryTypes.SELECT
}).then(result => {
autoIncrementValue = result
})Metadata
Metadata
Assignees
Labels
good first issueFor issues. An issue that is a good choice for first-time contributors.For issues. An issue that is a good choice for first-time contributors.type: featureDEPRECATED: replace with the "feature" issue typeDEPRECATED: replace with the "feature" issue type