Skip to content


Support date type on mysql adapter #42

merged 1 commit into from

2 participants


Hi guys,

we're facing the case of having date types columns on our mysql schema.

We don't have a date type on boss_db , I guess because on erlang we deal only with datetimes and now-like structure.

Storing dates and query using them is working if you pad them as datetimes ({Date, {0,0,0}}) so no problem here.

The only problem is when you try to read or update an already present element that includes a date type row. We got something like that


I added support for this case so when we recover a date value from mysql db is gracefully translated to their datetime version.


Explicitly supporting a "date" type would be best so that it works with type-validation, but I guess this is a reasonable hack for now.

@evanmiller evanmiller merged commit e24727e into ErlyORM:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 17, 2012
  1. support for date types on mysql

    Dave Garcia committed
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/db_adapters/boss_db_adapter_mysql.erl
2 src/db_adapters/boss_db_adapter_mysql.erl
@@ -429,6 +429,8 @@ pack_value(V) when is_list(V) ->
"'" ++ escape_sql(V) ++ "'";
pack_value({MegaSec, Sec, MicroSec}) when is_integer(MegaSec) andalso is_integer(Sec) andalso is_integer(MicroSec) ->
pack_now({MegaSec, Sec, MicroSec});
+pack_value({date, Date = {_,_,_}}) ->
+ pack_datetime({Date,{0,0,0}});
pack_value({{_, _, _}, {_, _, _}} = Val) ->
pack_value(Val) when is_integer(Val) ->
Something went wrong with that request. Please try again.