Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Adding support for multiple tables with same name across different databases #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dasilva333
Copy link

Also as part of the change this need to be included as well:
dasilva333/sails-mysql@ae67aed

@tjwebb
Copy link
Contributor

tjwebb commented Mar 17, 2015

Can you document how this feature would work?

@dasilva333
Copy link
Author

It seems there is an issue with waterline/sails-mysql/waterline-sequel to reproduce the problem try the following steps:

  1. create a database called 'cats' in mysql
  2. create another database called 'dogs' in mysql
  3. create a table called owners in both databases.
  4. Attempt to load those two models
  5. Verify it does not work with and without the identity property on the model

The solution I came up with might not be the ideal solution because it required me to assign an identity property to every model before I load it like this:

modelObject.identity = modelObject.connection.toLowerCase()+"_"+modelObject.tableName.toLowerCase();

and then later to:

orm.loadCollection(Waterline.Collection.extend(modelObject));

Basically I'm submitting my solution but also suggesting someone else look further into this simple and reproducible problem with the code.

@dasilva333
Copy link
Author

Also of note this ticket was also reported elsewhere on the parent project:
https://github.com/balderdashy/sails-mysql/issues/171

@kai23
Copy link

kai23 commented Apr 8, 2015

As reported on the parent project, adding an identity « works » great, but fail on populate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants