-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Labels
dialect: sqliteFor issues and PRs. Things that involve SQLite (and do not involve all dialects).For issues and PRs. Things that involve SQLite (and do not involve all dialects).type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type
Description
What are you doing?
Similarly to #5769 , I have two models with a one to one relation:
- The
Filemodel, that hold the data of the file (weight, ...) - The
Imagemodel that hold image-specific data (height, width, ...)
Image.id should be the primary key of Image AND a foreign key to file.id, so I tried this:
const File = sequelize.define('file', {});
const Image = sequelize.define('image', {
id: {
primaryKey: true,
type: Sequelize.INTEGER,
references: {
model: File,
key: "id",
}
}
});(the same things happen if I use belongsTo instead of referencing the File model in the define method)
What do you expect to happen?
I want the Image.id field to reference the File.id field.
It work if I do it on an other field (not the primary key), and that produce SQL like:
`file_id` INTEGER REFERENCES `files` (`id`) ON DELETE SET NULL ON UPDATE CASCADEWhat is actually happening?
The file.id field is not referenced, and the produced SQL is like:
`id` INTEGER PRIMARY KEYDialect: sqlite3
Dialect version: 4.0.0
Sequelize version: 4.37.8
Tested with latest release: No
Metadata
Metadata
Assignees
Labels
dialect: sqliteFor issues and PRs. Things that involve SQLite (and do not involve all dialects).For issues and PRs. Things that involve SQLite (and do not involve all dialects).type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type