balderdashy / balderdashy/sails

MongoDB adapter doesn't recognise FKs to mysql table correctly

Open
#4,367 8 comments 0 reactions 0 assignees View on GitHub
bug helpful info or workaround
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.