https://github.com/codesetuptest/django-django-11001
SWE-bench instance: django__django-11001
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.8%) to scientific vocabulary
Repository
SWE-bench instance: django__django-11001
Basic Info
- Host: GitHub
- Owner: CodeSetupTest
- License: bsd-3-clause
- Language: Python
- Default Branch: main
- Size: 0 Bytes
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
SWE-bench Instance: django__django-11001
Repository: django/django Base Commit: ef082ebb84f00e38af4e8880d04e8365c2766d34
Problem Statement
Incorrect removal of order_by clause created as multiline RawSQL Description
Hi. The SQLCompiler is ripping off one of my "order by" clause, because he "thinks" the clause was already "seen" (in SQLCompiler.getorderby()). I'm using expressions written as multiline RawSQLs, which are similar but not the same. The bug is located in SQLCompiler.getorderby(), somewhere around line computing part of SQL query without ordering: withoutordering = self.orderingparts.search(sql).group(1) The sql variable contains multiline sql. As a result, the self.orderingparts regular expression is returning just a line containing ASC or DESC words. This line is added to seen set, and because my raw queries have identical last lines, only the first clasue is returing from SQLCompiler.getorderby(). As a quick/temporal fix I can suggest making sql variable clean of newline characters, like this: sqloneline = ' '.join(sql.split('\n')) withoutordering = self.orderingparts.search(sqloneline).group(1) Note: beware of unicode (Py2.x u'') and EOL dragons (\r). Example of my query: return MyModel.objects.all().orderby( RawSQL(''' case when status in ('accepted', 'verification') then 2 else 1 end''', []).desc(), RawSQL(''' case when status in ('accepted', 'verification') then (accepteddatetime, preferreddatetime) else null end''', []).asc(), RawSQL(''' case when status not in ('accepted', 'verification') then (accepteddatetime, preferreddatetime, createdat) else null end''', []).desc()) The orderingparts.search is returing accordingly: ' then 2 else 1 end)' ' else null end' ' else null end' Second RawSQL with a else null end part is removed from query. The fun thing is that the issue can be solved by workaround by adding a space or any other char to the last line. So in case of RawSQL I can just say, that current implementation of avoiding duplicates in order by clause works only for special/rare cases (or does not work in all cases). The bug filed here is about wrong identification of duplicates (because it compares only last line of SQL passed to order by clause). Hope my notes will help you fixing the issue. Sorry for my english.
Repository Contents
This repository contains the actual source code from the original repository at commit ef082ebb84f00e38af4e8880d04e8365c2766d34. The code is ready for development and testing.
Docker Environment
A Dockerfile is provided to set up the proper environment for this instance:
bash
docker build -t swebench-instance .
docker run -it swebench-instance /bin/bash
Owner
- Name: CodeSetupTest
- Login: CodeSetupTest
- Kind: organization
- Repositories: 1
- Profile: https://github.com/CodeSetupTest
GitHub Events
Total
- Create event: 1
Last Year
- Create event: 1
Dependencies
- sweb.env.py.x86_64.2baaea72acc974f6c02079 latest build
- eslint ^0.22.1 development
- grunt ^1.0.1 development
- grunt-cli ^1.2.0 development
- grunt-contrib-qunit ^1.2.0 development
- pytz *
- sqlparse *
- mysqlclient >=1.3.13 test
- cx_oracle >=6.0 test
- psycopg2-binary >=2.5.4 test
- Pillow * test
- PyYAML * test
- argon2-cffi >=16.1.0 test
- bcrypt * test
- docutils * test
- geoip2 * test
- jinja2 >=2.9.2 test
- numpy * test
- pylibmc * test
- python-memcached >=1.59 test
- pytz * test
- pywatchman * test
- selenium * test
- sqlparse * test
- tblib * test