Skip to content

Commit

Permalink
Table_exists: expect table name, not model name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
skalee committed Nov 21, 2014
1 parent 58f975e commit 830cac6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/db_adapters/boss_db_adapter_mysql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 830cac6

Please sign in to comment.