Skip to content

Conversation

@gacarrillor
Copy link
Member

@gacarrillor gacarrillor commented Oct 30, 2025

From DbConnector.get_bags_of_info() we now get an additional field that allows us to differentiate the type of mapping being used. It can be an empty string if no mapping is present.

  • PostGIS
  • GeoPackage

Includes tests.

Fix opengisch/QgisModelBaker#1082


Note that this does not include the corresponding fix for ili2db v3.

@gacarrillor gacarrillor force-pushed the fix_suppress_bag_of_catalogue branch from 8d6988d to 09ed6a4 Compare October 30, 2025 22:43
@gacarrillor gacarrillor marked this pull request as ready for review October 30, 2025 23:18
@gacarrillor gacarrillor requested a review from signedav October 30, 2025 23:22
Copy link
Member

@signedav signedav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I don't really get it yet. Maybe you can help me with some comments. I expected it to be simpler, but I guess I don't see all the impacts...

ON LOWER(meta_attrs_cardinality_min.ilielement) = LOWER(cname.iliname||'.'||cprop.columnname) AND meta_attrs_cardinality_min.attr_name = 'ili2db.ili.attrCardinalityMin'
LEFT JOIN T_ILI2DB_META_ATTRS as meta_attrs_cardinality_max
ON LOWER(meta_attrs_cardinality_max.ilielement) = LOWER(cname.iliname||'.'||cprop.columnname) AND meta_attrs_cardinality_max.attr_name = 'ili2db.ili.attrCardinalityMax'
WHERE cprop.tag = 'ch.ehi.ili2db.foreignKey' AND meta_attrs_array.attr_value = 'ARRAY'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I don't understand is, why it was not sufficient just to return the meta_attrs_array.attr_value as mapping_type and then check it in the suppress_catalogue_reference_layers? Why is the union select needed?

Copy link
Member Author

@gacarrillor gacarrillor Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair question, taking e.g., KbS_LV95_V1_3 model from tests:

  • Just returning meta_attrs_array.attr_value as mapping_type and commenting mapping=ARRAY in WHERE:

    • 19 rows returned. I think the other relations are also included.
    • Only the rows with mapping=ARRAY have proper cardinality, the rest has NULL values for cardinalities.
  • Using the UNION ALL :

    • 4 rows returned. One per BAG OF in the model.
    • Each row includes proper cardinality.

Nonetheless, I guess the UNION ALL query looks a bit harder to maintain. I'm reverting to keep it simple.

@gacarrillor
Copy link
Member Author

@signedav, marking as draft since I prepare some changes here, thanks for the review!

@gacarrillor gacarrillor marked this pull request as draft November 2, 2025 03:01
@gacarrillor gacarrillor changed the title Proper discovery of BAGs OF, even if no mapping meta attr is present Discovery of BAGs OF: take into account BAGs OF when no mapping meta attr is present Nov 6, 2025
@gacarrillor gacarrillor force-pushed the fix_suppress_bag_of_catalogue branch from e64a317 to b61de32 Compare November 6, 2025 02:02
@gacarrillor gacarrillor marked this pull request as ready for review November 6, 2025 02:28
@gacarrillor
Copy link
Member Author

@signedav, I've added a commit on top, reverting to the original simple SQL query (tweaked).

I've added two custom pytest marks so that we can filter bag_of, or catalogue related tests easily. This needed a pytest.ini file to register the custom marks.

If we agree on merging it, we should squash commits, since the first ones have been reverted.

Copy link
Member

@signedav signedav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. Some suggestions. But otherwise good to merge...

@signedav signedav self-requested a review November 6, 2025 11:28
@signedav signedav merged commit dd3cce1 into main Nov 7, 2025
5 checks passed
@signedav signedav deleted the fix_suppress_bag_of_catalogue branch November 7, 2025 08:02
@signedav
Copy link
Member

signedav commented Nov 7, 2025

Forgot to squash like you intended. Sorry.

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

Successfully merging this pull request may close these issues.

Filtering out BAG OF Catalogue Relations

3 participants