question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it normal unable to use autocomplete for SQLModel class field?

See original GitHub issue

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn’t find it.
  • I searched the SQLModel documentation, with the integrated search.
  • I already searched in Google “How to X in SQLModel” and didn’t find any information.
  • I already read and followed all the tutorial in the docs and didn’t find an answer.
  • I already checked if it is not related to SQLModel but to Pydantic.
  • I already checked if it is not related to SQLModel but to SQLAlchemy.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

class Hero1(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    secret_name: str
    age: Optional[int] = None


class Hero2():
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    secret_name: str
    age: Optional[int] = None

Description

I’m using Pycharm. When I write code like, select(Hero1).where(Hero1.age > 35)

I expect IDE to show field ‘age’ when I type ‘Hero1.’ but IDE autocomplete displays no fields of Hero1. but with Hero2 (without SQLModel inherits), it surely works fine.

Is this normal or only my IDE problem?

Operating System

Windows

Operating System Details

windows 10 Pycharm 2022

SQLModel Version

0.0.8

Python Version

3.10.6

Additional Context

image

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tiangolocommented, Nov 3, 2022

It’s probably that PyCharm still doesn’t support dataclass_transform, that’s a new standard in Python and it was adopted by Pydantic and SQLModel even before it was an official standard.

You can probably ask them to add support for it. 🤓

0reactions
tiangolocommented, Nov 7, 2022

Just a note, autocompletion for attributes would work even without support for dataclass_transform. What dataclass_transform would help with is autocompletion for parameters when creating a new instance of the class.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a Table with SQLModel - Use the Engine
The next step is to define the fields or columns of the class by using standard ... But inside the SQL database, it...
Read more >
Simple instructions for a self referential table #127 - GitHub
I am only a litte familiar with SQL alchemy but was unable to translate their example into one that would work with SQLmodel....
Read more >
SQLModel: SQL DBs based on Python type hints. The ... - Reddit
And you can also use inheritance to avoid duplication of fields/columns, but customize, include, exclude fields in the data models for input and ......
Read more >
SQLModel is the Pydantic inspired Python ORM we ... - YouTube
The first 1000 people to use this link will get a 1 month free trial of Skillshare: https://skl.sh/johnwatsonrooney03221An ORM provides a ...
Read more >
How to get Alembic to recognise SQLModel database model?
There should be info about that in Advanced user guide soon with better explanation than mine but here is how I made Alimbic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found