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

Multiple records in the wide table for a single atom. #1274

Closed stefjoosten closed 2 years ago

stefjoosten commented 2 years ago

What happened

During my work for the emergency centers, I encountered a strange phenomenon, which I have never seen before. The following screenshot shows that some atoms of type "Voorziening" have multiple records in the database. Not surprisingly, this affects the behaviour of the application in many undesirable ways. Here is screenshot 1. Screenshot 2022-01-26 at 07 16 19

What I expected

Screenshot 2 shows what I expected: Screenshot 2022-01-26 at 07 33 40

Version of ampersand that was used

I used container images ampersandtarski/prototype-framework:v1.13.0 and ampersandtarski/ampersand:v4.6.2, both of which are on docker hub.

Steps to reproduce Screenshot 1

  1. Compile the application without the spreadsheet
  2. Start the application and install the database
  3. Load the spreadsheet in the population importer
  4. Inspect the database

Steps to reproduce Screenshot 2

  1. Compile the same application with the spreadsheet in an INCLUDE-statement
  2. Start the application and install the database
  3. Inspect the database

Context / Source of ampersand script

I will have to put some effort into making this issue reproducible. The symptoms clearly point a finger towards the population importer, so I hope @Michiel-s already has a hunch about possible causes in a quest to find the root cause.

Michiel-s commented 2 years ago

Hi @stefjoosten can you exclude the possibility that one of the two has trailing whitespace?

hanjoosten commented 2 years ago

Yes, that is excluded. @stefjoosten has shown me what was going on. There were quite a few different instances that had this.

Michiel-s commented 2 years ago

Ok. I'll have a look at it this weekend. Could you email me the test population.

Michiel-s commented 2 years ago

Before I can work with the files you've sent me, I need to fix some issue:

You should use the exec-engine SetConcept instead of InsAtom for changing atom types, e.g.:

RULE "Typering van Videobronnen" :
  I[Beheerseenheid] /\ voorzieningtype;"Videobron"; voorzieningtype~ |- I[Videobron]
VIOLATION (TXT "{EX} InsAtom;Videobron;", SRC I[Beheerseenheid])

must be:

RULE "Typering van Videobronnen" :
  I[Beheerseenheid] /\ voorzieningtype;"Videobron"; voorzieningtype~ |- I[Videobron]
VIOLATION (TXT "{EX} SetConcept;Beheerseenheid;Videobron;", SRC I[Beheerseenheid])
Michiel-s commented 2 years ago

Ok, now I can conclude that it is a whitespace issue.

Please check the excel sheet and notice that e.g. Ambulance voorziening has 9 trailing whitespaces at most places, but 20 trailing whitespaces at the sheet Voorziening.

The prototype framework works as expected, it just see those as two different atoms; as it should in my opinion.

So clean up the import sheet and you are good to go.

Michiel-s commented 2 years ago

Yes, that is excluded. @stefjoosten has shown me what was going on. There were quite a few different instances that had this.

What made you think so @hanjoosten?

hanjoosten commented 2 years ago

Sorry @Michiel-s . @stefjoosten and I had a joint session looking into this issue. Because there were more than multiple different words that had this issue, we convinsed each other that it couldn't be a whitespace problem. I should have known better image

Michiel-s commented 2 years ago

No worries. Just asking.