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

Error in the operator # #1460

Open stefjoosten opened 6 months ago

stefjoosten commented 6 months ago

What happened

I noticed that

RELATION r[A*B]
ENFORCE r := I[A]#"foo"

has a different semantics than

RELATION r[A*B]
ENFORCE r := V[A*B]#"foo"

If I test this with the following population:

POPULATION A CONTAINS [ "1", "2", "3" ]
POPULATION B CONTAINS [ "foo", "bar", "gnu" ]

I see that the expression I[A]#"foo" yields [("1","foo"),("1","bar"),("1","gnu"),("2","foo"),("2","bar"),("2","gnu"),("3","foo"),("3","bar"),("3","gnu")]. Yet, the expression V[A*B]#"foo" yields [("1","foo"),("2","foo"),("3","foo")].

What I expected

I expected the result to be the same, i.e. [("1","foo"),("2","foo"),("3","foo")], in both cases to comply with the definition of #.

Version of ampersand that was used

I used a dockerfile FROM ampersandtarski/prototype-framework:v1.14

Steps to reproduce

  1. Run the script below as a prototype (e.g. in https://rap.cs.ou.nl) and observe the results for the term V[A*B]#"foo".
  2. Move the comment, rerun, and observe the results for the term I[A]#"foo".

Screenshot / Video

Context / Source of ampersand script

CONTEXT Issue1460

RELATION r[A*B]
-- ENFORCE r := I[A]#"foo"
ENFORCE r := V[A*B]#"foo"

POPULATION A CONTAINS [ "1", "2", "3" ]
POPULATION B CONTAINS [ "foo", "bar", "gnu" ]

INTERFACE ShowAll : "_SESSION";I[SESSION] BOX
 [ As : V[SESSION*A] BOX
       [ A : I
       , "B (r)" : r
       ]
 , Bs : V[SESSION*B] BOX
       [ B : I
       , "A (r~)" : r~
       ]
 ]

ENDCONTEXT