New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart:dom indexeddb unable to retrieve correctly formed object from database #1883

Closed
sethladd opened this Issue Feb 28, 2012 · 13 comments

Comments

Projects
None yet
5 participants
@sethladd
Member

sethladd commented Feb 28, 2012

I can save an object into the database, but I can't retrieve the same object from the database.

For example,

I can save this:

{'x': ['foo', {'bar':2}]}

which gets translated to JavaScript like this:

_map(["x", ["foo", _map(["bar", (2)])]])

and when I retrieve that object from the DB, it looks like this:

Object
_list: Object
_map: Object
  _keys: Array[6]
    5: "x"
  length: 6
  proto: Array[0]
  _loadLimit: 6
  _numberOfDeleted: 0
  _numberOfEntries: 1
  _values: Array[6]
  proto: Object
  proto: Object

but instead it should look something more like this:

Object
  x: Array[2]
    0: "foo"
    1: Object
      bar: 2
    proto: Object
    length: 2
  proto: Array[0]
  proto: Object

I should be able to do this on retrieved object:

obj['x'][1].bar

I'll attach working JavaScript code.

@sethladd

This comment has been minimized.

Member

sethladd commented Feb 28, 2012

Attaching working raw, native JavaScript code. The results of this code should also work in Dart.


Attachment:
javascript.js (921 Bytes)

@sethladd

This comment has been minimized.

@rakudrama

This comment has been minimized.

Member

rakudrama commented Feb 29, 2012

The put operation stores a 'structured clone' http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#structured-clone of the object.
This copies the JavaScript object graph - the same rules as used for postMessage.

The Dart Map<> object is not a direct JavaScript Object. What you see is the structured clone of the Dart Map implementation.
There is code in the isolates library to serialize/deserialize objects but it appears to be bound to the isolate code.

Q1. Is it a requirement that a value written to the database in JavaScript is readable in Dart and vice-versa?

Q2. What is the minimum set of types required to unblock the customer?


cc @sigmundch.
cc @floitschG.

@sethladd

This comment has been minimized.

Member

sethladd commented Feb 29, 2012

Good point, sorry about that. I should be able to do obj['x'][1]['bar']

Regardless, I can't even do obj['x'] on the retrieved object. The code errors with:

Uncaught NoSuchMethodException : method not found: 'operator []'
Receiver: [object Object]
Arguments: [x]

when I try this: pring("Value is $v and ${v['x']}!");

@vsmenon

This comment has been minimized.

Member

vsmenon commented Apr 13, 2012

Removed Area-UI label.
Added Area-DOM label.

@sigmundch

This comment has been minimized.

Member

sigmundch commented May 14, 2012

Added Isolates label.

@vsmenon

This comment has been minimized.

Member

vsmenon commented Jun 22, 2012

Lowering priority. You can get the same functionality via serializing to JSON and storing as a string for now.


Added this to the Later milestone.
Removed Priority-High label.
Added Priority-Medium label.

@sethladd

This comment has been minimized.

Member

sethladd commented Jun 22, 2012

I disagree that this workaround is sufficient. The issue with using a JSON string is that you can't use IndexedDB's nice indexes on object properties.


Removed Isolates label.

@rakudrama

This comment has been minimized.

Member

rakudrama commented Jun 22, 2012

Marked this as blocking #1310.

@iposva-google

This comment has been minimized.

Contributor

iposva-google commented Aug 13, 2012

Removed Area-DOM label.
Added Area-HTML label.

@rakudrama

This comment has been minimized.

Member

rakudrama commented Aug 17, 2012

Issue #3669 has been merged into this issue.

@vsmenon

This comment has been minimized.

Member

vsmenon commented Aug 23, 2012

Removed this from the Later milestone.
Added this to the M1 milestone.

@rakudrama

This comment has been minimized.

Member

rakudrama commented Oct 3, 2012

Fixed at r11331
html/indexeddb_2_test excerises this issue.


Added Fixed label.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment