<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1503431365714_29795">Hello Henry,</div><div dir="ltr" id="yui_3_16_0_ym19_1_1503431365714_29796">thank you. it was very helpful, I have saved the response.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1503431365714_29838">the key piece that col has to be present on which the key is built, was helpful..<br></div><div id="yui_3_16_0_ym19_1_1503431365714_29798"><span id="yui_3_16_0_ym19_1_1503431365714_29876">thx for examples also. again very helpful !</span></div><div id="yui_3_16_0_ym19_1_1503431365714_29870"><span><br></span></div><div id="yui_3_16_0_ym19_1_1503431365714_29871"><span>thank you!</span></div><div id="yui_3_16_0_ym19_1_1503431365714_29872"><span>Rajeev</span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 13px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> On Monday, August 21, 2017 5:26 PM, Henry Van Styn &lt;vanstyn@cpan.org&gt; wrote:<br></font></div>  <br><br> <div class="y_msg_container"><div id="yiv4869423755"><div><div class="yiv4869423755">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="yiv4869423755"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755">1. Get rid of nodeid altogether and make nodename the primary key</div><div class="yiv4869423755">2. Add a separate unique constraint on nodename, and then, use that key in the find_or_create…</div><div class="yiv4869423755"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755">Here is an example of what that looks like in the Result class:&nbsp;<a rel="nofollow" shape="rect" class="yiv4869423755" target="_blank" href="https://github.com/vanstyn/Rapi-Blog/blob/master/lib/Rapi/Blog/DB/Result/User.pm#L51">https://github.com/vanstyn/Rapi-Blog/blob/master/lib/Rapi/Blog/DB/Result/User.pm#L51</a></div><div class="yiv4869423755"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755">And then here is an example of a find_or_create which makes use of it:&nbsp;<a rel="nofollow" shape="rect" class="yiv4869423755" target="_blank" href="https://github.com/vanstyn/Rapi-Blog/blob/master/devel/import_frew_posts.pl#L43-L47">https://github.com/vanstyn/Rapi-Blog/blob/master/devel/import_frew_posts.pl#L43-L47</a></div><div class="yiv4869423755"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755">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="yiv4869423755"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755">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 rel="nofollow" shape="rect" class="yiv4869423755" target="_blank" href="https://github.com/vanstyn/Rapi-Blog/blob/master/sql/rapi_blog.sql#L18">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="yiv4869423755"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755">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="yiv4869423755"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755">Hope this helps,</div><div class="yiv4869423755">Henry</div><div class="yiv4869423755"><br class="yiv4869423755" clear="none"></div><br class="yiv4869423755" clear="none"><div><blockquote class="yiv4869423755" type="cite"><div class="yiv4869423755yqt3129173099" id="yiv4869423755yqt49900"><div class="yiv4869423755">On Aug 21, 2017, at 5:41 PM, Rajeev Prasad &lt;<a rel="nofollow" shape="rect" class="yiv4869423755" ymailto="mailto:rp.neuli@yahoo.com" target="_blank" href="mailto:rp.neuli@yahoo.com">rp.neuli@yahoo.com</a>&gt; wrote:</div><br class="yiv4869423755Apple-interchange-newline" clear="none"><div class="yiv4869423755"><div class="yiv4869423755"><div class="yiv4869423755" style="background-color:rgb(255, 255, 255);font-family:'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:13px;"><div class="yiv4869423755" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5446">that does not work.</div><div class="yiv4869423755"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755" dir="ltr">i get this err:</div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5411"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5412">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 class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5533"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5534"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5475">when i remove the key part altogether i get new err:</div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5496"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5497">DBIx::Class::Row::store_column(): No such column 'nodeName' on Mydb::Schema::Result::Node at ./test.pl line 80</div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5627"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5596">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 class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5658"><br class="yiv4869423755" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5410" clear="none"></div><div class="yiv4869423755" dir="ltr" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5413"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755" id="yiv4869423755yui_3_16_0_ym19_1_1503351235084_5407"><span class="yiv4869423755"></span></div> <div class="yiv4869423755qtdSeparateBR"><br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none"></div><div class="yiv4869423755yahoo_quoted" style="display:block;"> <div class="yiv4869423755" style="font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;"> <div class="yiv4869423755" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div class="yiv4869423755" dir="ltr"><font class="yiv4869423755" size="2" face="Arial"> On Monday, August 21, 2017 9:38 AM, tirveni yadav &lt;<a rel="nofollow" shape="rect" class="yiv4869423755" ymailto="mailto:yadav.tirveni@gmail.com" target="_blank" href="mailto:yadav.tirveni@gmail.com">yadav.tirveni@gmail.com</a>&gt; wrote:<br class="yiv4869423755" clear="none"></font></div>  <br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none"> <div class="yiv4869423755y_msg_container"><div class="yiv4869423755" dir="ltr">On Mon, Aug 21, 2017 at 7:15 PM, Rajeev Prasad &lt;<a rel="nofollow" shape="rect" class="yiv4869423755" ymailto="mailto:rp.neuli@yahoo.com" target="_blank" href="mailto:rp.neuli@yahoo.com">rp.neuli@yahoo.com</a>&gt; wrote:<br class="yiv4869423755" clear="none">&gt; no, nodeID is auto increment field as seen in tabel description. it is<br class="yiv4869423755" clear="none">&gt; complaining there is no such key. i dont know why...<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt; On Monday, August 21, 2017 7:39 AM, tirveni yadav &lt;<a rel="nofollow" shape="rect" class="yiv4869423755" ymailto="mailto:yadav.tirveni@gmail.com" target="_blank" href="mailto:yadav.tirveni@gmail.com">yadav.tirveni@gmail.com</a>&gt;<br class="yiv4869423755" clear="none">&gt; wrote:<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt; On Mon, Aug 21, 2017 at 6:50 AM, Rajeev Prasad &lt;<a rel="nofollow" shape="rect" class="yiv4869423755" ymailto="mailto:rp.neuli@yahoo.com" target="_blank" href="mailto:rp.neuli@yahoo.com">rp.neuli@yahoo.com</a>&gt; wrote:<br class="yiv4869423755" clear="none">&gt;&gt;<br class="yiv4869423755" clear="none">&gt;&gt; why am i getting this err in DBIx::Class ?<br class="yiv4869423755" clear="none">&gt;&gt;<br class="yiv4869423755" clear="none">&gt;&gt; $./update_db.pl<br class="yiv4869423755" clear="none">&gt;&gt; DBIx::Class::ResultSource::unique_constraint_columns(): Unknown unique<br class="yiv4869423755" clear="none">&gt;&gt; constraint nodeid on 'node' at ./update_from_ieds.pl line 80<br class="yiv4869423755" clear="none">&gt;&gt;<br class="yiv4869423755" clear="none">&gt;&gt;<br class="yiv4869423755" clear="none">&gt;&gt; relevant code:<br class="yiv4869423755" clear="none">&gt;&gt; ...<br class="yiv4869423755" clear="none">&gt;&gt; sub addNode<br class="yiv4869423755" clear="none">&gt;&gt; {<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; my $node = shift; my $lcNode = lc($node);<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; my $id = $schema<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; -&gt;resultset('Node')<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; -&gt;find_or_create<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; (<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { nodeName =&gt; $lcNode },<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { key =&gt; 'nodeid' }<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; );<br class="yiv4869423755" clear="none">&gt;&gt;&nbsp; &nbsp; return $id;<br class="yiv4869423755" clear="none">&gt;&gt; }<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt; Are you trying to do this:<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt; my $id = $schema<br class="yiv4869423755" clear="none">&gt;&nbsp; &nbsp; &nbsp; &nbsp;  -&gt;resultset('Node')-&gt;find_or_create<br class="yiv4869423755" clear="none">&gt;&nbsp; &nbsp; &nbsp;  (<br class="yiv4869423755" clear="none">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br class="yiv4869423755" clear="none">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nodeName&nbsp; =&gt; $lcNode ,<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nodeID&nbsp; &nbsp; =&gt; $nodeid,<br class="yiv4869423755" clear="none">&gt;&nbsp; &nbsp; &nbsp; &nbsp;  }<br class="yiv4869423755" clear="none">&gt;&nbsp; &nbsp; &nbsp; &nbsp;  );<br class="yiv4869423755" clear="none">&gt;<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">In my view, unique constraint naming issue:<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">Try this:<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">A.<br class="yiv4869423755" clear="none">In Node.pm:<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">__PACKAGE__-&gt;add_unique_constraint(node_nodeid =&gt; [ qw/nodeid/ ], );<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">B.<br class="yiv4869423755" clear="none">function add_node<br class="yiv4869423755" clear="none">{<br class="yiv4869423755" clear="none">&nbsp; my $rs_node = $dbic-&gt;resultset('Node');<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">&nbsp; my $row_node;<br class="yiv4869423755" clear="none">&nbsp; $row_node = $rs_node-&gt;find_or_create<br class="yiv4869423755" clear="none">&nbsp; &nbsp; &nbsp; &nbsp; (<br class="yiv4869423755" clear="none">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br class="yiv4869423755" clear="none">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nodename =&gt; 'October',<br class="yiv4869423755" clear="none">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nodeid =&gt; '10',<br class="yiv4869423755" clear="none">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  },<br class="yiv4869423755" clear="none">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { key =&gt; 'node_nodeid' }<br class="yiv4869423755" clear="none">&nbsp; &nbsp; &nbsp; &nbsp; );<br class="yiv4869423755" clear="none">&nbsp; return $row_node;<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">}<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">-- <br class="yiv4869423755" clear="none">Regards,<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">Tirveni Yadav<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none"><a rel="nofollow" shape="rect" class="yiv4869423755" target="_blank" href="http://www.udyansh.org/">www.udyansh.org</a><div class="yiv4869423755yqt2997962540" id="yiv4869423755yqtfd03090"><br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">www.bael.io<br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none">What is this Universe ? From what it arises ? Into what does it go?<br class="yiv4869423755" clear="none">In freedom it arises, In freedom it rests and into freedom it melts away.<br class="yiv4869423755" clear="none">Upanishads.<br class="yiv4869423755" clear="none"></div></div><br class="yiv4869423755" clear="none"><br class="yiv4869423755" clear="none"></div>  </div> </div>  </div></div></div>_______________________________________________<br class="yiv4869423755" clear="none">List: <a rel="nofollow" shape="rect" class="yiv4869423755" target="_blank" href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br class="yiv4869423755" clear="none">IRC: <a rel="nofollow" shape="rect" class="yiv4869423755" target="_blank" href="http://irc.perl.org/">irc.perl.org</a>#dbix-class<br class="yiv4869423755" clear="none">SVN: <a rel="nofollow" shape="rect" class="yiv4869423755" target="_blank" href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br class="yiv4869423755" clear="none">Searchable Archive: <a rel="nofollow" shape="rect" class="yiv4869423755" target="_blank" href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a></div></div></blockquote></div><br class="yiv4869423755" clear="none"></div></div><br><br></div>  </div> </div>  </div></div></body></html>