WebSQL: Are returned rows in SQLResultSetRowList immutable?

二次信任 提交于 2019-12-19 09:03:30

问题


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:


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



来源:https://stackoverflow.com/questions/19999906/websql-are-returned-rows-in-sqlresultsetrowlist-immutable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!