Alter ID replacement behaviour
See original GitHub issueFirst 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 Table(SQLModel):
id: Optional[str] = Field(default=uuid.uuid4().hex, primary_key=True)
Description
Hi,
I would like to alter a table’s primary key’s behaviour so I can use, for example, UUID; like
class Table(SQLModel):
id: Optional[str] = Field(default=uuid.uuid4().hex, primary_key=True)
The expected behaviour should be replacing each uuid every time a new “record” is created.
Any options?
Thanks!
Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.9
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Identify and Define Problem and Replacement Behaviors
Step 1: Identify and define problem and replacement behaviors. The first step in the FBA process is to identify and define the problem...
Read more >Teaching Alternative Behaviors to Students
Identifying, Teaching, and Ensuring the Use of Replacement Behaviors. Your comprehensive, online guide to teaching alternatives to problem behaviors.
Read more >Teaching Replacement Behaviors
Replacement behaviors are an important part of ABA. Replacement behaviors are used to replace the challenging behaviors that interfere with ...
Read more >“Replacing” Problem Behavior: An Analysis of Tactical ... - NCBI
The notion of establishing reinforcement contingencies for alternative or replacement behaviors as part of any program that targets inappropriate behavior ...
Read more >The Competing Behavior Pathway Model: Developing ...
A replacement behavior also represents the behavior you want to occur ... a powerful and positive plan that can change a student's life....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, that’s exactly want I wanted @JLHasson
Thanks to all.
I believe you want to use the
default_factory
parameter: https://pydantic-docs.helpmanual.io/usage/models/#field-with-dynamic-default-value