2016-03-25 17 views
1

私の人生にとって、これを理解することはできません。私はmnesiaテーブルを作成しようとしていますが、この奇妙なエラーが発生し続ける。ここでmnesiaテーブルを作成しようとすると「bad_type」エラーが発生する

は私のコマンドです:ここでは

ok = mnesia:create_schema(Nodes), 
rpc:multicall(Nodes, application, start, [mnesia]), 
{_, ok} = mnesia:create_table(rr_events, 
     [{attributes, record_info(fields, rr_events)}, 
     {index, [#rr_events.key]}, 
     {disc_copies, Nodes}]), 
rpc:multicall(Nodes, application, stop, [mnesia]). 

は私の記録である:ここでは

-record(rr_events, {key, events=[]}). 

は誤りです:これが何であるか

=PROGRESS REPORT==== 24-Mar-2016::21:53:42 === 
     application: mnesia 
      started_at: [email protected] 
** exception error: no match of right hand side value 
        {aborted,{bad_type,rr_events,{index,[2]}}} 
    in function rr:install/1 (c:/Users/zzzz/Projects/zzz/zzz/rr/rr/_build/default/lib/rr/src/rr.erl, line 13) 

任意のアイデア?これを理解できません。

答えて

1

は、私は最近、この問題に出くわしました。次Learn you some Erlang状態は:あなたが唯一のレコードの最初の要素のインデックスに必要がある場合は

Note that you do not need to put an index on the first field of the record, as this is done for you by default.

、私は{index, [record_name]}を省略助言します。

またLYSEから段落がそれを示唆する一方で、official Erlang documentationはさらに、1つを行くと述べている:

index. This is a list of attribute names, or integers, which specify the tuple positions on which Mnesia is to build and maintain an extra index table.

0

Phew!答えに私をリードするこのexcellent blog postのおかげで、引用:

This error:

{aborted,{bad_type,wrud_record,{index,[2]}}}

will occur if you used the first element of the record to index one table, like:

-record(wrud_record, {user, date, label, remark, url}).

and

mnesia:create_table(wrud_record,[ {index,[user]}, {attributes, record_info(fields, wrud_record)}])

, so you should change the index to another element like remark here:

mnesia:create_table(wrud_record,[ {index,[remark]}, {attributes, record_info(fields, wrud_record)}])

everything will be fine. :)

関連する問題