Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top