Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile time restrictions w.r.t SESSION #1459

Open
stefjoosten opened this issue Dec 23, 2023 · 3 comments
Open

Compile time restrictions w.r.t SESSION #1459

stefjoosten opened this issue Dec 23, 2023 · 3 comments

Comments

@stefjoosten
Copy link
Contributor

stefjoosten commented Dec 23, 2023

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

Screenshot / Video

Context / Source of ampersand script

@hanjoosten
Copy link
Member

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.

@hanjoosten hanjoosten closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2023
@stefjoosten stefjoosten reopened this Dec 26, 2023
@stefjoosten
Copy link
Contributor Author

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

@hanjoosten
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants