AmpersandTarski / Ampersand

Build database applications faster than anyone else, and keep your data pollution free as a bonus.
http://ampersandtarski.github.io/
GNU General Public License v3.0
40 stars 8 forks source link

Compile time restrictions w.r.t SESSION #1459

Open stefjoosten opened 6 months ago

stefjoosten commented 6 months ago

What happened

I got a run time error message immediately after deploying a script:

afbeelding

I was surprised because the compiler found my script correct and yet its deployment produces a database error. Since Ampersand must generate code that doesn't break, this is a bug.

Analysis

I made the script as small as I could, based on the assumption that there is something wrong with my use of "SESSION". This is the script:

CONTEXT Issue

RELATION link[SESSION*Link] [UNI]
POPULATION link[SESSION*Link] CONTAINS
   [ ("_SESSION","P0")
   ]

INTERFACE ShowAll : "_SESSION";I[SESSION] BOX
 [ Links : V[SESSION*Link] BOX
       [ Link : I
       , "Session (link~)" : link~
       ]
 , Sessions : V[SESSION] BOX
       [ Session : I
       , "Link (link)" : link
       ]
 ]

ENDCONTEXT

And this is what I saw:

afbeelding

Obviously, I should not have obtained a red error message because Ampersand must never generate software that breaks. So even though this error message looks different, it exposes some way of using SESSION that isn't kosher.

What I expected

In the small example, I expected to see the following

afbeelding

Version of ampersand that was used

Steps to reproduce

1. 2. 3. 4.

Screenshot / Video

Context / Source of ampersand script

hanjoosten commented 6 months ago

I was surprised because the compiler found my script correct and yet its deployment produces a database error. Since Ampersand must generate code that doesn't break, this is a bug.

The very first message warns you that there exists a database that was deployed based on another (version) of an ampersand script. It also warns you that that database has a different structure that the database that would be generated by your script. It is by design that Ampersand does not automatically delete that old database to be able to install a new one with the required structure. As a consequence, the old database is as is. In some cases you can be lucky, in other cases it might lead to errors. Like in this case.

The only way I see to avoid these bugs is to delete the old database instead of generating a warning. Since this can cause serious data loss, I think this is unacceptable. The current behavior, warn about the change of the structure and throwing an error with a suggestion to reinstall the database is in my opinion the best alternative. If you see this otherwise, feel free to reopen this issue and elaborate on your view.

stefjoosten commented 6 months ago

Han, your diagnosis misses the point. Please reconsider after rereading the issue. The minimized example demonstrates the bug.

hanjoosten commented 6 months ago

I cannot reproduce this error. Normally, when you see such red error, you can click on it and it reveals details, sometimes with valuable clues. Could you show these?