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

Wrong test query in gpkgext_relations Relation Name? #643

Closed
phidrho opened this issue Nov 7, 2022 · 4 comments
Closed

Wrong test query in gpkgext_relations Relation Name? #643

phidrho opened this issue Nov 7, 2022 · 4 comments

Comments

@phidrho
Copy link

phidrho commented Nov 7, 2022

Hi,

if I understood text from Requirement 8 properly:

Each relation_name column in a gpkgext_relations row SHALL either match a relation_name from the Requirements Classes for User-Defined Related Data Tables in this or other OGC standards (e.g. media for [Media Requirement Class]), or be of the form x-_<relation_name> where indicates the person or organization that developed and maintains this set of User-Defined Related Tables.

Allowed relation_name are: 'features', 'simple_attributes', 'media', 'attributes', 'tiles', and custom name is optional, so test query in gpkgext_relations Relation Name should be changed from:

SELECT
    base_table_name,
    relation_name
FROM
    gpkgext_relations
WHERE
    (relation_name NOT IN ('features', 'simple_attributes', 'media')
    AND
    relation_name NOT LIKE 'x-%\_%' ESCAPE '\')

to:

SELECT
    base_table_name,
    relation_name
FROM
    gpkgext_relations
WHERE
    (relation_name NOT IN ('features', 'simple_attributes', 'media', 'attributes', 'tiles')
    OR
    relation_name NOT LIKE 'x-%\_%' ESCAPE '\')
@rouault
Copy link
Contributor

rouault commented Nov 10, 2022

I had proposed #631 some time ago regarding this

@phidrho
Copy link
Author

phidrho commented Nov 10, 2022

I had proposed #631 some time ago regarding this

Didn't see that, great!
Did I misunderstood test query or 'AND' should also be replaced with 'OR' inside WHERE clause.
Test is defined as 1. run a query, and 2. Fail if returns any rows.

@rouault
Copy link
Contributor

rouault commented Nov 10, 2022

Did I misunderstood test query or 'AND' should also be replaced with 'OR' inside WHERE clause.

the AND is correct AFAICS. A perhaps more natural, but equivalent way, would be to have the NOT as the topmost operator with OR inner it: NOT( relation_name IN ('features', 'simple_attributes', 'media', 'attributes', 'tiles') OR relation_name LIKE 'x-%\_%' ESCAPE '\' )

@phidrho
Copy link
Author

phidrho commented Nov 10, 2022

Did I misunderstood test query or 'AND' should also be replaced with 'OR' inside WHERE clause.

the AND is correct AFAICS. A perhaps more natural, but equivalent way, would be to have the NOT as the topmost operator with OR inner it: NOT( relation_name IN ('features', 'simple_attributes', 'media', 'attributes', 'tiles') OR relation_name LIKE 'x-%\_%' ESCAPE '\' )

Thanks, I just figured it out that with OR it would return other case in moment of testing (first or second).

@phidrho phidrho closed this as completed Nov 10, 2022
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