anchor.diff:  -module(sql_bridge_emysql).
   -behaviour(sql_bridge_adapter).
  +-include_lib("emysql/include/emysql.hrl").
  +-define(IS_DATE(Type), Type==?FIELD_TYPE_DATETIME orelse Type==?FIELD_TYPE_TIMESTAMP).
   
   -export([
   	start/0,
  
positive.code: format_key(K) when is_list(K) ->
      list_to_atom(K).
  
  -spec format_list_result(Stringify :: boolean(), Json :: sql_bridge:json()) -> [list()].
  format_list_result(Stringify, Json) ->
      [
          [format_value(Stringify, Value) || {_,Value} <- Row]
      || Row <- Json].
  
  -spec format_tuple_result(Stringify :: boolean(), Json :: json()) -> [tuple()].
  format_tuple_result(Stringify, Json) ->
      [list_to_tuple(Row) || Row <- format_list_result(Stringify, Json)].
  
  -spec format_proplist_result(Stringify :: boolean(), Json :: json()) -> [sql_bridge:proplist()].
  format_proplist_result(Stringify, Json) ->
      [
          [{format_key(F), format_value(Stringify, V)} || {F,V} <- Row]
      || Row <-Json].
  
  -spec format_dict_result(Stringify :: boolean(), Json :: json()) -> [sql_bridge:t_dict()].
  format_dict_result(Stringify, Json) ->
      [dict:from_list(PL) || PL <- format_proplist_result(Stringify, Json)].
  
  -spec format_map_results(Stringify :: boolean(), Json :: json()) -> [map()].
  format_map_results(Stringify, Json) ->
      [maps:from_list(PL) || PL <- format_proplist_result(Stringify, Json)].
  
  schema_db_column() ->
  	"table_schema".
  
  format_value(_, null) ->
  	undefined;
  format_value(true, V) when is_binary(V) ->
  	sql_bridge_utils:binary_to_string(V);
  format_value(_, V) when is_tuple(V) ->
      sql_bridge_utils:format_datetime(V);
  format_value(_, V) ->
      V.
  
  -spec encode(V :: any()) -> binary().
  
negative.code: %% @doc Format the results from emysql as a list of Types
  format_result(Type,Res) ->
      Json = emysql:as_json(Res),
      Fields = get_field_types(Res),
      DateFields = [?IS_DATE(F) || F <- Fields],
  	Stringify = sql_bridge_utils:stringify_binaries(),
      case Type of
          list ->
              format_list_result(DateFields, Stringify, Json);
          tuple ->
              format_tuple_result(DateFields, Stringify, Json);
          proplist ->
              format_proplist_result(DateFields, Stringify, Json);
          dict ->
              format_dict_result(DateFields, Stringify, Json);
  		map ->
  			format_map_results(DateFields, Stringify, Json)
      end.
  
  get_field_types(#result_packet{field_list=Fs}) ->
      [F#field.type || F <- Fs].
  
  -spec format_key(K :: sql_bridge:field()) -> atom().
  %% @doc Normalize field values into atoms
  