title: How to check if a table sub-field exist in Lua?
body: <p>I'm trying to use Wikidata's Lua models.</p>
  
  <p>I need to search for a specific ID in Wikidata's entities :</p>
  
  <pre><code>    subjectitemofthisproperty = 'Q' .. tostring( entity['claims']['P1629'][1]["mainsnak"]["datavalue"]["value"]["numeric-id"] )
  </code></pre>
  
  <p>The main problem is that some entities don't have the <code>entity['claims']['P1629'][1]["mainsnak"]["datavalue"]["value"]["numeric-id"]</code> subfield.</p>
  
  <p>So that Lua returns:</p>
  
  <blockquote>
    <p>Lua error in Module:LoPwS_row at line 80: attempt to index field
    'P1629' (a nil value).</p>
  </blockquote>
  
  <p>If I do a :</p>
  
  <pre><code>if entity['claims']['P1629'][1]["mainsnak"]["datavalue"]["value"]["numeric-id"] ~= nil then
  </code></pre>
  
  <p>It will not work because the condition call the field and, then, return the same error.</p>
  
  <p>Is there a simple solution for test if a field exists? Thanks!</p>