<div dir="ltr"><br><br><div class="gmail_quote">On Sun, Apr 17, 2011 at 8:01 AM, Ian Duncan <span dir="ltr">&lt;<a href="mailto:iand675@gmail.com">iand675@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><div><div></div><div class="h5"><br><div><div>On Apr 16, 2011, at 11:48 PM, Michael Snoyman wrote:</div><br><blockquote type="cite"><div dir="ltr"><br><br><div class="gmail_quote">On Sun, Apr 17, 2011 at 7:37 AM, Ian Duncan <span dir="ltr">&lt;<a href="mailto:iand675@gmail.com" target="_blank">iand675@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word"><div><div></div><div><br><div><div>On Apr 16, 2011, at 10:53 PM, Michael Snoyman wrote:</div><br><blockquote type="cite"><div dir="ltr"><br><br><div class="gmail_quote">On Sun, Apr 17, 2011 at 6:27 AM, Ian Duncan <span dir="ltr">&lt;<a href="mailto:iand675@gmail.com" target="_blank">iand675@gmail.com</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I&#39;m fiddling around a bit with the Persist library and wondering what the PersistUpdate datatype does. From what I can gather, it looks like Update replaces the value, add will add to the current value if it is an integer or double, and subtract, multiply, and divide perform their respective operations. Is this correct, or is there something else to these types?<br>






<br></blockquote><div><br></div><div>Nope, that&#39;s it. In SQL, none of the addition/subtraction/multiplication/division logic is performed in Persistent, rather it&#39;s all passed off to the SQL engine. So if you try to divide two strings, the result depends on what the SQL engine allows.</div>





<div><br></div><div>Michael </div></div></div>
</blockquote></div><br></div></div><div>If I may ask then, does not using the Update keyword in the quasiquoting syntax simply mean that no default implementation of update is provided? Is the rationale for this to prevent accidental modifications of fields that should remain static once a row is inserted? It seems like a somewhat cumbersome restriction.</div>



</div></blockquote></div><br><div>I&#39;ll tell you the theory for requiring the Update keyword (and Eq, Lt, Gt, Asc, Desc, ...). In theory, backends can optimize for different use cases. The prime example I give is that a SQL backend could automatically add indices if it knows that a field will be sorted on. (We don&#39;t do this currently, but I&#39;ll consider adding it in the future.) It&#39;s entirely possible that there are backends for which a more optimal structure can be set up when only certain fields can be updated.</div>



<div><br></div><div>That&#39;s the theory. Maybe in practice this was all a bad idea, feel free to let me know how you feel either way ;).</div><div><br></div><div>Michael</div></div>
</blockquote></div><br></div></div><div>Perhaps what I would suggest then is providing the ability to use the update keyword over a whole data type like so:</div><div><br></div><div>[persist|</div><div>Appointment Update</div>

<div><span style="white-space:pre-wrap">        </span>day Day</div><div><span style="white-space:pre-wrap">        </span>time TimeOfDay</div><div><span style="white-space:pre-wrap">        </span>finished Bool</div><div><span style="white-space:pre-wrap">        </span>price Int Add</div>

<div><span style="white-space:pre-wrap">        </span>billingFirstName String</div><div><span style="white-space:pre-wrap">        </span>billingLastName String</div><div><span style="white-space:pre-wrap">        </span>billingTelephone String</div>

<div><span style="white-space:pre-wrap">        </span>billingEmail EmailId</div><div><span style="white-space:pre-wrap">        </span>expressToken String NoUpdate</div><div><span style="white-space:pre-wrap">        </span>expressId String NoUpdate</div>

<div>|]</div><div><br></div><div>This is a contrived example, but notice the use of the Update keyword after Appointment and the use of NoUpdate keyword for expressToken and expressId. This would make all fields updatable by default with the exception of expressToken, expressId, which would not provide an updating function, and price which would override the overwrite form of update in favor of addition.</div>

<div><br></div><div>What do you think?</div></div></blockquote></div><br><div>I have no objections, and it&#39;s a relatively easy change to put into place. Does anyone else have an opinion?</div><div><br></div><div>This will likely need to wait for a point release of persistent, since I&#39;m really trying to avoid adding bugs 5 hours before a release ;).</div>

<div><br></div><div>Michael</div></div>