-
Notifications
You must be signed in to change notification settings - Fork 81
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
ArrayField of Postgres processed incorrectly #92
Comments
A pull request would be great. In particular, I'll be looking for tests of the existing working array functionality, to make sure those don't break. Confirming that they already exist sufficiently is fine. I'm certain that I do have an ArrayField in my production work project that is working, so as long as I don't break that, I'm happy to clean up other issues. It seems like you've got a reasonable grasp on this issue. I don't yet. But a pull request would be welcome, and I will review it. Thank you for reporting the issue. |
While preparing a branch for this PR I was running tests with tox and found few more issues.
Updating Django version to 2.0.10 and 2.1.5 fixed the issue.
Adding migration for JsonModel fixed this as well. Should I create separate PRs for this two? |
|
Gosh, my bad. I've missed that update. Sorry about that.
it's in the master branch now. Looks like a separate case to me. I'll provide more info later. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I believe this is now fixed in #101 . |
I've found that ArrayField of Postgres is processed incorrectly, which actually does not allow to fetch Array Fields not via ORM, nor SQL Expression Language.
Currently existing tests does not cover this case as they are not fetching not object, not list of values from the table
Tested with:
Python==3.7.5
Django==2.2.5
djangorestframework==3.10.3
aldjemy==0.10.1
sqlalchemy==1.3.16
psycopg2==2.8.3
Postgres==10.5
Looks like here (aldjemy/postgres.py line 16):
author of ArrayField processing copy-pasted similar process from the upper level (aldjemy/table.py line 102):
but there is no need to put single field in a list. It will not be unpacked anywhere.
I.e. there is no need in aldjemy/postgres.py to do the following:
Since it will produce not the SA Column instance, but python list in the attribute of SA Table instance.
![Screenshot_1](https://user-images.githubusercontent.com/33364822/82218173-29f4c180-9924-11ea-9aad-0f9083ecb4e8.png)
![Screenshot_2](https://user-images.githubusercontent.com/33364822/82218542-b606e900-9924-11ea-8102-3c6b2fbc0cf4.png)
This will lead to attempt to call method
dialect_impl
from list instance during fetching, when SQLAlchemy awaits here Column instance.Removal of those two lines of code fixed the issue. I've checked it with ORM and SQL Expression Language.
Walked through with debugger and compared the resulting column type. It's the same as of Table build with declarative_base.
Resulting column data types are valid:
![Screenshot_3](https://user-images.githubusercontent.com/33364822/82218533-b43d2580-9924-11ea-8f73-7e93a914b68e.png)
![Screenshot_4](https://user-images.githubusercontent.com/33364822/82218425-8b1c9500-9924-11ea-9d95-3fe485fe72e2.png)
I can make it a PR with few additional tests.
The text was updated successfully, but these errors were encountered: