Commit 742b83bc authored by Thierry Martinez's avatar Thierry Martinez

Tables

parent c25dc2eb
...@@ -684,7 +684,7 @@ delete_item(Id) :- ...@@ -684,7 +684,7 @@ delete_item(Id) :-
retractall(annotation(Id, _KindAnnotation, _Annotation)), retractall(annotation(Id, _KindAnnotation, _Annotation)),
retractall(listed_item(_Index, Id)), retractall(listed_item(_Index, Id)),
retractall(dependency(Id, _Master)), retractall(dependency(Id, _Master)),
retract_all(at_delete_goal(Id, _Goal)), retractall(at_delete_goal(Id, _Goal)),
\+ ( \+ (
item(SubId, Id, _SubKind, _SubItem), item(SubId, Id, _SubKind, _SubItem),
\+ ( \+ (
......
...@@ -144,6 +144,7 @@ delete_column(Columns) :- ...@@ -144,6 +144,7 @@ delete_column(Columns) :-
; ;
find_item([parent: Id, kind: column, item: Column, id: ColumnId]) find_item([parent: Id, kind: column, item: Column, id: ColumnId])
), ),
print(ColumnId), nl,
delete_item(ColumnId) delete_item(ColumnId)
) )
). ).
...@@ -180,7 +181,7 @@ add_table(Name, Table) :- ...@@ -180,7 +181,7 @@ add_table(Name, Table) :-
-> ->
declare_column(Id, 0, FirstColumnName), declare_column(Id, 0, FirstColumnName),
\+ ( \+ (
nth1(ColumnIndex, OtherColumns, ColumnName), nth0(ColumnIndex, OtherColumns, ColumnName),
\+ ( \+ (
declare_column(Id, ColumnIndex, ColumnName) declare_column(Id, ColumnIndex, ColumnName)
) )
...@@ -236,12 +237,13 @@ perform_column_delete(Id, ColumnIndex) :- ...@@ -236,12 +237,13 @@ perform_column_delete(Id, ColumnIndex) :-
( (
get_annotation(Id, data, Data) get_annotation(Id, data, Data)
-> ->
print(ColumnIndex), nl,
findall( findall(
NewRow, NewRow,
( (
member(Row, Data), member(Row, Data),
Row =.. [row, RowItems], Row =.. [row, RowItems],
nth1(ColumnIndex, RowItems, _Deleted, NewRowItems), nth0(ColumnIndex, RowItems, _Deleted, NewRowItems),
NewRow =.. [row, NewRowItems] NewRow =.. [row, NewRowItems]
), ),
NewData NewData
......
...@@ -18,4 +18,13 @@ test( ...@@ -18,4 +18,13 @@ test(
add_table(table, [row(50, 50)]), add_table(table, [row(50, 50)]),
get_table_data(Data). get_table_data(Data).
test(
'delete_column',
[true(Data == [row(10, 30), row(40, 60)])]
) :-
clear_model,
add_table(table, [row(10, 20, 30), row(40, 50, 60)]),
command(delete_column(1)),
get_table_data(Data).
:- end_tests(tables). :- end_tests(tables).
...@@ -112,7 +112,9 @@ command(Command) :- ...@@ -112,7 +112,9 @@ command(Command) :-
Command0 = Command Command0 = Command
; ;
between(1, Arity, Arity0), between(1, Arity, Arity0),
predicate_info(Functor/Arity0, ArgumentTypes, variantargs, _) print(Functor/Arity0),
predicate_info(Functor/Arity0, ArgumentTypes, variantargs, _),
print(variantargs)
-> ->
Command =.. [Functor | Arguments], Command =.. [Functor | Arguments],
PrefixLength is Arity0 - 1, PrefixLength is Arity0 - 1,
......
...@@ -27,6 +27,7 @@ predicate_info((Head :- Body), ArgumentTypes, BiochamCommand, Doc) :- ...@@ -27,6 +27,7 @@ predicate_info((Head :- Body), ArgumentTypes, BiochamCommand, Doc) :-
predicate_info(Functor/Arity, ArgumentTypes, BiochamCommand, Doc) :- predicate_info(Functor/Arity, ArgumentTypes, BiochamCommand, Doc) :-
functor(Head, Functor, Arity), functor(Head, Functor, Arity),
once(clause(Head, Body)), once(clause(Head, Body)),
print(found),
predicate_info((Head :- Body), ArgumentTypes, BiochamCommand, Doc). predicate_info((Head :- Body), ArgumentTypes, BiochamCommand, Doc).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment