diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2022-04-27 15:05:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 15:05:49 +0200 |
commit | f023cdf8c42cc1a4bb850b478dbbf7d901b5e1bd (patch) | |
tree | 5698494b5438a721976a1f685dcd29301538a7d7 /userapi/storage/postgres/accounts_table.go | |
parent | d7cc187ec00410b949ffae1625835f8ac9f36c29 (diff) |
Add UserAPI storage tests (#2384)
* Add tests for parts of the userapi storage
* Add tests for keybackup
* Add LoginToken tests
* Add OpenID tests
* Add profile tests
* Add pusher tests
* Add ThreePID tests
* Add notification tests
* Add more device tests, fix numeric localpart query
* Fix failing CI
* Fix numeric local part query
Diffstat (limited to 'userapi/storage/postgres/accounts_table.go')
-rw-r--r-- | userapi/storage/postgres/accounts_table.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/userapi/storage/postgres/accounts_table.go b/userapi/storage/postgres/accounts_table.go index 92311d56..f86812f1 100644 --- a/userapi/storage/postgres/accounts_table.go +++ b/userapi/storage/postgres/accounts_table.go @@ -47,8 +47,6 @@ CREATE TABLE IF NOT EXISTS account_accounts ( -- TODO: -- upgraded_ts, devices, any email reset stuff? ); --- Create sequence for autogenerated numeric usernames -CREATE SEQUENCE IF NOT EXISTS numeric_username_seq START 1; ` const insertAccountSQL = "" + @@ -67,7 +65,7 @@ const selectPasswordHashSQL = "" + "SELECT password_hash FROM account_accounts WHERE localpart = $1 AND is_deactivated = FALSE" const selectNewNumericLocalpartSQL = "" + - "SELECT nextval('numeric_username_seq')" + "SELECT COALESCE(MAX(localpart::integer), 0) FROM account_accounts WHERE localpart ~ '^[0-9]*$'" type accountsStatements struct { insertAccountStmt *sql.Stmt @@ -178,5 +176,5 @@ func (s *accountsStatements) SelectNewNumericLocalpart( stmt = sqlutil.TxStmt(txn, stmt) } err = stmt.QueryRowContext(ctx).Scan(&id) - return + return id + 1, err } |