django-extensions / django-extensions/django-extensions

sqldiff: Duration fields not handled properly and array type handlinghack very broken

Open
#1,663 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6.8k
Forks
1.2k
Avg merge
3h 58m
Merged PRs (30d)
1

Description

Ref:

https://github.com/django-extensions/django-extensions/blob/c17f8a543551bd5c98b6b66a694a488fa292a93f/django_extensions/management/commands/sqldiff.py#L1190

I hit this because my model has a DurationField which has a db type of interval[] and so this test is triggered. The test subsequently bombs anyhow because of malformed piece of SQL. If you look at it it's passing table_name, a string in as the first parameter which becomes the value of the attrelid column in pg_attribute which is of type oid and not string.

The comment of course is indicative of the status of this piece of code and it asks some salient questions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in django_extensions/management/commands/sqldiff.py around line 1190, where the issue identifies the DurationField and array-type handling. Reproduce the failure with a model whose database type is interval[], then inspect the generated PostgreSQL query and its attrelid parameter. Done means sqldiff handles this field without malformed SQL.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, postgresql, python
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.