From d125bcba07b07c2ed6df2f0d1d3418d06e3fcd05 Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Fri, 10 Oct 2014 10:35:31 +0400 Subject: [PATCH] Allow raw constraints for tables as well --- src/sqlite3.erl | 4 ++-- src/sqlite3_lib.erl | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sqlite3.erl b/src/sqlite3.erl index ff0972e..4b998bb 100644 --- a/src/sqlite3.erl +++ b/src/sqlite3.erl @@ -1232,7 +1232,7 @@ list_init([H|T]) -> [H|list_init(T)]. %% @type pk_constraints() = pk_constraint() | [pk_constraint()]. %% See {@link column_constraint()}. %% @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()}. %% @type column_constraints() = column_constraint() | [column_constraint()]. %% 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) %% of one column. %% @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()]. %% %% Currently supported constraints for {@link table_info()} and {@link sqlite3:create_table/4}. diff --git a/src/sqlite3_lib.erl b/src/sqlite3_lib.erl index 970a5b8..7a4aa6a 100644 --- a/src/sqlite3_lib.erl +++ b/src/sqlite3_lib.erl @@ -378,6 +378,7 @@ table_constraint_sql(TableConstraint) -> ["UNIQUE(", map_intersperse(fun indexed_column_sql/1, Columns, ", "), ")"]; %% TODO: foreign key + {raw, S} when is_list(S) -> S; _ when is_list(TableConstraint) -> map_intersperse(fun table_constraint_sql/1, TableConstraint, ", ") end.