From d75de5821ebc7da77edd3178ba87f48a783790cf Mon Sep 17 00:00:00 2001 From: Mathias Franck Date: Tue, 26 Apr 2016 14:49:18 +0200 Subject: [PATCH] Optional configuration of the module for DB driver overriding the one computed from URI scheme --- src/texas.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/texas.erl b/src/texas.erl index ae8e25c..50fca34 100644 --- a/src/texas.erl +++ b/src/texas.erl @@ -54,6 +54,19 @@ start() -> _ -> ok end. + +% @doc +% Finds the suited driver module, +% from scheme naming, or from texas config. +% @end +scheme_to_module(Scheme) -> + case doteki:get_env([texas, driver_module], undefined) of + undefined -> + list_to_atom("texas_" ++ Scheme); + Mapped -> + Mapped + end. + % @doc % Connect to the database. % @end @@ -71,7 +84,7 @@ connect(URI) -> connect(URI, Options) -> case texas_uri:parse(URI) of {ok, {Scheme, User, Password, Server, Port, Path, Params, Fragment}} -> - Module = list_to_atom("texas_" ++ Scheme), + Module = scheme_to_module(Scheme), case erlang:apply(Module, start, []) of ok -> case code:ensure_loaded(Module) of