WebSQL: Are returned rows in SQLResultSetRowList i

2019-02-17 23:34发布

I've been fetching rows from a WebSQL DB, and the returned rows seems to be readonly.

    db.readTransaction(
        function(t1) {              
            t1.executeSql(
                "SELECT * FROM Foo WHERE id = ?",
                [1],
                function(t2, resultSet){
                    var foo = resultSet.rows.item(0);

                    console.log("before: " + foo.col1);
                    foo.col1 = "new value";
                    console.log("after: " + foo.col1);
                    console.log("sealed? " + Object.isSealed(foo));
                    console.log("frozen? " + Object.isFrozen(foo));
                }
            );
        }
    );

It prints:

    before: old value
    after: old value
    sealed? false
    frozen? false

I had to manually clone the row to be able to modify it.

How is this possible? How can an object be made immutable without being frozen or sealed? And where in the specs says it should be like that?


UPDATE: It's funny. It only happens in some tables. Still clueless about it.


UPDATE 2: Nope, it happens in every table I read from. Seems to be something related to Chrome (Also happens in Opera, so it might be a webkit behavior).

1条回答
成全新的幸福
2楼-- · 2019-02-17 23:45

According to the Web SQL Spec SQLResultSetRowList in SQLResultSet Interface is readonly.

查看更多
登录 后发表回答