fibjs / fib-orm

Object Relational Mapping for fibjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

incompactable to the master version of fibjs

richardo2016 opened this issue · comments

I found the code in repository is right after I wrote the issue, one fix had been in master branch but the code in npm(it's version 1.1.0) is too old, so please update the version of npm package, thx very much : )


after I upgrading to the v0.13.0, fib-orm can not work with the code in README's example. because the result retured by Database.execute is just one NArray type value, and old rs_convert function below is unnecessarry.

// old rs_convert
function rs_convert(r) {
    var r1 = r.toArray();
    r1.insertId = r.insertId;
    r1.affected = r.affected;
    for (var i = 0; i < r1.length; i++)
        r1[i] = r1[i].toJSON();

    return r1;
}

that would made script crashed when one sql executed, and throw one typeError:

TypeError: r.toArray is not a function

Also the toJSON is not one method of item object in r. so r1[i].toJSON() would make one error.

If you think code below is valid and fib-orm is just for the latest fibjs(v0.13.0), maybe you can just replace the old code above with it:

// 1: shorter code
function rs_convert(r) {
    var r1 = Array.prototype.slice(r, 0);
    r1.insertId = r.insertId;
    r1.affected = r.affected;

    return r1;
}

// 2: remove it, because it's unnecessary.