numtel / meteor-mysql

Reactive MySQL for Meteor
MIT License
343 stars 41 forks source link

Reactivity issue when having join in select query #42

Closed anilkhichar closed 9 years ago

anilkhichar commented 9 years ago

Following query is giving the correct data at meteor startup but once either 'questions ', or 'milestones' table data is updated by other user, reactivity is lost.

Meteor.publish('questionDelivery', function(id) {
  return liveDb.select('SELECT q.title, m.milestone_name as "milestone" FROM questions q left join milestones m on q.milestone_id = m.milestone_id', [
    {
      table: ['questions', 'milestones']
    }
  ]);
});

Actually the problem is with the table object:

table: ['questions', 'milestones']

And this is the patch for this problem.

Meteor.publish('questionDelivery', function(id) {
  return liveDb.select('SELECT q.title, m.milestone_name as "milestone" FROM questions q left join milestones m on q.milestone_id = m.milestone_id', [
    {
      table: 'questions',
    },
    {
      table: 'milestones',
    },
  ]);
});
numtel commented 9 years ago

What is the question? The first way you listed is not supported. The second way is as expected.

anil-kumar-ma commented 9 years ago

Thanks numtel for reply,

The first way is also working and giving the correct data on first time load but once data gets updated in any of the joined table, latest data is not being updated in the subscribed collection.

At the first glance I thought table is an array of tables and which started giving me results but later found issue with the re-activity.

I would suggest, make the 'table' key to accept only string while blocking arrays.