Update uniqueness checks to use sqlalchemy orm 2.0 style
This commit is contained in:
parent
5e051e7e89
commit
e47711356c
|
@ -38,7 +38,10 @@ def create(
|
|||
raise ArgumentError('Lexicon prompt must be a string')
|
||||
|
||||
# Query the db to make sure the lexicon name isn't taken
|
||||
if db.session.query(func.count(Lexicon.id)).filter(Lexicon.name == name).scalar() > 0:
|
||||
if db(
|
||||
select(func.count(Lexicon.id))
|
||||
.where(Lexicon.name == name)
|
||||
).scalar() > 0:
|
||||
raise ArgumentError('Lexicon name is already taken')
|
||||
|
||||
new_lexicon = Lexicon(
|
||||
|
|
|
@ -51,7 +51,10 @@ def create(
|
|||
raise ArgumentError('Email must be a string')
|
||||
|
||||
# Query the db to make sure the username isn't taken
|
||||
if db.session.query(func.count(User.id)).filter(User.username == username).scalar() > 0:
|
||||
if db(
|
||||
select(func.count(User.id))
|
||||
.where(User.username == username)
|
||||
).scalar() > 0:
|
||||
raise ArgumentError('Username is already taken')
|
||||
|
||||
new_user = User(
|
||||
|
|
Loading…
Reference in New Issue