balderdashy / balderdashy/sails
MongoDB adapter doesn't recognise FKs to mysql table correctly
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**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 via `user: { model: 'User', required: true }` and `User` is in mysql database. I then want to create a `Client` and supply `{user: 1}` the adapter throws
`Error: Invalid replacement foreign key value provided for association (`user`). Cannot interpret `1` as a Mongo id.`
REPO: git@bitbucket.org:mp3por/sails-bug-2.git
Please advice :)
Contributor guide
Research direction
Start by reproducing the Client-to-User association described in the issue with sails-mongo@1.0.0 and a MySQL User model, using the linked reproduction repository. Trace the adapter's foreign-key replacement handling when creating Client with {user: 1}. Done means the MongoDB adapter recognises the MySQL foreign key and creates the Client without the Mongo id error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, mysql, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100