<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Craig,</p>
    <p>remove the leading end-of-line and spaces in your ExecuteSQL</p>
    <pre>l = ds.ExecuteSQL(
    """SELECT *
    FROM "open-data-platform:v_s_parcel_proposed"
    ORDER BY "parcel_pfi" ASC
    """
)

Also fixed per <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/commit/f6c7d95e2c66ba1f62f6ff17e31af37f7f8f6bc8">https://github.com/OSGeo/gdal/commit/f6c7d95e2c66ba1f62f6ff17e31af37f7f8f6bc8</a>

Even
</pre>
    <p></p>
    <div class="moz-cite-prefix">Le 02/11/2023 à 02:50, Craig de Stigter
      via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CAF1M8pfUoWYR2+yqCOp5NwxM0Pm9T5ojqfEbt_EDpOTR_pwfNA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Hey folks</div>
        <div><br>
        </div>
        <div>We're having a lot of trouble getting data out of a WFS
          server that doesn't have primary keys. <a
            href="https://github.com/OSGeo/gdal/pull/8146"
            moz-do-not-send="true">(previous work on this)</a></div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>The URL that's causing us grief is this one: <a
href="https://opendata.maps.vic.gov.au/geoserver/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=2.0.0&TYPENAMES=open-data-platform:v_s_parcel_proposed&STARTINDEX=0&COUNT=2"
            moz-do-not-send="true">https://opendata.maps.vic.gov.au/geoserver/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=2.0.0&TYPENAMES=open-data-platform:v_s_parcel_proposed&STARTINDEX=0&COUNT=2</a></div>
        <div><br>
        </div>
        <div>* we can't disable pagination, because the server only
          returns 5000 records even if we ask for more.</div>
        <div>* we can't paginate without ordering, because there's no
          PK.</div>
        <div><br>
        </div>
        <div>So, adding a `&SORTBY=parcel_pfi` to the querystring
          fixes the issue. But I can't seem to get GDAL to do that for
          us.</div>
        <div><br>
        </div>
        <div>There does seem to be code for applying an "ORDER BY"
          clause from ExecuteSQL to the WFS 1.1+ SORTBY field. However,
          I can't get it to work.</div>
        <div><br>
        </div>
        <div>I made <a
href="https://gist.github.com/craigds/4fc8c0f61d02c0293b7c5005b8492744#file-wfs-order-by-test-py"
            moz-do-not-send="true">a test script</a> to demonstrate the
          problem. It uses ExecuteSQL to apply an ORDER BY clause, but
          the resulting curl queries don't have a SORTBY parameter. Then
          it crashes after the server returns a 400 error due to the
          missing SORTBY.<br>
        </div>
        <div><br>
        </div>
        <div>I assume there's something I need to do to cause GDAL to
          use the SORTBY parameter but I'm not sure what it is. Any tips
          would be appreciated.<br>
        </div>
        <div><br>
          <span class="gmail_signature_prefix">-- </span><br>
          <div dir="ltr" class="gmail_signature"
            data-smartmail="gmail_signature">
            <div dir="ltr">
              <div
style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">Regards,</div>
              <div
style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">Craig</div>
              <div
style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><br>
              </div>
              <div
style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">Platform
                Engineer<br>
              </div>
              <div
style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">Koordinates</div>
              <div
style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><br>
              </div>
              <div
style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><a
                  href="tel:+64%2021%20256%209488"
                  style="color:rgb(17,85,204)" target="_blank"
                  moz-do-not-send="true">+64 21 256 9488</a> / <a
                  href="http://koordinates.com/"
                  style="color:rgb(17,85,204)" target="_blank"
                  moz-do-not-send="true">koordinates.com</a> / <a
                  href="https://twitter.com/koordinates"
                  style="color:rgb(17,85,204)" target="_blank"
                  moz-do-not-send="true">@koordinates</a></div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>