Skip to content

fix(discovery): SQL request had wrong param binding

Benjamin Ségault requested to merge users/bsegault/fix-discovery into main

When trying to fetch a Grid2drespresentation by itself, I had the following error from the open-etp-server log:

{"name":"ETPApi","hostname":"ws-ncy-saint-emilion","pid":151568,"level":30,"msg":"Failed to get grid box eml:///dataspace('Mandaros_Full/Mandaros_Full')/resqml20.obj_Grid2dRepresentation(6066b03c-9909-42d0-9587-37ac65ca9344) Server error 8: Server Error: Unexpected Exception: ERROR:  could not determine data type of parameter $3","time":"2021-11-02T16:09:54.078Z","v":0}

Inspecting the postgres container, it said this was due to the following request

select res2.guid, res2.name, ml||'.'||xml,

               res2.createdBy, res2.createdAt, res2.updatedAt,

               res2.xdata_json, res2.xdata_avro, res2.obj_id

          from res

          join rel on rel.obj_id = res.obj_id

          join res res2 on res2.obj_id = rel.dst_id

          join typ on typ.id = res2.typ_id

          join uri on uri.id = typ.uri_id

         where res.typ_id =

               (

                select typ.id

                  from typ

                  join uri on uri.id = typ.uri_id

                 where uri.ml || '.' || typ.xml = $1

               )

           and res.guid = $2

           and 1 = 1

           and res2.typ_id =

                        (

                            select typ.id

                            from typ

                            join uri on uri.id = typ.uri_id

                            where uri.ml || '.' || typ.xml = $4

                        )

Note that there is parameter bindings for $1, $2 and $4 but not $3.

With this change, our client behaves as expected.

Edited by Laurent Deny

Merge request reports