Allow raw constraints for tables as well

This commit is contained in:
Alexey Romanov
2014-10-10 10:35:31 +04:00
parent 9b9448dcdd
commit d125bcba07
2 changed files with 3 additions and 2 deletions

View File

@@ -1232,7 +1232,7 @@ list_init([H|T]) -> [H|list_init(T)].
%% @type pk_constraints() = pk_constraint() | [pk_constraint()]. %% @type pk_constraints() = pk_constraint() | [pk_constraint()].
%% See {@link column_constraint()}. %% See {@link column_constraint()}.
%% @type column_constraint() = non_null | primary_key | {primary_key, pk_constraints()} %% @type column_constraint() = non_null | primary_key | {primary_key, pk_constraints()}
%% | unique | {default, sql_value()}. %% | unique | {default, sql_value()} | {raw, string()}.
%% See {@link column_constraints()}. %% See {@link column_constraints()}.
%% @type column_constraints() = column_constraint() | [column_constraint()]. %% @type column_constraints() = column_constraint() | [column_constraint()].
%% See {@link table_info()}. %% See {@link table_info()}.
@@ -1241,7 +1241,7 @@ list_init([H|T]) -> [H|list_init(T)].
%% Describes the columns of an SQLite table: each tuple contains name, type and constraints (if any) %% Describes the columns of an SQLite table: each tuple contains name, type and constraints (if any)
%% of one column. %% of one column.
%% @end %% @end
%% @type table_constraint() = {primary_key, [atom()]} | {unique, [atom()]}. %% @type table_constraint() = {primary_key, [atom()]} | {unique, [atom()]} | {raw, string()}.
%% @type table_constraints() = table_constraint() | [table_constraint()]. %% @type table_constraints() = table_constraint() | [table_constraint()].
%% %%
%% Currently supported constraints for {@link table_info()} and {@link sqlite3:create_table/4}. %% Currently supported constraints for {@link table_info()} and {@link sqlite3:create_table/4}.

View File

@@ -378,6 +378,7 @@ table_constraint_sql(TableConstraint) ->
["UNIQUE(", ["UNIQUE(",
map_intersperse(fun indexed_column_sql/1, Columns, ", "), ")"]; map_intersperse(fun indexed_column_sql/1, Columns, ", "), ")"];
%% TODO: foreign key %% TODO: foreign key
{raw, S} when is_list(S) -> S;
_ when is_list(TableConstraint) -> _ when is_list(TableConstraint) ->
map_intersperse(fun table_constraint_sql/1, TableConstraint, ", ") map_intersperse(fun table_constraint_sql/1, TableConstraint, ", ")
end. end.