WebSQL:SQLResultSetRowList中返回的行是不可变的吗? [英] WebSQL: Are returned rows in SQLResultSetRowList immutable?

查看:966
本文介绍了WebSQL:SQLResultSetRowList中返回的行是不可变的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在从WebSQL数据库中获取行,并且返回的行似乎是只读的。

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));
                }
            );
        }
    );

打印:

    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.

更新2:不,它发生在我读到的每个表中。似乎是与Chrome相关的东西(也发生在Opera中,因此它可能是一个webkit行为)。

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).

推荐答案

根据 Web SQL Spec SQLResultSetRowList in SQLResultSet 接口是只读的。

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

这篇关于WebSQL:SQLResultSetRowList中返回的行是不可变的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆