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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>18807</bug_id>
          
          <creation_ts>2008-04-29 22:52:20 -0700</creation_ts>
          <short_desc>Support storing JavaScript objects as BLOB</short_desc>
          <delta_ts>2023-08-24 03:53:37 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Jayant Sai">jayant.b.sai</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>beidson</cc>
    
    <cc>emacemac7</cc>
    
    <cc>jayant.b.sai</cc>
    
    <cc>oliver</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>79266</commentid>
    <comment_count>0</comment_count>
    <who name="Jayant Sai">jayant.b.sai</who>
    <bug_when>2008-04-29 22:52:20 -0700</bug_when>
    <thetext>According to http://www.sqlite.org/datatype3.html, &apos;BLOB. The value is a blob of data, stored exactly as it was input.&apos;. Currently in WebKit &amp; Safari, the implementation seems to convert the JavaScript object to a string &quot;[object Object]&quot;. It would be great if it were possible to store JavaScript objects and JSON objects within the database as BLOB and as objects and not as string representations.

Currently, only a string de/serialization would work, but that can be expensive, especially when trying to run Safari on iPhone which has very limited JavaScript execution time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79267</commentid>
    <comment_count>1</comment_count>
      <attachid>20897</attachid>
    <who name="Jayant Sai">jayant.b.sai</who>
    <bug_when>2008-04-29 22:54:26 -0700</bug_when>
    <thetext>Created attachment 20897
Test page

A simple test page showing storing an object literal as BLOB. Currently the alert displays the type of data after SELECT as string.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79693</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-05-05 12:02:36 -0700</bug_when>
    <thetext>SQLite documentation is only tangentially related to HTML5 storage, because there are at least two other type systems to consider - first, there is JavaScript, and then, there is DOM. And anyway, BLOB is not magic - it&apos;s just a special kind of string suitable for storing large amounts of data.

Yet, it does seem a little weird that a function is stringified like &quot;[object Object]&quot; in this test case - e.g. alert(selectData) successfully shows its source, and one could expect the same here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79849</commentid>
    <comment_count>3</comment_count>
    <who name="Jayant Sai">jayant.b.sai</who>
    <bug_when>2008-05-07 16:23:50 -0700</bug_when>
    <thetext>Thank you for clarifying about the SQLite &amp; HTML5 storage differences.

Do you have any recommendations on how I should store the object, without converting it to a String. In my current app, this conversion takes too long. Or is this a bug which will need to be fixed in WebKit?

thanks
Jayant

(In reply to comment #2)
&gt; SQLite documentation is only tangentially related to HTML5 storage, because
&gt; there are at least two other type systems to consider - first, there is
&gt; JavaScript, and then, there is DOM. And anyway, BLOB is not magic - it&apos;s just a
&gt; special kind of string suitable for storing large amounts of data.
&gt; 
&gt; Yet, it does seem a little weird that a function is stringified like &quot;[object
&gt; Object]&quot; in this test case - e.g. alert(selectData) successfully shows its
&gt; source, and one could expect the same here.
&gt; 

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80121</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-05-11 03:37:05 -0700</bug_when>
    <thetext>I don&apos;t think there is any way to store an object without turning it into a string. You may want to join WHATWG &lt;http://www.whatwg.org/&gt; and describe your use case in an e-mail to its list for people working on the specification to consider it.

Brady, what do you think? Does our implicit stringification appear broken, as I wondered in comment 2?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>130373</commentid>
    <comment_count>5</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2009-07-07 22:51:15 -0700</bug_when>
    <thetext>JSON.stringify would appear to accomplish what is being requested here</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>427034</commentid>
    <comment_count>6</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2011-06-24 12:07:49 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; JSON.stringify would appear to accomplish what is being requested here

As an addendum, our postMesage serialisation is a flat binary storage system that supports  avariety of dom objects and allows cyclic graphs, maybe that would be superior?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1973246</commentid>
    <comment_count>7</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-08-24 03:53:37 -0700</bug_when>
    <thetext>This should be standardized first as suggested above. But also, as suggested above, there&apos;s ample alternatives available.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>20897</attachid>
            <date>2008-04-29 22:54:26 -0700</date>
            <delta_ts>2008-04-29 22:54:26 -0700</delta_ts>
            <desc>Test page</desc>
            <filename>dbblob.html</filename>
            <type>text/html</type>
            <size>1678</size>
            <attacher name="Jayant Sai">jayant.b.sai</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEvL0VOIiAiaHR0cDov
L3d3dy53My5vcmcvVFIvaHRtbDQvc3RyaWN0LmR0ZCI+CjxodG1sPgogIDxoZWFkPgogICAgPHRp
dGxlPlN0b3JlIEJsb2IgRGF0YWJhc2U8L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EgQkxPQik7IiwgW10sIGFkZEJsb2JEYXRhLCBl
cnJvckhhbmRsZXIpOwogICAgICB9CiAgICAgIAogICAgICBmdW5jdGlvbiBhZGRCbG9iRGF0YSh0
cmFuc2FjdGlvbiwgcmVzdWx0cykgewogICAgICAgIHZhciBkYXRhID0geyBmb286IkZPTyIsIGJh
cjoiQkFSIiB9OwogICAgICAgIHRyYW5zYWN0aW9uLmV4ZWN1dGVTcWwoIklOU0VSVCBJTlRPIHRl
c3QgVkFMVUVTICg/KSIsIFtkYXRhXSwgc2VsZWN0RGF0YSwgZXJyb3JIYW5kbGVyKTsKICAgICAg
fQogICAgICAKICAgICAgZnVuY3Rpb24gc2VsZWN0RGF0YSh0cmFuc2FjdGlvbiwgcmVzdWx0cykg
ewogICAgICAgIHRyYW5zYWN0aW9uLmV4ZWN1dGVTcWwoIlNFTEVDVCBkYXRhIEZST00gdGVzdCIs
IFtdLCBzaG93UmVzdWx0LCBlcnJvckhhbmRsZXIpOwogICAgICB9CiAgICAgIAogICAgICBmdW5j
dGlvbiBzaG93UmVzdWx0KHRyYW5zYWN0aW9uLCByZXN1bHRzKSB7CiAgICAgICAgdmFyIGRhdGEg
PSByZXN1bHRzLnJvd3MuaXRlbSgwKS5kYXRhOwogICAgICAgIGFsZXJ0KGRhdGEgKyAiXG4iICsg
dHlwZW9mKGRhdGEpKTsKICAgICAgfQogICAgICAKICAgICAgZnVuY3Rpb24gZXJyb3JIYW5kbGVy
KHRyYW5zYWN0aW9uLCBlcnJvcikgewogICAgICAgIGFsZXJ0KCJFUlI6ICIgKyBlcnJvci5tZXNz
YWdlKTsKICAgICAgfQogICAgPC9zY3JpcHQ+CgogIDwvaGVhZD4KICA8Ym9keSBvbmxvYWQ9Imxv
YWQoKTsiPgogIDwvYm9keT4KPC9odG1sPg==
</data>

          </attachment>
      

    </bug>

</bugzilla>