Hi!
I have this model:
-module(ngpw_user, [Id::integer(),
Email::string(),
Verified::boolean(),
Tainted::boolean(),
AuthenticationKey::binary(),
Salt::binary(),
LastLogin::date()]).
-columns([
{id, "id"}, % Bigserial
{email, "email"}, % citext
{verified, "verified"}, % bool
{tainted, "tainted"}, % bool
{authentication_key, "authentication_key"}, % bytea
{salt, "salt"}, % bytea
{last_login, "last_login"} % date
]).
-table("ngpw_users").
-compile(export_all).
I have created a table with the following code:
%% Migration: create_users_table
{create_users_table,
fun(up) -> boss_db:execute(<<"CREATE TABLE ngpw_users (id bigserial
primary key,email text not null,verified boolean default false,tainted
boolean default false,authentication_key bytea,salt bytea,last_login
date);">>),
boss_db:execute(<<"CREATE UNIQUE INDEX unique_email_on_ngpw_users ON
ngpw_users (email)">>);
(down) ->
boss_db:execute(<<"DROP INDEX unique_email_on_ngpw_users">>),
boss_db:execute(<<"DROP TABLE ngpw_users">>)
end}.
I create the record with:
{Date, _} = calendar:universal_time(),
ngpw_user:new(id,
Email,
false, % Verified
false, % Tainted
AuthKey,
Salt,
Date).
(Is there a better way to get the date? Is it possible to insert a null
value?)
But when I try to save the record I get:
05:13:27.377 [notice] Saving Record
{ngpw_user,id,"[email protected]",false,false,<<60,205,252,70,14,123,202,207,114,56,94,83,216,27,28,230,182,218,216,71,44,177,167,154,174,179,211,46,181,14,162,81,89,161,53,49,102,8,190,192,52,221,40,238,194,119,232,46,185,153,61,57,111,194,170,119,83,230,108,105,183,99,101,41>>,<<44,32,40,25,59,192,238,241,221,234,70,231,91,196,86,100>>,{2015,12,14}}
05:13:27.378 [error] gen_server <0.298.0> terminated with reason: no
function clause matching
boss_db_adapter_pgsql:maybe_populate_id_value({ngpw_user,id,"[email protected]",false,false,<<60,205,252,70,14,123,202,207,114,56,94,83,216,27,28,230,...>>,...},
integer) line 222
05:13:27.378 [error] CRASH REPORT Process <0.298.0> with 0 neighbours
exited with reason: no function clause matching
boss_db_adapter_pgsql:maybe_populate_id_value({ngpw_user,id,"[email protected]",false,false,<<60,205,252,70,14,123,202,207,114,56,94,83,216,27,28,230,...>>,...},
integer) line 222 in gen_server:terminate/7 line 826
05:13:27.378 [error] Supervisor {<0.98.0>,poolboy_sup} had child undefined
started with {boss_db_controller,start_link,undefined} at <0.298.0> exit
with reason no function clause matching
boss_db_adapter_pgsql:maybe_populate_id_value({ngpw_user,id,"[email protected]",false,false,<<60,205,252,70,14,123,202,207,114,56,94,83,216,27,28,230,...>>,...},
integer) line 222 in context child_terminated
05:13:27.379 [error] Error in controller exit:{{function_clause,
[{boss_db_adapter_pgsql,maybe_populate_id_value,
[{ngpw_user,id,"[email protected]",false,false,
<<60,205,252,70,14,123,202,207,114,56,94,83,216,27,28,230,
182,218,216,71,44,177,167,154,174,179,211,46,181,14,162,
81,89,161,53,49,102,8,190,192,52,221,40,238,194,119,232,
46,185,153,61,57,111,194,170,119,83,230,108,105,183,99,
101,41>>,
<<44,32,40,25,59,192,238,241,221,234,70,231,91,196,86,100>>,
{2015,12,14}},
integer],
[{file,"src/db_adapters/boss_db_adapter_pgsql.erl"},
{line,222}]},
{boss_db_adapter_pgsql,save_record,2,
[{file,"src/db_adapters/boss_db_adapter_pgsql.erl"},
{line,142}]},
{boss_db_controller,handle_call,3,
[{file,"src/boss_db_controller.erl"},{line,162}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,629}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,661}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]},
{gen_server,call,
[<0.298.0>,
{save_record,
{ngpw_user,id,"[email protected]",false,false,
<<60,205,252,70,14,123,202,207,114,56,94,83,216,27,28,230,
182,218,216,71,44,177,167,154,174,179,211,46,181,14,162,
81,89,161,53,49,102,8,190,192,52,221,40,238,194,119,232,
46,185,153,61,57,111,194,170,119,83,230,108,105,183,99,
101,41>>,
<<44,32,40,25,59,192,238,241,221,234,70,231,91,196,86,100>>,
{2015,12,14}}},
30000]}} Stacktrace:
gen_server.erl:212 [gen_server:call/3]
src/boss_pool.erl:12 [boss_pool:call/3]
src/boss_db.erl:421 [boss_db:save_record/2]
/vagrant/ngpwstore/src/lib/ngpw_user_lib.erl:23
[ngpw_user_lib:register_user/2]
/vagrant/ngpwstore/src/controller/ngpwstore_main_controller.erl:29
[ngpwstore_main_controller:signup/4]
src/boss/boss_web_controller.erl:305
[boss_web_controller:call_controller_action/3]
src/boss/boss_web_controller.erl:297 [boss_web_controller:apply_action/4]
src/boss/boss_web_controller.erl:276
[boss_web_controller:execute_action_inner/9]
05:13:27.380 [error] "Error in controller, see console.log for details\n"
05:13:27.381 [error] POST /signup [ngpwstore] 500 1252ms
05:13:27.541 [info] GET /404 [ngpwstore] 200 68ms
What am I doing wrong here?
By the way, I am using the latest version of Chicagoboss from the master
branch on github,
--
You received this message because you are subscribed to the Google Groups
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/chicagoboss.
To view this discussion on the web visit
https://groups.google.com/d/msgid/chicagoboss/c817de3c-7599-484b-93d3-3ab6029f30ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.