-
Notifications
You must be signed in to change notification settings - Fork 2k
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
MongoDB adapter doesn't recognise FKs to mysql table correctly #4367
Comments
@mp3por Thanks for posting, we'll take a look as soon as possible. For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here. |
This also doesn't work if the I managed to hack it for |
@mp3por thanks for the heads up- I think I see why this is happening Will look into it ASAP. Your workaround makes sense in the mean time (of course it means you won't be able to rely on .populate()) |
Here's the code in sails-mongo that's specifically wrong: @mp3por Also in the mean time, if you have a moment to take a pass at a PR, I'd be happy to review and hopefully merge. I think what we need there is to add another disjunct checking if the foreign key is pointed at another model powered by the current sails-mongo adapter, and if so, skip the check. Please just comment here with that PR if you get to it (Also, you'll notice in that code that there's another workaround hack you could use involving |
Another possible workaround without changing the Model Structure (NOT a fix):Setting In the example in OP, set this for Bonus: |
@maheshwarishivam 👍 thanks for the follow-up! @streleck this is related to the other issue we were talking about this morning. |
@maheshwarishivam I'm using
|
@ghost - The referenced issue was closed because for being relatively duplicate of this one -however it has a lot of useful info so it's definitely worth checking out. @maheshwarishivam Thanks for the workaround! |
Sails version: sails@1.0.1
Node version: 8.9.4
NPM version: 5.6.0
DB adapter name: sails-mongo
DB adapter version: sails-mongo@1.0.0
Operating system: macOS 10.13.3
Hello,
I have a reference from my mongo model (
Client
) to a mysql model viauser: { model: 'User', required: true }
andUser
is in mysql database. I then want to create aClient
and supply{user: 1}
the adapter throwsError: Invalid replacement foreign key value provided for association (
user). Cannot interpret
1as a Mongo id.
REPO: git@bitbucket.org:mp3por/sails-bug-2.git
Please advice :)
The text was updated successfully, but these errors were encountered: