supabase / postgrest-dart

Dart client for PostgREST
https://supabase.com
MIT License
136 stars 38 forks source link

Request with multiple order columns is not correct #59

Closed dsyrstad closed 2 years ago

dsyrstad commented 2 years ago

Steps to reproduce

  1. Run code similar to:
    await client
        .from('atable')
        .select()
        .order('col1')
        .order('col2')
        .execute();

    Actual result

    The URL generated is http://localhost:8003/rest/v1/atable?select=%2A&order=%22col1%22.desc.nullslast&order=%22col1%22.desc.nullslast%2C%22col2%22.desc.nullslast Notice that there are two order parameters - one with col1 and the other with col1 and col2. It seems that the second order is ignored when it is executed. I would guess this depends on the how the server sees the order of the order parameters.

Expected result

The URL generated has just a single order parameter: http://localhost:8003/rest/v1/atable?select=%2A&order=%22col1%22.desc.nullslast%2C%22col2%22.desc.nullslast

Workaround

Use appendSearchParams('order', 'col1,col2') to generate the order parameter. This produces: http://localhost:8003/rest/v1/atable?select=%2A&order=col1%2Ccol2

I'm using postgrest 0.1.9 (with supabase 0.2.14)