Skip to content
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
Closed
Assignees
Labels
web-libraries Issues impacting dart:html, etc., libraries
Milestone

Comments

@sethladd
Copy link
Contributor

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
Copy link
Contributor Author

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


Attachment:
javascript.js (921 Bytes)

@sethladd
Copy link
Contributor Author

@rakudrama
Copy link
Member

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
Copy link
Contributor Author

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
Copy link
Member

vsmenon commented Apr 13, 2012

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

@sigmundch
Copy link
Member

Added Isolates label.

@vsmenon
Copy link
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
Copy link
Contributor Author

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
Copy link
Member

Marked this as blocking #1310.

@iposva-google
Copy link
Contributor

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

@rakudrama
Copy link
Member

Issue #3669 has been merged into this issue.

@vsmenon
Copy link
Member

vsmenon commented Aug 23, 2012

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

@rakudrama
Copy link
Member

Fixed at r11331
html/indexeddb_2_test excerises this issue.


Added Fixed label.

@sethladd sethladd added Type-Defect web-libraries Issues impacting dart:html, etc., libraries labels Oct 3, 2012
@sethladd sethladd added this to the M1 milestone Oct 3, 2012
copybara-service bot pushed a commit that referenced this issue Jan 17, 2023
…, webdev

Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/c4ab682..a99abd4):
  a99abd4b  2023-01-16  dependabot[bot]  Bump dart-lang/setup-dart from 1.3 to 1.4 (#3305)
  a692eeaa  2023-01-16  dependabot[bot]  Bump github/codeql-action from 2.1.37 to 2.1.38 (#3304)
  a43a6c2b  2023-01-14  Parker Lougheed  Remove search code debug prints (#3300)
  cf28572a  2023-01-14  Parker Lougheed  Remove obsolete doc_packages tool (#3301)
  fcbadcd7  2023-01-14  Parker Lougheed  Remove null safety badge (#3295)
  263ea617  2023-01-14  Parker Lougheed  Use spread syntax instead of add (#3296)
  820b5ba5  2023-01-14  Parker Lougheed  Use equal signs to set default parameter values (#3298)
  31e9c797  2023-01-14  Parker Lougheed  Fix build by removing test opting out of null safety (#3297)
  d4495c2c  2023-01-11  dependabot[bot]  Bump actions/checkout from 3.2.0 to 3.3.0 (#3292)
  3ae8eef5  2023-01-11  dependabot[bot]  Bump actions/upload-artifact from 3.1.1 to 3.1.2 (#3291)
  8a9e4691  2023-01-11  dependabot[bot]  Bump actions/cache from 3.2.2 to 3.2.3 (#3290)

http (https://github.com/dart-lang/http/compare/d434d42..c955c7e):
  c955c7e  2023-01-13  Brian Quinlan  Add consistent implementations for `close`. (#851)

intl (https://github.com/dart-lang/intl/compare/c61fdd1..6140b60):
  6140b60  2023-01-12  Googler  Internal change

mime (https://github.com/dart-lang/mime/compare/273d454..034471a):
  034471a  2023-01-11  Kevin Moore  Prepare to release v1.0.4 (#80)

string_scanner (https://github.com/dart-lang/string_scanner/compare/c58618d..0454980):
  0454980  2023-01-17  Kevin Moore  dependabot: monthly is plenty (#54)

sync_http (https://github.com/dart-lang/sync_http/compare/8622614..36a1bd0):
  36a1bd0  2023-01-11  Kevin Moore  Bump min SDK, enable and fix new lints (#34)

test (https://github.com/dart-lang/test/compare/932a652..43fd928):
  43fd9284  2023-01-17  Jacob MacDonald  delete some old integration test helper files that were opted out (#1850)
  2c59fb6c  2023-01-17  Kevin Moore  Run no response daily (#1849)
  8ea50552  2023-01-12  joshualitt  Update wasm integration test to use generated JS runtime for Dart2Wasm. (#1844)
  9a23b72a  2023-01-11  Nate Bosch  Prepare to publish (#1843)
  d887825a  2023-01-11  Derek Xu  Update vm_service constraints to >=6.0.0 <11.0.0 (#1842)

webdev (https://github.com/dart-lang/webdev/compare/094ee97..f978b90):
  f978b90  2023-01-13  Elliott Brooks (she/her)  [MV3] Debug session persists across closing and opening Chrome DevTools (#1894)
  b1b4eff  2023-01-13  Anna Gringauze  Prepare for dart 3.0 alpha changes: generate assets (#1887)
  969f41f  2023-01-13  Elliott Brooks (she/her)  Save encoded URI for ACX DevTools (#1890)
  8384a11  2023-01-13  Elliott Brooks (she/her)  Skip flaky test on windows (#1893)
  8224045  2023-01-13  Elliott Brooks (she/her)  Ignore `illegal_language_version_override` for non null-safe fixtures (#1891)
  e42a030  2023-01-13  Elliott Brooks (she/her)  Re-enable most test cases in `devtools_test` (#1881)
  e134e5b  2023-01-11  Elliott Brooks (she/her)  [MV3] Dart debug extension supports DWDS versions < `17.0.0` (#1882)
  ed80c94  2023-01-11  Elliott Brooks (she/her)  [MV3] Prepare extension for release (#1886)
  be616cd  2023-01-10  Anna Gringauze  Return error from expression evaluation if the evaluator is closed. (#1884)
  18b3277  2023-01-10  Elliott Brooks (she/her)  [MV3] Fix late initialization error on debugger detach (#1879)
  03d4035  2023-01-10  Elliott Brooks (she/her)  Check if storage object exists before trying to read properties(#1883)
  ae55fec  2023-01-10  Elliott Brooks (she/her)  Format manifest.json (#1885)
  3743293  2023-01-10  Anna Gringauze  Fix race condition on simultaneous hot restarts (#1870)

Change-Id: I2bddd015f1e054eb9e24afb247f9c470257560a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279073
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

5 participants