Discussion:
unknown
1970-01-01 00:00:00 UTC
Permalink
<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt">Hi<br>&nbsp;&nbsp; Oops I should have RTFMed a bit more to refresh my memory before posting. <br><br>There are some significant differences.<br>To start things off (excuse errors due to failure to RTFM sufficiently):<br><br>DTL auto-prepares statements (would you ever not want to do this?)<br><br>You don't need to say select or insert its implicit in whether you are reading or writing.<br><div>So you just specify one or more tables (joins just work!) <br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">There's also a bulk fetch helper which can be used more efficiently than
iteration.<br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">Its not clear to me when SOCI uses bulk fetch. If you use a vector of rows I think it will just iterate?<br><span class="tab"></span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br><span class="tab"></span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">Finally there is fine control over the mapping of datatypes (for reasons I forget called a BCA in DTL,</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">&nbsp;and which in C++11 could be a lambda instead).<br><span
class="tab"></span></div>I think this is a little less awkward than specialising the type_conversion template in SOCI<br>(though I am prepared to be shown wrong by any SOCI gurus)<br><br>E.g.<div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyRowType rowbuf,<br></span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DBView&lt;MyRowType&gt; view("table1, table1",</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span
class="tab">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BCA(rowbuf,<br><span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tab">&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COLS["column1"] &gt;&gt; rowbuf.column1 &amp;&amp;</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent;
font-style: normal;"><span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tab">&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COLS["column2"] &gt;&gt; rowbuf.column2),</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span class="tab">&nbsp;&nbsp;&nbsp; </span><span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "where clause here
if you want it");<br></span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bulk_fetch_helper(view.begin(), 500, std::ostream_iterator&lt;MyRowType&gt;(std::cout, "\n"));<br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">So I think there is some room for improvement in SOCI on the ORM side. <br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">I suspect a lot of the success of SOCI, in terms of attracting users, is based on its ability to make queries
look</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">like embedded SQL (but of course so much better). <br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">I think the success of ORMs and DTL in particular is in hiding the database wherever possible.<br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">So from the ORM perspective embedding SQL seems like a horseless carriage</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">(see for example http://www.horton.com/beyondhcthandouts.htm)</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px;
font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">The DTL documentation makes no bones about pushing for a modern design away from the horseless carriage of embedded SQL.</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">SOCI on the other hand just leaves it to the user. Users coming from the a background of using SQL directly on the database</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">will naturally be drawn to the embedded SQL way of thinking and hence prefer that side of SOCI to its ORM offering. <br></div><div style="color: rgb(0, 0, 0);
font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">Java programmers will be drawn the other way from using Hibernate/JPA.<br></div><br>My agenda here is simply that SOCI+DTL (or even +=) would form a good starting point for a standard C++ database interface.<br>Now that its come up again in the context of C++1y with library proposals not having to wait for a new standard<br>its worth giving more thought.<br><br>Regards,<br><br>Bruce.<br><br><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;"> <div style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1"> <font face="Arial" size="2"> <b><span style="font-weight:bold;">From:</span></b> Mateusz Loskot &lt;***@loskot.net&gt;<br> <b><span style="font-weight: bold;">To:</span></b> Bruce Adams &lt;***@yahoo.co.uk&gt;; SOCI general discussion list &lt;soci-***@lists.sourceforge.net&gt; <br> <b><span style="font-weight: bold;">Sent:</span></b> Friday, April 12, 2013 5:48 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [soci-users] The next three big things<br> </font> </div> <div class="y_msg_container"><br>
On 12 April 2013 16:16, Bruce Adams &lt;<a ymailto="mailto:***@yahoo.co.uk" href="mailto:***@yahoo.co.uk">***@yahoo.co.uk</a>&gt; wrote:<br>&gt; Thanks in part to my prompting the the author of DTL has posted in<br>&gt; regard to n3612<br>&gt;<br>&gt; <a href="https://groups.google.com/a/isocpp.org/forum/#%21topic/std-proposals/iqOtgxP_IRA" target="_blank">https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/iqOtgxP_IRA</a><br><br>Thanks for that. The whole discussion is very interesting.<br>I will yet see, but despite I am subscribed to that mailing list,<br>it is unlikely I will have time to dive into it myself, unfortunately.<br><br>&gt; One of the attractions of DTLs approach for me is illustrated by the example<br>&gt; of how to dump an entire table:<br><br>&gt; DynamicDBView&lt;&gt; view("DB_EXAMPLE", "*");<br>&gt; copy(view.begin(), view.end(), ostream_iterator&lt;variant_row&gt;(cout, "\n"));<br>&gt;<br>&gt;
I never worked out if it was possible to be quite so elegant in SOCI. Is it?<br><br>Yes, fancy :-)<br><br>
Loading...