W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

Re: [Bug 15434] New: [IndexedDB] Detail steps for assigning a key to a value

From: Jonas Sicking <jonas@sicking.cc>
Date: Tue, 24 Jan 2012 17:39:44 -0800
Message-ID: <CA+c2ei-KVc+5k1zUsxFaDfe_0fu1mNNuvqg+Bzx=gigOrxbSpw@mail.gmail.com>
To: Joshua Bell <jsbell@chromium.org>
Cc: public-webapps@w3.org
On Tue, Jan 24, 2012 at 5:28 PM, Joshua Bell <jsbell@chromium.org> wrote:
>
>
> On Tue, Jan 24, 2012 at 5:15 PM, Jonas Sicking <jonas@sicking.cc> wrote:
>>
>> On Tue, Jan 24, 2012 at 4:23 PM, Joshua Bell <jsbell@chromium.org> wrote:
>> >
>> >
>> > On Tue, Jan 24, 2012 at 4:16 PM, Israel Hilerio <israelh@microsoft.com>
>> > wrote:
>> >>
>> >> On Tuesday, January 24, 2012 11:38 AM, Jonas Sicking wrote:>
>> >> > Based on this (pending details from microsoft of course) I suggest
>> >> > the
>> >> > following set of steps:
>> >> >
>> >> > 1. If /keyPath/ is the empty string, skip the remaining steps and
>> >> > /value/ is not
>> >> > modified.
>> >> > 2. Let /remainingKeypath/ be /keyPath/ and /object/ be /value/.
>> >> > 3. if /object/ is not an Object object or an Array object (see
>> >> > structured clone
>> >> > algorithm), then throw a DOMException of type DataError.
>> >> > 4. If /remainingKeypath/ has a period in it, assign
>> >> > /remainingKeypath/
>> >> > to be
>> >> > everything after the first period and assign /attribute/ to be
>> >> > everything
>> >> > before that first period. Otherwise, go to step 8.
>> >> > 5. If /object/ does not have an attribute named /attribute/, then
>> >> > create
>> >> > the
>> >> > attribute and assign it an empty object.
>> >> > 6. Assign /object/ to be the value of the attribute named /attribute/
>> >> > on
>> >> > /object/.
>> >> > 7. Go to step 3.
>> >> > 8. NOTE: The steps leading here ensure that /remainingKeyPath/ is a
>> >> > single
>> >> > attribute name (i.e. string without periods) by this step. They also
>> >> > ensure
>> >> > that /object/ is an Object or an Array, and not a Date, RegExp, Blob
>> >> > etc.
>> >> > 9. Let /attribute/ be /remainingKeyPath/ 10. Set an attribute named
>> >> > /attribute/ on /object/ with the value /key/.
>> >> >
>> >> > Note that the intent is that these steps are only executed if
>> >> > evaluating
>> >> > the
>> >> > keyPath did not yield a value. I.e. if we know that we need to modify
>> >> > the
>> >> > stored value. Because of this we know that at step
>> >> > 10 the object does not have an attribute with name /attribute/.
>> >> >
>> >> > Let me know if these steps sound ok?
>> >> >
>> >> > / Jonas
>> >> >
>> >>
>> >> The steps look good to me.
>> >>
>> >> Israel
>> >>
>> >
>> > Ditto.
>>
>> Sweet! Though as I was copying these steps into the bug I realized
>> that step 1 is superfluous as I already pointed out earlier in this
>> thread (this is disregarding what we decide regarding empty-string as
>> valid keyPaths for objectStores and/or indexes).
>>
>> I hope it was ok that I removed that step as I copied the steps into the
>> bug.
>
>
> If we decide to keep empty-string as a valid keyPath, it would not hurt to
> leave an informative note at the start of the section describing this
> algorithm pointing out that keyPath is guaranteed not be empty based on the
> preconditions for autoIncrement.

Good point. We should also point out that step 9 will never result in
a property being overwritten.

/ Jonas
Received on Wednesday, 25 January 2012 01:40:43 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:50 GMT