Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #143, #174, #175 #176

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

fix: #143, #174, #175 #176

wants to merge 3 commits into from

Conversation

soedirgo
Copy link
Member

@soedirgo soedirgo commented Jan 26, 2022

#143 and #175 are interrelated (they change the /query response format), so I decided to consolidate the fixes into 1 PR.

Fixes #174

dates, timestamps, and timestamptzs are no longer converted to JS Dates.

date before: "2020-01-01T00:00:00.000Z"

date after: "2020-01-01"

Fixes #143

Queries w/ multiple statements now return results from all statements instead of returning an empty list.

select 1 as a; select 2 as b before:

[]

select 1 as a; select 2 as b after:

[
  {
    "columns": [
      "a"
    ],
    "rows": [
      [
        1
      ]
    ]
  },
  {
    "columns": [
      "b"
    ],
    "rows": [
      [
        2
      ]
    ]
  }
]

Fixes #175

Columns with the same alias now works, but this required a breaking change in the response format.

select 1 as x, 2 as x before:

[
  {
    "x": 2
  }
]

select 1 as x, 2 as x after:

[
  {
    "columns": [
      "x",
      "x"
    ],
    "rows": [
      [
        1,
        2
      ]
    ]
  }
]

Additional notes

Previously, the response is a list of rows, but now that we support multi-statement queries, the response is a list of query results. In other words:

Type of response before: Record<string, unknown>[]
Type of response after: { columns: string[]; rows: unknown[][] }[]

@soedirgo
Copy link
Member Author

In hindsight, I wonder if this would require a lot of refactors in Studio. If there are a lot of call sites that rely on the old response format, we can expose the "arrayMode" as a new endpoint instead.

@soedirgo soedirgo marked this pull request as draft February 18, 2022 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant