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.

Alter ID replacement behaviour

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 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:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
perezzinicommented, Oct 26, 2021

Yes, that’s exactly want I wanted @JLHasson

Thanks to all.

0reactions
JLHassoncommented, Oct 26, 2021

I believe you want to use the default_factory parameter: https://pydantic-docs.helpmanual.io/usage/models/#field-with-dynamic-default-value

Read more comments on GitHub >

github_iconTop 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 >

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