laowantong / mocodo

Modélisation Conceptuelle de Données. Nickel. Ni souris.
https://www.mocodo.net
MIT License
181 stars 49 forks source link

MCD cleared bug when rearranging MCD #50

Closed mrm-david closed 2 years ago

mrm-david commented 4 years ago

The following MCD creates a bug when clicking on Réarranger: The error is

Mocodo Err.4 - Le MCD est vide.

If I ALT-click, rearrange works.

%%mocodo
ordered by, 0N clients, 11 orders
orders: order, client_ord, client_inv,client_del, date_ord
has, 1N orders, 11 lines
lines: order, num_line, ref, qty

clients: client, name
deliver to, 0N clients, 11 orders
:
manufactures, 1N lines, 11 ofs

::
invoiced to, 0N clients, 11 orders
ofs: of, order, num_line
laowantong commented 4 years ago

Yes, I can reproduce it, it's strange. Clicking on Rearrange rewrites the MCD as:

%%mocodo
ordered by, 0N clients, 11 orders
orders: order, client_ord, client_inv,client_del, date_ord
has, 1N orders, 11 lines

lines: order, num_line, ref, qty
clients: client, name
deliver to, 0N clients, 11 orders

manufactures, 1N lines, 11 ofs
invoiced to, 0N clients, 11 orders
ofs: of, order, num_line

And, after a few seconds, clears it up. This may be a bug in the web version, since it works under Jupyter Notebook:

%%mocodo --arrange
...

Thanks for the report.

laowantong commented 2 years ago

In fact, this can be reproduce with any non planar MCD, e.g. K33:

DIGNISSIM: nec sem, nunc, vulputate
IMPERDIET: a praesent, nibh, semper
TINCIDUNT: faucibus, orci, cursus

RHONCUS, 1N DIGNISSIM, 1N IMPERDIET, 1N TINCIDUNT
SODALES, 1N DIGNISSIM, 1N IMPERDIET, 1N TINCIDUNT
QUIS ENIM, 1N DIGNISSIM, 1N IMPERDIET, 1N TINCIDUNT

image

In Mocodo online (up to 2.3.9), trying to arrange a non planar MCD fails (which is normal) and clears the input text (which is a bug). The next version (3.0, WIP) will both display the expected error message and preserve the input text.


Note: since your MCD is planar, you may wonder why it triggers the same bug. In fact, clicking on the "shuffle" icon has two effects. First, it fits your MCD in the smallest balanced grid, in your case 3 x 3:

%%mocodo
ordered by, 0N clients, 11 orders
orders: order, client_ord, client_inv,client_del, date_ord
has, 1N orders, 11 lines

lines: order, num_line, ref, qty
clients: client, name
deliver to, 0N clients, 11 orders

manufactures, 1N lines, 11 ofs
invoiced to, 0N clients, 11 orders
ofs: of, order, num_line

Second, it tries to find a planar layout on this constrained grid, which may actually be impossible. This explains why clicking doesn't work (it triggers the clearing bug) although alt-clicking does (it finds a non-constrained planar layout).