[QGIS-Developer] duplicate oracle views displayed in the layer list

Julien Cabieces julien.cabieces at oslandia.com
Mon Oct 4 22:44:21 PDT 2021


Hi,

I take a quick look and there is something to be improved in data source
manager [1]. Could you open an issue? I'll fix it when I get a
bit of time.

Though, if you select your layer from browser and add it directly (not
going through data source manager), the primary keys will be
autmatically detected.

Kind regards,
Julien

[1] https://github.com/qgis/QGIS/blob/master/src/providers/oracle/qgsoraclesourceselect.cpp#L79


> Hello,
>
> Thanks for your feedback. Is this PR integrated in qgis 3.16.9? I guess it is but I am not 100% sure.
>
> I took your unit test in order to test if the PR was working. But the result is still the same. My QGIS can't figure out what is the primary key of the view whereas Qgis can manage to detect the primary key on the table.
>
> Here is my sql script:
>
> CREATE TABLE "ATLAS"."TABLE_TESTPKS" (pk1 INTEGER, DESCRIPTION VARCHAR2(25), pk2 NUMBER, CONSTRAINT cons_pk PRIMARY KEY(pk1, pk2));
> INSERT INTO ALTAS.TABLE_TESTPKS VALUES(1000,'Desc for 1st record', 1);
> INSERT INTO ATLAS.TABLE_TESTPKS VALUES(2000,'Desc for 2nd record', 2);
> CREATE OR REPLACE VIEW "ATLAS"."VIEW_TESTPKS" AS SELECT * FROM ATLAS.TABLE_TESTPKS;
> COMMIT;
> ALTER VIEW ATLAS.VIEW_TESTPKS ADD CONSTRAINT const_view_pks PRIMARY KEY (pk1,pk2) DISABLE;
>
> I also tried with only one primary key on the view:
>
> CREATE TABLE "ATLAS"."TABLE_TESTPKS3" (pk1 INTEGER, DESCRIPTION VARCHAR2(25), pk2 NUMBER, CONSTRAINT cons_pk3 PRIMARY KEY(pk1, pk2));
> COMMIT;
> INSERT INTO TABLE_TESTPKS3 VALUES(1000,'Desc for 1st record', 1);
> INSERT INTO ATLAS.TABLE_TESTPKS3 VALUES(2000,'Desc for 2nd record', 2);
> CREATE OR REPLACE VIEW "ATLAS"."VIEW_TESTPKS3" AS SELECT * FROM ATLAS.TABLE_TESTPKS3 ;
> COMMIT;
> ALTER VIEW ATLAS.VIEW_TESTPKS3 ADD CONSTRAINT const_view_pks3 PRIMARY KEY (pk1) DISABLE;
>
>
> Then for both, I checked in the layer manager if qgis can recognize the id but qgis still offer me the possibility to define the primary key.
>
> Should open an issue? Or something is wrong in my way to test qgis?
>
> Jonathan
>
>
>
>
>
>
>
> -----Message d'origine-----
> De : Julien Cabieces <julien.cabieces at oslandia.com>
> Envoyé : lundi 4 octobre 2021 10:16
> À : Piraux Jonathan <jonathan.piraux at sibelga.be>
> Cc : qgis-developer at lists.osgeo.org
> Objet : Re: [QGIS-Developer] duplicate oracle views displayed in the layer list
>
>
> Hi,
>
> Regarding the primary key in disabled mode, it should work since this
> PR: https://smex-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fqgis%2fQGIS%2fpull%2f35112&umid=0b5dbc0e-6bdc-453a-91ec-8a660054db2a&auth=7f6fc31f18215669cf004d4797887d3e13de5b8d-c69e27dc0d3ac43d988d40510ffd17c7f0be14f0
>
> Take a look about the test requests in the PR, maybe it'll give you an hint about why it doesn't work on your side.
>
> If not, could you please open an issue here: https://smex-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fqgis%2fQGIS%2fissues%2f&umid=0b5dbc0e-6bdc-453a-91ec-8a660054db2a&auth=7f6fc31f18215669cf004d4797887d3e13de5b8d-5948a851307fe8df3701542c3952384de944f1c0
>
> Kind regards,
> Julien
>
>> Hello,
>>
>> I can't figure out how I should configure my oracle db to avoid qgis to duplicate oracle views in the layer manager. Like shown in the following link:
>>
>> https://i.stack.imgur.com/esjuI.png
>>
>> On this image we can see that all oracle views are displayed 3 times:
>>
>>
>>   *   Once as an attribute table
>>   *   Once as a layer with a known primary key
>>   *   Once as a layer without a known primary key
>>
>> I though that the issue was link to the fact that the views had no primary keys. This as I saw in the oracle provider code (qgsoracleprovider.cpp)  that there is logic to select a column of the view/table that could be a primary key.
>>
>> Therefore, I tried to set a primary key on one view as Oracle allows it (in disabled mode). But without any success.
>>
>> As any one a suggestion? An idea how I could correctly define my oracle views?
>>
>> I am using Qgis 3.16.9
>>
>> Thanks
>>
>> Jonathan
>>
>>
>>
>>
>>
>>
>>
>>
>> Disclaimer
>>
>> Le pr?sent courriel ainsi que ses annexes ?ventuelles peuvent contenir des informations confidentielles et/ou prot?g?es par des droits de propri?t? intellectuelle et sont destin?s ? l'usage exclusif du (des) destinataire(s) susmentionn?(s). Toute utilisation - notamment, mais non exclusivement, pour la reproduction, la communication ou la distribution totale ou partielle sous quelque forme que ce soit - de leur contenu par des personnes autres que le(s) destinataire(s) d?sign?(s) est interdite. Si vous avez re?u ce courriel par erreur, veuillez en informer l'exp?diteur soit par t?l?phone soit par courriel, et supprimer de tout ordinateur les donn?es y aff?rentes. Merci de votre collaboration. En d?pit des pr?cautions prises, des courriels peuvent ?tre intercept?s, modifi?s, perdus, d?truits ou contenir des virus. Nous d?clinons toute responsabilit? quant aux ?ventuels dommages ?ventuellement caus?s dans cette ?ventualit?. Toute personne qui communique avec SIBELGA par courriel est suppos?e accepter ce risque.
>>
>> Deze mail en zijn eventuele bijlagen kunnen informatie bevatten die vertrouwelijk is en/of beschermd door intellectuele-eigendomsrechten en zijn bestemd voor exclusief gebruik door voormelde geadresseerde(n). Elk gebruik - onder meer, maar niet exclusief, voor volledige of gedeeltelijke reproductie, communicatie of distributie, onder welke vorm ook - van de inhoud ervan door andere personen dan de aangeduide geadresseerde(n), is verboden. Hebt u deze mail per vergissing ontvangen, gelieve de verzender daarvan per telefoon of mail te verwittigen, en de eraan gekoppelde gegevens van elke computer te verwijderen. Met dank voor uw medewerking. Ondanks de genomen voorzorgen, kunnen er mails worden onderschept, gewijzigd, verloren, vernietigd of kunnen zij virussen bevatten. Wij wijzen elke verantwoordelijkheid af met betrekking tot eventuele schade die in die hypothese zou zijn veroorzaakt. Elke persoon die via mail met SIBELGA communiceert, wordt geacht dat risico te aanvaarden.
>>
>> Sibelga<https://www.sibelga.be>
>>
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
> Disclaimer
>
> Le présent courriel ainsi que ses annexes éventuelles peuvent contenir des informations confidentielles et/ou protégées par des droits de propriété intellectuelle et sont destinés á l'usage exclusif du (des) destinataire(s) susmentionné(s). Toute utilisation - notamment, mais non exclusivement, pour la reproduction, la communication ou la distribution totale ou partielle sous quelque forme que ce soit - de leur contenu par des personnes autres que le(s) destinataire(s) désigné(s) est interdite. Si vous avez reçu ce courriel par erreur, veuillez en informer l'expéditeur soit par téléphone soit par courriel, et supprimer de tout ordinateur les données y afférentes. Merci de votre collaboration. En dépit des précautions prises, des courriels peuvent être interceptés, modifiés, perdus, détruits ou contenir des virus. Nous déclinons toute responsabilité quant aux éventuels dommages éventuellement causés dans cette éventualité. Toute personne qui communique avec SIBELGA par courriel est supposée accepter ce risque.
>
> Deze mail en zijn eventuele bijlagen kunnen informatie bevatten die vertrouwelijk is en/of beschermd door intellectuele-eigendomsrechten en zijn bestemd voor exclusief gebruik door voormelde geadresseerde(n). Elk gebruik - onder meer, maar niet exclusief, voor volledige of gedeeltelijke reproductie, communicatie of distributie, onder welke vorm ook - van de inhoud ervan door andere personen dan de aangeduide geadresseerde(n), is verboden. Hebt u deze mail per vergissing ontvangen, gelieve de verzender daarvan per telefoon of mail te verwittigen, en de eraan gekoppelde gegevens van elke computer te verwijderen. Met dank voor uw medewerking. Ondanks de genomen voorzorgen, kunnen er mails worden onderschept, gewijzigd, verloren, vernietigd of kunnen zij virussen bevatten. Wij wijzen elke verantwoordelijkheid af met betrekking tot eventuele schade die in die hypothese zou zijn veroorzaakt. Elke persoon die via mail met SIBELGA communiceert, wordt geacht dat risico te aanvaarden.
>
> Sibelga<https://www.sibelga.be>



More information about the QGIS-Developer mailing list