tortoise / tortoise/tortoise-orm
'__startswith’ modifier didn’t work fine on Oracle DB.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
When using the '__startswith' modifier on Oracle DB, the data type of the automatically generated CAST function is only converted to 'VARCHAR' with no length, resulting in the following error.
ORA-00906: Left parenthesis missing
ex.)
async def get_counter(self, current_date):
result = await (
MY_TABLE
.filter(create_dtm__startswith=current_date)
.annotate(count=Count("*"))
.group_by("status")
.values("status", "count")
)
return result
actual query like that.
SELECT "RESULT" "status",COUNT(*) "count" FROM "MY_TABLE" WHERE CAST("DATETIME" AS VARCHAR) LIKE '20230829%' ESCAPE '\' GROUP BY "RESULT"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the __startswith modifier and the Oracle-specific SQL generation that produces CAST(... AS VARCHAR); compare the generated query with the failing example. Done means the Oracle query executes without ORA-00906 while preserving the intended date-prefix filtering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100