Skip to content

$sqlquery-export view inlining not supported #2663

Description

@fhnaumann

Describe the bug
Performing a $sqlquery-export against the server with an inline view definition that is also referenced inside the query field in that request is reported back as invalid with an "undeclared table".

To Reproduce
Request:
POST /$sqlquery-export

Accept:application/fhir+json
Content-Type:application/fhir+json
Prefer:respond-async
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "query",
      "part": [
        {
          "name": "queryResource",
          "resource": {
            "resourceType": "Library",
            "status": "active",
            "type": {
              "coding": [
                {
                  "system": "https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes",
                  "code": "sql-query"
                }
              ]
            },
            "content": [
              {
                "contentType": "application/sql",
                "data": "U0VMRUNUIGNvdW50KCopIEFTIG4gRlJPTSB2ZXJpZnlfcGF0aWVudA==",
                "extension": [
                  {
                    "url": "https://sql-on-fhir.org/ig/StructureDefinition/sql-text",
                    "valueString": "SELECT count(*) AS n FROM verify_patient"
                  }
                ]
              }
            ]
          }
        }
      ]
    },
    {
      "name": "view",
      "part": [
        { "name": "name", "valueString": "verify_patient" },
        {
          "name": "viewResource",
          "resource": {
            "resourceType": "ViewDefinition",
            "url": "https://example.org/ViewDefinition/verify_patient",
            "name": "verify_patient",
            "status": "active",
            "resource": "Patient",
            "select": [
              {
                "column": [
                  { "path": "getResourceKey()", "name": "patient_id" }
                ]
              }
            ]
          }
        }
      ]
    },
    {
      "name": "_format",
      "valueCode": "ndjson"
    }
  ]
}

Returns:

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "SQL references an undeclared table: verify_patient"
    }
  ]
}

Expected behavior
I expect it to resolve the inline resource and return a 202 with a polling location.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions