0
我試圖做一個查詢,幫助我通過用戶名獲取用戶。我想要做的是檢查給定的用戶名是否是唯一的。所以我想到的是當我執行我的選擇請求時用大寫的用戶名,並將它與給定用戶名的大寫字母進行比較。這是我的嘗試:Playframework SQL查詢
SQL("select * from utilisateur where upper(pseudo) = {pseudo}").on(
'pseudo -> pseudo.toUpperCase
).as(Utilisateur.utilisateur.singleOpt)
但得到這個錯誤:
[RuntimeException: SqlMappingError(too many rows when expecting a single one)]
我想這太:
SQL("select * from utilisateur where ucase(pseudo) = {pseudo}").on(
'pseudo -> pseudo.toUpperCase
).as(Utilisateur.utilisateur.singleOpt)
,我得到這個錯誤:
[PSQLException: ERROR: function ucase(character varying) does not exist Indice : No function matches the given name and argument types. You might need to add explicit type casts. Position : 33]
我該怎麼辦?
PS:IM使用PostgreSQL 9.1
感謝您對這個工作me.As罰你所說的問題是從'singleOpt'來,因爲它越來越多行當它只檢查一個。 –