Skip to content

Commit

Permalink
Added additional string to configure update/delete actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Metz committed Jan 26, 2024
1 parent 15eaabe commit 5703b04
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/sqlite3.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
-type column_constraint() :: non_null | primary_key | {primary_key, pk_constraints()}
| unique | {default, sql_value()}.
-type column_constraints() :: column_constraint() | [column_constraint()].
-type table_constraint() :: {primary_key, [atom()]} | {foreign_key, {[atom()], atom(), [atom()]}} | {unique, [atom()]}.
-type table_constraint() :: {primary_key, [atom()]} | {foreign_key, {[atom()], atom(), [atom()], string()}} | {unique, [atom()]}.
-type table_constraints() :: table_constraint() | [table_constraint()].
-type table_info() :: [{column_id(), sql_type()} | {column_id(), sql_type(), column_constraints()}].

Expand Down
5 changes: 3 additions & 2 deletions src/sqlite3_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,15 @@ table_constraint_sql(TableConstraint) ->
{unique, Columns} ->
["UNIQUE(",
map_intersperse(fun indexed_column_sql/1, Columns, ", "), ")"];
{foreign_key, {Columns, Parent, ParentColumns}} ->
{foreign_key, {Columns, Parent, ParentColumns, Action}} ->
["FOREIGN KEY(",
map_intersperse(fun indexed_column_sql/1, Columns, ", "),
") REFERENCES ",
atom_to_list(Parent),
"(",
map_intersperse(fun indexed_column_sql/1, ParentColumns, ", "),
")"];
")",
Action];
{raw, S} when is_list(S) -> S;
_ when is_list(TableConstraint) ->
map_intersperse(fun table_constraint_sql/1, TableConstraint, ", ")
Expand Down

0 comments on commit 5703b04

Please sign in to comment.