Chicagoboss 数据库之郁闷

从表面上看CB功能很强大。也许。。。

版本0.7.2

以前 太乐观,以为 出了riak其它支持的数据库都能随意切换,说想的美一点都不错

我们开始开发用的是mock,测试方便,不需要创建表。

开发完了,切换到mysql上问题来了阿阿阿阿阿。

1、如果每个table名必须是复数形式 如account module必须用accounts表名(其它的测试)。

2、Id 需要设置为自动增长我采用biginit(11),如果采用其它类型 只能插入NULL

3、字段名称也需要注意不能随便用"_id"结尾否则会认为"_id"前面是表名。如send_user_id 会认为send_user是表,其实可能不是此时会出错。

4、继续说明'test_id' 此字段必须与test表的id类型一致。s

 

查询错误与区别

 

([email protected])54> 

([email protected])54> boss_db:find("account-1").

* 5: syntax error before: boss_db

([email protected])54> boss_db:find("account-1").

{account,"account-1",<<"jason">>,

         <<"[email protected]">>,undefined,undefined,<<"1234">>,

         <<"2012-03-15 01:51:34">>,<<"jason">>,<<"13105322554">>,

         undefined,undefined}

([email protected])55> boss_db:find(account,[{id,"1"}]).

[{account,"account-1",<<"jason">>,

          <<"[email protected]">>,undefined,undefined,<<"1234">>,

          <<"2012-03-15 01:51:34">>,<<"jason">>,<<"13105322554">>,

          undefined,undefined}]

([email protected])56> boss_db:find(account,[{id,"account-1"}]).

[]

([email protected])57> boss_db:find("1").                       

** exception exit: {{{badmatch,["1"]},

                     [{boss_db_adapter_mysql,infer_type_from_id,1},

                      {boss_db_adapter_mysql,find,2},

                      {boss_db_controller,handle_call,3},

                      {gen_server,handle_msg,5},

                      {proc_lib,init_p_do_apply,3}]},

                    {gen_server,call,[<0.12572.0>,{find,"1"},30000]}}

     in function  gen_server:call/3

     in call from boss_pool:call/3

([email protected])58> 

=ERROR REPORT==== 15-Mar-2012::17:11:48 ===

** Generic server <0.12572.0> terminating 

** Last message in was {find,"1"}

** When Server state == {state,boss_db_adapter_mysql,<0.12573.0>,[],

                               {dict,0,16,16,8,80,48,

                                     {[],[],[],[],[],[],[],[],[],[],[],[],[],

                                      [],[],[]},

                                     {{[],[],[],[],[],[],[],[],[],[],[],[],[],

                                       [],[],[]}}},

                               false,60,db,0}

** Reason for termination == 

** {{badmatch,["1"]},

    [{boss_db_adapter_mysql,infer_type_from_id,1},

     {boss_db_adapter_mysql,find,2},

     {boss_db_controller,handle_call,3},

     {gen_server,handle_msg,5},

     {proc_lib,init_p_do_apply,3}]}

-------------------------------------
以下错误是 由 modle变量 与数据库之间 一致造成的
=INFO REPORT==== 15-Mar-2012::18:37:22 ===
In elves_authorization:user_authorization on 25 line Base64="amFzb246MTIzNA==" ,
=ERROR REPORT==== 15-Mar-2012::18:37:22 ===
** Generic server <0.77.0> terminating 
** Last message in was {find,message,[],4,0,id,str_ascending}
** When Server state == {state,boss_db_adapter_mysql,<0.78.0>,[],
                               {dict,0,16,16,8,80,48,
                                     {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                      [],[],[]},
                                     {{[],[],[],[],[],[],[],[],[],[],[],[],[],
                                       [],[],[]}}},
                               false,60,db,0}
** Reason for termination == 
** {badarith,[{lists,nth,2},
              {boss_db_adapter_mysql,'-activate_record/3-fun-0-',4},
              {lists,map,2},
              {lists,map,2},
              {boss_db_adapter_mysql,activate_record,3},
              {lists,map,2},
              {boss_db_controller,handle_call,3},
              {gen_server,handle_msg,5}]}

=CRASH REPORT==== 15-Mar-2012::18:37:22 ===
  crasher:
    initial call: boss_db_controller:init/1
    pid: <0.77.0>
    registered_name: []
    exception exit: {badarith,
                        [{lists,nth,2},
                         {boss_db_adapter_mysql,'-activate_record/3-fun-0-',4},
                         {lists,map,2},
                         {lists,map,2},
                         {boss_db_adapter_mysql,activate_record,3},
                         {lists,map,2},
                         {boss_db_controller,handle_call,3},
                         {gen_server,handle_msg,5}]}
      in function  gen_server:terminate/6
    ancestors: [<0.64.0>,boss_db_pool,boss_db_sup,boss_web,boss_sup,
                  <0.58.0>]
    messages: []
    links: [<0.64.0>,<0.63.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 6765
    stack_size: 24
    reductions: 14142
  neighbours:

你可能感兴趣的:(数据库)