Mnesia Errors case_clause in QLC query without a case clause
<p>I have the following function for a hacky project:</p>

<pre><code>% The Record variable is some known record with an associated table.
Query = qlc:q([Existing ||
  Existing &lt;- mnesia:table(Table),
  ExistingFields = record_to_fields(Existing),
  RecordFields = record_to_fields(Record),
  ExistingFields == RecordFields
]).
</code></pre>

<p>The function <code>record_to_fields/1</code> simply drops the record name and ID from the tuple so that I can compare the fields themselves. If anyone wants context, it's because I pre-generate a unique ID for a record before attempting to insert it into Mnesia, and I want to make sure that a record with identical fields (but different ID) does not exist. </p>

<p>This results in the following (redacted for clarity) stack trace: </p>

<pre><code>{aborted, {{case_clause, {stuff}},
      [{db, '-my_func/2-fun-1-',8, ...
</code></pre>

<p>Which points to the line where I declare <code>Query</code>, however there is no case clause in sight. What is causing this error?</p>

<p>(Will answer myself, but I appreciate a comment that could explain how I could achieve what I want)</p>

<p>EDIT: this wouldn't be necessary if I could simply mark certain fields as unique, and Mnesia had a dedicated <code>insert/1</code> or <code>create/1</code> function. </p>