claeis / ili2db

interlis import/export to relational databases
30 stars 30 forks source link

Error using a catalogue and ili2db.mapping="ARRAY" meta-attribute #438

Open gacarrillor opened 2 years ago

gacarrillor commented 2 years ago

Is there any technical impediment for the following scenario?

  1. Define a catalogue in a model.
  2. Define a field referencing the catalogue.
  3. Define a BAG {0..*} OF for the field.
  4. Use ili2db.mapping="ARRAY" meta-attribute for such a field.

Scenarios 1 to 3 seem to work as expected, but as soon as I add the aforementioned meta-attribute, I get the following error in the schema import:

mapping of ili-classes to sql-tables failed
mapping of Errores_Calidad_V0_1.Topic_Errores.Metadatos failed 
   Errores_Calidad_V0_1.Topic_Errores.Metadatos.Reglas_Validadas
unexpected attr type Errores_Calidad_V0_1.Catalogos_Errores.TipoReglaRef.Reference

Let me know if you need more details.

edigonzales commented 2 years ago

The attribute must follow some conditions:

The second condition is obsolete if you use ili2db.mapping="JSON".

gacarrillor commented 2 years ago

Thank you Stefan, however, I've been unable to achieve it.

I verified my attribute (see point 2. in the first message of this thread) was of type structure and pointed to the catalogue, but this didn't work.

I also created a structure pointing to the catalog and then made my attribute point to the structure instead of pointing to the catalog. This also didn't work.

I obtained this error (note the attribute points now to a structure and the structure has a single attribute called TipoRegla pointing to the catalog):

mapping of ili-classes to sql-tables failed
  mapping of Errores_Calidad_V0_1.Topic_Errores.Metadatos failed
    Errores_Calidad_V0_1.Topic_Errores.Metadatos.Reglas_Validadas
      unexpected attr type Errores_Calidad_V0_1.Catalogos_Errores.TipoReglaEstructura.TipoRegla

For reference, this is the scenario (Reglas is the attribute I'd like to be stored as an array of TipoRegla):

image

And this is a simplified .ili model to replicate the issue:

Modelos_Errores_y_Excepciones.zip

What I intend to do is actually possible for catalogues or is not supported?

romefi commented 2 years ago

We stumbled over the same problem with the model Test.zip

It would be very chic if ili2db would support ARRAYS with catalogues in order to use it with QGIS Model Baker. Now we're asking ourselfes if it's a bug of ili2db (Error: mapping of ili-classes to sql-tables failed) or if it's just not possible to integrate ARRAYS and catalogues with ili2db. Which would lead to the question, if ili2db could be enhanced in this direction, that this would be possible.

claeis commented 2 years ago

This (Array of Reference) is not (yet) supported (but is implementable)