Closed xalteropsx closed 8 months ago
it's not bug, you may need learn more about database, mysql never promise auto increase field continuous, why sqlachemy is not the same? might because that sqlalchemy check data first and it didn't execute create sql statement..
data = _mod(**_request.model_dump(), user_id=_user.id)
database.add(data)
database.flush()
not sure i use sort of this technique to avoid waste of id incremental value
it's not bug, you may need learn more about database, mysql never promise auto increase field continuous, why sqlachemy is not the same? might because that sqlalchemy check data first and it didn't execute create sql statement..
is their anything alternative to session.flush() ? in tortoise neither their is an session.add()
@YAGregor u need to check the flush method that is the key of not incrementing the id in sqlachemy while here we have nothing about flush i think tortoise not added anything related to flush or docs
even ponyorm has flush ...
@grigi why tortoise not has flush which is the most powerful method ?
feature: 1.it avoid fail attempt id to not trigger incremental 2.it allow to multi post table cause it get the id before post
my 70% code is base on flush and yet this orm not have i see all other orm already supported flush
db_module = mod(**module.dict())
database.add(db_module)
database.flush()
db_group = mod1(**group.dict(), module_id=db_module.id)
database.add(db_group)
database.commit()
database.refresh(db_module)
database.refresh(db_group)
return {
"module": db_module,
"group": db_group,
}
the flush
is apart of sqlalchemy's "unit of work", tortoise orm would never has flush
, cause tortoise, just like django, follow "active record pattern", it's very different from sqlalchemy (from idea level),
for your case, you just to need to avoid insert fail, or use another data source(like redis) to make autoincreasing sequence
nvm friend i left tortoise yestarday i saw rust orm which build for fastapi i love it almost 12k star in 7month of its release
nvm friend i left tortoise yestarday i saw rust orm which build for fastapi i love it almost 12k star in 7month of its release
what rust orm? I never heard
@YAGregor Edgedb
id keep keep increase even on fail post while this issue not occur on sqlalchmey