-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Foreign key reference a column in the same table causes error #11229
Comments
Can you please test this with another dialect? This is important to know whether the problem is dialect-specific or not. You can instantiate an in-memory SQLite instance very easily:
You can instantiate a local postgres instance very easily:
|
Hi, i have tested as suggested, here is the response. Test.associate = ({ Test }) => {
Test.hasMany(Test, { sourceKey:'userId2', targetKey: 'userId1', foreignKey: 'user_id_2' });
};
Test.associate = ({ Test }) => {
Test.hasMany(Test, { sourceKey:'userId1', targetKey: 'userId2', foreignKey: 'user_id_2' });
};
2. Postgres Test.associate = ({ Test }) => {
Test.hasMany(Test, { sourceKey:'userId2', targetKey: 'userId1', foreignKey: 'user_id_2' });
};
Test.associate = ({ Test }) => {
Test.hasMany(Test, { sourceKey:'userId1', targetKey: 'userId2', foreignKey: 'user_id_2' });
};
|
any update on this? |
I just add |
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
What are you doing?
To Reproduce
Steps to reproduce the behavior:
Run Test.sync()
What do you expect to happen?
What is actually happening?
Environment
Dialect:
Dialect library version: mysql2: "^1.6.5"
Database version: '10.1.13-MariaDB'
Sequelize version: 5.10.1
Node Version: 8.9.1
OS: windows
The text was updated successfully, but these errors were encountered: