<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">find_or_create relies on you supplying enough information to be able to “find” a single matching row. So, whatever key you tell it to use, you must supply that column in the data. If your primary key is ‘nodeid’ then you must supply that. Since it looks like you don’t want to know that, and instead want to use ‘nodeName’ you have two choices (assuming you want to use find_or_create):</div><div class=""><br class=""></div><div class="">1. Get rid of nodeid altogether and make nodename the primary key</div><div class="">2. Add a separate unique constraint on nodename, and then, use that key in the find_or_create…</div><div class=""><br class=""></div><div class="">Here is an example of what that looks like in the Result class:&nbsp;<a href="https://github.com/vanstyn/Rapi-Blog/blob/master/lib/Rapi/Blog/DB/Result/User.pm#L51" class="">https://github.com/vanstyn/Rapi-Blog/blob/master/lib/Rapi/Blog/DB/Result/User.pm#L51</a></div><div class=""><br class=""></div><div class="">And then here is an example of a find_or_create which makes use of it:&nbsp;<a href="https://github.com/vanstyn/Rapi-Blog/blob/master/devel/import_frew_posts.pl#L43-L47" class="">https://github.com/vanstyn/Rapi-Blog/blob/master/devel/import_frew_posts.pl#L43-L47</a></div><div class=""><br class=""></div><div class="">The critical bit there is that I’m supplying ‘username’ in the column data, since that is the column of the ‘username_unique’ constraint. So for your case you would have something like { key =&gt; ‘nodename_unique’ } assuming that’s what you called it.&nbsp;</div><div class=""><br class=""></div><div class="">I don’t know how you are creating your DBIC schema, but if you are using something like Schema::Loader to generate it from an existing database, you would need to change the real, underlying schema. That is RDBMS-specific, but to see what that looks like for the above example in SQLite:&nbsp;<a href="https://github.com/vanstyn/Rapi-Blog/blob/master/sql/rapi_blog.sql#L18" class="">https://github.com/vanstyn/Rapi-Blog/blob/master/sql/rapi_blog.sql#L18</a>&nbsp;(note the use of the ‘UNIQUE’ keyword — this sets up an unique index for that column on the table, which Schema::Loader detects and creates the DBIC constraint for you)</div><div class=""><br class=""></div><div class="">Finally, if you don’t want to do that, just don’t use find_or_create, and do it manually (i.e by calling -&gt;search()-&gt;first, etc). However, if nodename is not already required in your schema to be unique, it is probably a mistake. Since this means there could be more than one row with the same ‘nodename’ value, which guessing from what I’ve seen so far isn’t what you want. That is the actual root of the problem — you are not giving DBIC a way to identify the *single* row to match to “find”.</div><div class=""><br class=""></div><div class="">Hope this helps,</div><div class="">Henry</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 21, 2017, at 5:41 PM, Rajeev Prasad &lt;<a href="mailto:rp.neuli@yahoo.com" class="">rp.neuli@yahoo.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div style="background-color: rgb(255, 255, 255); font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;" class=""><div id="yui_3_16_0_ym19_1_1503351235084_5446" class="">that does not work.</div><div class=""><br class=""></div><div dir="ltr" class="">i get this err:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5411" class=""><br class=""></div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5412" class="">DBIx::Class::ResultSource::_minimal_valueset_satisfying_constraint(): Unable to satisfy requested constraint 'primary', missing values for column(s): 'nodeid' at ./test.pl line 80</div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5533" class=""><br class=""></div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5534" class=""><br class=""></div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5475" class="">when i remove the key part altogether i get new err:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5496" class=""><br class=""></div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5497" class="">DBIx::Class::Row::store_column(): No such column 'nodeName' on Mydb::Schema::Result::Node at ./test.pl line 80</div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5627" class=""><br class=""></div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5596" class="">and we know that column exist. so i think there is some crap happening with CamleCase in col names. I will try with changed col names. it is very frustrating.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5658" class=""><br id="yui_3_16_0_ym19_1_1503351235084_5410" class=""></div><div dir="ltr" id="yui_3_16_0_ym19_1_1503351235084_5413" class=""><br class=""></div><div id="yui_3_16_0_ym19_1_1503351235084_5407" class=""><span class=""></span></div> <div class="qtdSeparateBR"><br class=""><br class=""></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 13px;" class=""> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" class=""> <div dir="ltr" class=""><font size="2" face="Arial" class=""> On Monday, August 21, 2017 9:38 AM, tirveni yadav &lt;<a href="mailto:yadav.tirveni@gmail.com" class="">yadav.tirveni@gmail.com</a>&gt; wrote:<br class=""></font></div>  <br class=""><br class=""> <div class="y_msg_container"><div dir="ltr" class="">On Mon, Aug 21, 2017 at 7:15 PM, Rajeev Prasad &lt;<a shape="rect" ymailto="mailto:rp.neuli@yahoo.com" href="mailto:rp.neuli@yahoo.com" class="">rp.neuli@yahoo.com</a>&gt; wrote:<br clear="none" class="">&gt; no, nodeID is auto increment field as seen in tabel description. it is<br clear="none" class="">&gt; complaining there is no such key. i dont know why...<br clear="none" class="">&gt;<br clear="none" class="">&gt;<br clear="none" class="">&gt;<br clear="none" class="">&gt; On Monday, August 21, 2017 7:39 AM, tirveni yadav &lt;<a shape="rect" ymailto="mailto:yadav.tirveni@gmail.com" href="mailto:yadav.tirveni@gmail.com" class="">yadav.tirveni@gmail.com</a>&gt;<br clear="none" class="">&gt; wrote:<br clear="none" class="">&gt;<br clear="none" class="">&gt;<br clear="none" class="">&gt; On Mon, Aug 21, 2017 at 6:50 AM, Rajeev Prasad &lt;<a shape="rect" ymailto="mailto:rp.neuli@yahoo.com" href="mailto:rp.neuli@yahoo.com" class="">rp.neuli@yahoo.com</a>&gt; wrote:<br clear="none" class="">&gt;&gt;<br clear="none" class="">&gt;&gt; why am i getting this err in DBIx::Class ?<br clear="none" class="">&gt;&gt;<br clear="none" class="">&gt;&gt; $./update_db.pl<br clear="none" class="">&gt;&gt; DBIx::Class::ResultSource::unique_constraint_columns(): Unknown unique<br clear="none" class="">&gt;&gt; constraint nodeid on 'node' at ./update_from_ieds.pl line 80<br clear="none" class="">&gt;&gt;<br clear="none" class="">&gt;&gt;<br clear="none" class="">&gt;&gt; relevant code:<br clear="none" class="">&gt;&gt; ...<br clear="none" class="">&gt;&gt; sub addNode<br clear="none" class="">&gt;&gt; {<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; my $node = shift; my $lcNode = lc($node);<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; my $id = $schema<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; -&gt;resultset('Node')<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; -&gt;find_or_create<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; (<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { nodeName =&gt; $lcNode },<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { key =&gt; 'nodeid' }<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; );<br clear="none" class="">&gt;&gt;&nbsp; &nbsp; return $id;<br clear="none" class="">&gt;&gt; }<br clear="none" class="">&gt;<br clear="none" class="">&gt;<br clear="none" class="">&gt; Are you trying to do this:<br clear="none" class="">&gt;<br clear="none" class="">&gt;<br clear="none" class="">&gt; my $id = $schema<br clear="none" class="">&gt;&nbsp; &nbsp; &nbsp; &nbsp;  -&gt;resultset('Node')-&gt;find_or_create<br clear="none" class="">&gt;&nbsp; &nbsp; &nbsp;  (<br clear="none" class="">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br clear="none" class="">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nodeName&nbsp; =&gt; $lcNode ,<br clear="none" class="">&gt;<br clear="none" class="">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nodeID&nbsp; &nbsp; =&gt; $nodeid,<br clear="none" class="">&gt;&nbsp; &nbsp; &nbsp; &nbsp;  }<br clear="none" class="">&gt;&nbsp; &nbsp; &nbsp; &nbsp;  );<br clear="none" class="">&gt;<br clear="none" class=""><br clear="none" class="">In my view, unique constraint naming issue:<br clear="none" class=""><br clear="none" class="">Try this:<br clear="none" class=""><br clear="none" class="">A.<br clear="none" class="">In Node.pm:<br clear="none" class=""><br clear="none" class="">__PACKAGE__-&gt;add_unique_constraint(node_nodeid =&gt; [ qw/nodeid/ ], );<br clear="none" class=""><br clear="none" class=""><br clear="none" class="">B.<br clear="none" class="">function add_node<br clear="none" class="">{<br clear="none" class="">&nbsp; my $rs_node = $dbic-&gt;resultset('Node');<br clear="none" class=""><br clear="none" class="">&nbsp; my $row_node;<br clear="none" class="">&nbsp; $row_node = $rs_node-&gt;find_or_create<br clear="none" class="">&nbsp; &nbsp; &nbsp; &nbsp; (<br clear="none" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br clear="none" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nodename =&gt; 'October',<br clear="none" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nodeid =&gt; '10',<br clear="none" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  },<br clear="none" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { key =&gt; 'node_nodeid' }<br clear="none" class="">&nbsp; &nbsp; &nbsp; &nbsp; );<br clear="none" class="">&nbsp; return $row_node;<br clear="none" class=""><br clear="none" class="">}<br clear="none" class=""><br clear="none" class=""><br clear="none" class="">-- <br clear="none" class="">Regards,<br clear="none" class=""><br clear="none" class="">Tirveni Yadav<br clear="none" class=""><br clear="none" class=""><a href="http://www.udyansh.org" class="">www.udyansh.org</a><div class="yqt2997962540" id="yqtfd03090"><br clear="none" class=""><br clear="none" class="">www.bael.io<br clear="none" class=""><br clear="none" class="">What is this Universe ? From what it arises ? Into what does it go?<br clear="none" class="">In freedom it arises, In freedom it rests and into freedom it melts away.<br clear="none" class="">Upanishads.<br clear="none" class=""></div></div><br class=""><br class=""></div>  </div> </div>  </div></div></div>_______________________________________________<br class="">List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" class="">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br class="">IRC: <a href="http://irc.perl.org" class="">irc.perl.org</a>#dbix-class<br class="">SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" class="">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br class="">Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" class="">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a></div></blockquote></div><br class=""></body></html>