<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 9, 2020 at 11:26 PM Tim Sutton <<a href="mailto:tim@kartoza.com">tim@kartoza.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br>
<br>In particular, me an Nyall have been chatting about adding a method to 
factory a QgsVectorLayer from a generic SQL query, the issues I see is 
that we need a PK (at least for PG) and how to decide the geometry 
column if there are more than one. <br></div></div></blockquote><div><br></div><div><div style="font-family:arial,helvetica,sans-serif;font-size:small">I wonder if you could just transparently add row_number[1] to the query to give each row a unique id?</div><div style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div style="font-family:arial,helvetica,sans-serif;font-size:small">Regards</div><div style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div style="font-family:arial,helvetica,sans-serif;font-size:small">Tim</div><div style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div style="font-family:arial,helvetica,sans-serif;font-size:small">[1] <a href="https://www.postgresqltutorial.com/postgresql-row_number/" style="font-family:Arial,Helvetica,sans-serif" target="_blank">https://www.postgresqltutorial.com/postgresql-row_number/</a></div><div style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div></div></div></div></blockquote><div><br></div><div><br></div><div>Hi Tim, <br></div><div><br></div><div>the example query I pasted in my original email does exactly that:  (SELECT row_number()....</div><div><br></div><div>we just need a bit of login to determine when/if we have to make that trick.</div><div><br></div><br></div>-- <br><div dir="ltr" class="gmail_signature">Alessandro Pasotti<br>w3:   <a href="http://www.itopen.it" target="_blank">www.itopen.it</a></div></div>