numtel / meteor-mysql

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

.change() method does not get new rows added after started meteor #23

Open VCarrasco opened 9 years ago

VCarrasco commented 9 years ago

If a game(new row) has been added to a player after started Meteor and I use .change(player_id) to get the current games for this player then I'm not getting the last row(the newest one).

numtel commented 9 years ago

Can you provide any example code?

sushitommy commented 9 years ago

I'm able to reproduce this. Here's the function:

liveDB = new LiveMysql(
{
// removed code
});

Meteor.publish('mData', function(id, filter)
{
    if (this.userId == null) return;
    if (typeof id == "undefined") return;

    this.onStop(function() 
    {
        if (liveDB.db.threadId != null)
        {
            liveDB.end();
        }
    }); 

    var query;
    if (filter.timespan == undefined)
    {
        query = "" // query 1
    } else {
        query = "" // query 2
    }

    var cursor = liveDB.select(query, [ { table: table } ]);
    return cursor; 
});

If I call 'change' on the mysql subscription and query 2 is used instead of query 1, the mysql subscription stays empty.