Skip to content
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

Field cannot autocompletion when its a SQLModel #890

Open
8 of 9 tasks
zhaowcheng opened this issue Apr 9, 2024 · 6 comments
Open
8 of 9 tasks

Field cannot autocompletion when its a SQLModel #890

zhaowcheng opened this issue Apr 9, 2024 · 6 comments

Comments

@zhaowcheng
Copy link

zhaowcheng commented Apr 9, 2024

Privileged issue

  • I'm @tiangolo or he asked me directly to create an issue here.

Issue Content

Sorry for create this issue without permission, because this question has been in the discussion area for a week but no one has paid attention to it.

First Check

  • I added a very descriptive title here.
  • I used the GitHub search to find a similar question 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

from sqlmodel import SQLModel
from typing import Optional

class ModelNode(SQLModel):
    id: int
    name: str

class Node:
    id: int
    name: str

class Cluster(SQLModel):
    model_node: Optional[ModelNode] = None
    node: Optional[Node] = None

Description

Cluster.node. can autocompletion, but Cluster.model_node. cannot

Operating System

macOS

Operating System Details

IDE: vscode

SQLModel Version

0.0.16

Python Version

3.10.5

Additional Context

image

image

@asacristani
Copy link

asacristani commented Apr 14, 2024

@zhaowcheng If you create a new object from this class, the autocompletion works:
image
Also if you try to access to the property directly:
image

So not sure what is happening in your end (maybe any VS code configuration is missing?)

@zhaowcheng
Copy link
Author

@asacristani , thank you for your answer.

I downgraded pydantic from v2 to v1 and it worked.

Is this a bug in sqlmodel?

@waketzheng
Copy link

Autocomplete worked for me with latest version of sqlmodel and pydantic2.5.3 (Python3.11/Pycharm)
image

image

@zhaowcheng
Copy link
Author

@waketzheng
yes, pycharm can autocomplete when pydantic is v2, but vscode cannot.

@dipsx
Copy link

dipsx commented Apr 23, 2024

@waketzheng yes, pycharm can autocomplete when pydantic is v2, but vscode cannot.

same issue in vscode on windows

@Abeautifulsnow
Copy link

Abeautifulsnow commented May 11, 2024

I usually develop on WSL1 for windows. And the autocompletion functionality works fine in my vscode.
image

And my packages infos are below:

pydantic          2.7.1    Data validation using Python type hints
sqlmodel          0.0.18   SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants