<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>11270</bug_id>
          
          <creation_ts>2010-11-09 01:07:16 +0000</creation_ts>
          <short_desc>Interaction between in-line keys and key generators</short_desc>
          <delta_ts>2015-04-09 21:51:36 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>Indexed Database API</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jonas Sicking (Not reading bugmail)">jonas</reporter>
          <assigned_to name="This bug has no owner yet - up for the taking">dave.null</assigned_to>
          <cc>eliotgra</cc>
    
    <cc>jorlow</cc>
    
    <cc>mike</cc>
    
    <cc>pablo.castro</cc>
    
    <cc>public-webapps</cc>
    
    <cc>timm</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>42298</commentid>
    <comment_count>0</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2010-11-09 01:07:16 +0000</bug_when>
    <thetext>This is related to, and affected by, bug 9832 and bug 11269.

When adding a value to an object store which uses in-line keys and key generators keypaths are used to point out where a value should be *modified*. A key is generated and written to the stored value, and the location in the stored value is determined using the object store&apos;s keypath.

So what happens if trying save in an object store which has the following keypath, the following value. (The generated key is 4):

&quot;foo.bar&quot;
{ foo: {} }

Here the resulting object is clearly { foo: { bar: 4 } }

But what about

&quot;foo.bar&quot;
{ foo: { bar: 10 } }

Does this use the value 10 rather than generate a new key, does it throw an exception or does it store the value { foo: { bar: 4 } }?

What happens if the property is missing several parents, such as

&quot;foo.bar.baz&quot;
{ zip: {} }

Does this throw or does it store { zip: {}, foo: { bar: { baz: 4 } } }


If we end up allowing array indexes in key paths (like &quot;foo[1].bar&quot;) what does the following keypath/object result in?

&quot;foo[0]&quot;
{ foo: [10] }

&quot;foo[1]&quot;
{ foo: [10] }

&quot;foo[5]&quot;
{ foo: [10] }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>42299</commentid>
    <comment_count>1</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2010-11-09 01:12:36 +0000</bug_when>
    <thetext>Oh, something that definitely needs to be an error is

&quot;foo&quot;
4

I.e. trying to set a property on a primitive value.

But what about:

&quot;foo&quot;
[10]

Technically speaking the structured clone format already supports serializing properties on arrays, but it still feels wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48753</commentid>
    <comment_count>2</comment_count>
    <who name="Pablo Castro">pablo.castro</who>
    <bug_when>2011-05-24 21:55:54 +0000</bug_when>
    <thetext>Here&apos;s my take on this. We can discuss in the list if any of these needs further details:

&gt;&gt; But what about
&gt;&gt; 
&gt;&gt; &quot;foo.bar&quot;
&gt;&gt; { foo: { bar: 10 } }
&gt;&gt; 
&gt;&gt; Does this use the value 10 rather than generate a new key, does it throw an exception or does it store the value { foo: { bar: 4 } }?

It uses the value 10 (and fails if there is a constraint violation). This is just like when you explicitly specify a key value in a top-level keypath.

&gt;&gt; What happens if the property is missing several parents, such as
&gt;&gt; 
&gt;&gt; &quot;foo.bar.baz&quot;
&gt;&gt; { zip: {} }
&gt;&gt; 
&gt;&gt; Does this throw or does it store { zip: {}, foo: { bar: { baz: 4 } } }

It creates all the parents until it can store the value.

&gt;&gt; If we end up allowing array indexes in key paths (like &quot;foo[1].bar&quot;) what does
&gt;&gt; the following keypath/object result in?
&gt;&gt; 
&gt;&gt; &quot;foo[0]&quot;
&gt;&gt; { foo: [10] }
&gt;&gt; 
&gt;&gt; &quot;foo[1]&quot;
&gt;&gt; { foo: [10] }
&gt;&gt; 
&gt;&gt; &quot;foo[5]&quot;
&gt;&gt; { foo: [10] }

These would probably be fine. The only thing I wouldn&apos;t do is to complete the array so it&apos;s not sparse (the spec doesn&apos;t allow sparse arrays to be keys).

&gt;&gt; Oh, something that definitely needs to be an error is
&gt;&gt; 
&gt;&gt; &quot;foo&quot;
&gt;&gt; 4
&gt;&gt; 
&gt;&gt; I.e. trying to set a property on a primitive value.

Agreed.

&gt;&gt; But what about:
&gt;&gt; 
&gt;&gt; &quot;foo&quot;
&gt;&gt; [10]
&gt;&gt; 
&gt;&gt; Technically speaking the structured clone format already supports serializing
properties on arrays, but it still feels wrong.

+1, too weird.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50980</commentid>
    <comment_count>3</comment_count>
    <who name="Eliot Graff">eliotgra</who>
    <bug_when>2011-07-13 21:52:57 +0000</bug_when>
    <thetext>I added examples to 3.1.3 Keys, as outlined in this bug and the mails.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>