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

Add support for deferred column loading #97

Open
8 tasks done
hitman-gdg opened this issue Sep 14, 2021 · 5 comments
Open
8 tasks done

Add support for deferred column loading #97

hitman-gdg opened this issue Sep 14, 2021 · 5 comments
Labels
feature New feature or request

Comments

@hitman-gdg
Copy link

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

from sqlmodel import deferred

class User(sqlmodel, table=True):
    id: Optional[int] = Field(primary_key=True, default=None)
    name: str
    data: Optional[bytes] = Field(deferred=True)

Description

The ability to be able to included deferred sql columns

Wanted Solution

I would like to be able to work with sqlalchemy deferred columns, so that certain columns are not loaded by default as part of a model

Wanted Code

from sqlmodel import deferred

Alternatives

No response

Operating System

macOS

Operating System Details

No response

SQLModel Version

0.0.4

Python Version

3.9.6

Additional Context

No response

@hitman-gdg hitman-gdg added the feature New feature or request label Sep 14, 2021
@hitman-gdg hitman-gdg changed the title Add support for diferred column loading Add support for deferred column loading Sep 14, 2021
@eddcorts
Copy link

Having same issue, did you find any alternative with base SQLAlchemy or something?

@FilipeMarch
Copy link

Did you find a solution?

@lucas-labs
Copy link

I think that we can use the new sa_type now, in order to achieve this behaviour.

@ngi
Copy link

ngi commented Mar 28, 2024

any news how to use sa_type for deferred loading?

@MarkusDressel
Copy link

MarkusDressel commented Nov 14, 2024

@tiangolo can you provide some information if / how it possible to leverage SQLalchemy's deferred loading mechanism in SQLModel ?

I also could not find a way to make deferred loading on column level (not on query level) work. sa_column setting is not recognized by SQLModel and still loads the deferred column

blob: bytes | None = Field(default=None, sa_column=deferred(Column(LargeBinary)))

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

No branches or pull requests

6 participants