From 830cac6e18c752574685e37d79079bc67e9606c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ska=C5=82acki?= Date: Fri, 21 Nov 2014 17:59:37 +0100 Subject: [PATCH] Table_exists: expect table name, not model name 1. Make API compatible with PostgreSQL adapter 2. Make it working when called with schema_migrations 3. It generally makes more sense to work with SQL table names, models can be renamed or deleted which would break old migrations. --- src/db_adapters/boss_db_adapter_mysql.erl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/db_adapters/boss_db_adapter_mysql.erl b/src/db_adapters/boss_db_adapter_mysql.erl index e1fe7cf0..62eba8a5 100644 --- a/src/db_adapters/boss_db_adapter_mysql.erl +++ b/src/db_adapters/boss_db_adapter_mysql.erl @@ -100,10 +100,9 @@ count(Pid, Type, Conditions) -> {error, MysqlRes} -> {error, mysql:get_result_reason(MysqlRes)} end. - -table_exists(Pid, Type) -> - TableName = boss_record_lib:database_table(Type), - Res = fetch(Pid, ["SELECT 1 FROM ", TableName," LIMIT 1"]), + +table_exists(Pid, TableName) when is_atom(TableName) -> + Res = fetch(Pid, ["SELECT 1 FROM ", atom_to_list(TableName)," LIMIT 1"]), case Res of {updated, _} -> ok;