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 issue with Postgres 10 #138

Merged
merged 3 commits into from Jul 4, 2021
Merged

Fix issue with Postgres 10 #138

merged 3 commits into from Jul 4, 2021

Conversation

ryancheley
Copy link
Contributor

When using version 1.0 on Ubuntu 18.04 with Postgres 10.17 an Internal Server (500) error is generated.

I traced this back to the change made for version 1.0 on line 162 (see compared diff here)

The array_agg will throw the error

could not find array type for data type information_schema.sql_identifier

casting the column_name field to text resolves this issue for Postgres 10.

I did run the tests locally and 88 passed with 2 warnings. The warnings were:

test_project/test_utils.py::test_apply_sort[select * from (select * from foo) as results order by "bar"-bar-True-select * from (select * from foo) as results order by "bar" desc]
  /Users/ryan/github/django-sql-dashboard/venv/lib/python3.9/site-packages/django/db/backends/postgresql/base.py:304: RuntimeWarning: Normally Django will use a connection to the 'postgres' database to avoid running initialization queries against the production database when it's not needed (for example, when running tests). Django was unable to create a connection to the 'postgres' database and will use the first PostgreSQL database instead.
    warnings.warn(

test_project/test_utils.py::test_apply_sort[select * from (select * from foo) as results order by "bar"-bar-True-select * from (select * from foo) as results order by "bar" desc]
  /Users/ryan/github/django-sql-dashboard:0: PytestWarning: Error when trying to teardown test databases: RuntimeError("generator didn't stop after throw()")

-- Docs: https://docs.pytest.org/en/stable/warnings.html

When using Postgres 10 the `information_schema.columns.column_name` needs to be cast as text. Otherwise, an error is generated which states:

```
could not find array type for data type information_schema.sql_identifier
```
There was a missing space between the -m and venv that could lead to confusion for new contributors
@simonw
Copy link
Owner

simonw commented Jul 4, 2021

Thanks for figuring this out!

@simonw
Copy link
Owner

simonw commented Jul 4, 2021

It would be great to have the GitHub Actions workflow run tests against multiple PostgreSQL versions to catch this kind of thing in the future https://github.com/simonw/django-sql-dashboard/blob/main/.github/workflows/test.yml

@simonw simonw merged commit 65e7d51 into simonw:main Jul 4, 2021
@ryancheley
Copy link
Contributor Author

@simonw no problem! Sorry if the commit history looks wonky. As I was working through the contribution guidelines I found a typo which I fixed, but had messed up all of the branches on my local version and was trying to undo and redo and ... well, it's a holiday Sunday and I think it's time I go enjoy time with my family! Cheers!

simonw added a commit that referenced this pull request Jul 6, 2021
simonw pushed a commit that referenced this pull request Jul 6, 2021
* Fixed issue with Postgres 10

When using Postgres 10 the `information_schema.columns.column_name` needs to be cast as text. Otherwise, an error is generated which states:

```
could not find array type for data type information_schema.sql_identifier
```

* Fixed typo

There was a missing space between the -m and venv that could lead to confusion for new contributors
simonw added a commit that referenced this pull request Jul 6, 2021
simonw added a commit that referenced this pull request Jul 6, 2021
@simonw
Copy link
Owner

simonw commented Aug 9, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants