Fix stupid mistake.. and just return the NullString

This commit is contained in:
Till Faelligen 2022-05-04 17:53:49 +02:00
parent 88612ddd0c
commit 60ba4b5612
2 changed files with 10 additions and 9 deletions

View file

@ -142,9 +142,9 @@ func (s *accountsStatements) InsertAccount(
var err error var err error
if accountType != api.AccountTypeAppService { if accountType != api.AccountTypeAppService {
_, err = stmt.ExecContext(ctx, localpart, createdTimeMS, hash, nil, accountType) _, err = stmt.ExecContext(ctx, localpart, createdTimeMS, hash, nil, accountType, policyVersion)
} else { } else {
_, err = stmt.ExecContext(ctx, localpart, createdTimeMS, hash, appserviceID, accountType) _, err = stmt.ExecContext(ctx, localpart, createdTimeMS, hash, appserviceID, accountType, policyVersion)
} }
if err != nil { if err != nil {
return nil, err return nil, err
@ -219,10 +219,10 @@ func (s *accountsStatements) SelectNewNumericLocalpart(
func (s *accountsStatements) SelectPrivacyPolicy( func (s *accountsStatements) SelectPrivacyPolicy(
ctx context.Context, txn *sql.Tx, localPart string, ctx context.Context, txn *sql.Tx, localPart string,
) (policy string, err error) { ) (policy string, err error) {
var policyNull sql.NullString
stmt := sqlutil.TxStmt(txn, s.selectPrivacyPolicyStmt) stmt := sqlutil.TxStmt(txn, s.selectPrivacyPolicyStmt)
err = stmt.QueryRowContext(ctx, localPart).Scan(&policyNull)
err = stmt.QueryRowContext(ctx, localPart).Scan(&policy) return policyNull.String, err
return
} }
// batchSelectPrivacyPolicy queries all users which didn't accept the current policy version // batchSelectPrivacyPolicy queries all users which didn't accept the current policy version

View file

@ -144,9 +144,9 @@ func (s *accountsStatements) InsertAccount(
var err error var err error
if accountType != api.AccountTypeAppService { if accountType != api.AccountTypeAppService {
_, err = stmt.ExecContext(ctx, localpart, createdTimeMS, hash, nil, accountType) _, err = stmt.ExecContext(ctx, localpart, createdTimeMS, hash, nil, accountType, policyVersion)
} else { } else {
_, err = stmt.ExecContext(ctx, localpart, createdTimeMS, hash, appserviceID, accountType) _, err = stmt.ExecContext(ctx, localpart, createdTimeMS, hash, appserviceID, accountType, policyVersion)
} }
if err != nil { if err != nil {
return nil, err return nil, err
@ -225,9 +225,10 @@ func (s *accountsStatements) SelectNewNumericLocalpart(
func (s *accountsStatements) SelectPrivacyPolicy( func (s *accountsStatements) SelectPrivacyPolicy(
ctx context.Context, txn *sql.Tx, localPart string, ctx context.Context, txn *sql.Tx, localPart string,
) (policy string, err error) { ) (policy string, err error) {
var policyNull sql.NullString
stmt := sqlutil.TxStmt(txn, s.selectPrivacyPolicyStmt) stmt := sqlutil.TxStmt(txn, s.selectPrivacyPolicyStmt)
err = stmt.QueryRowContext(ctx, localPart).Scan(&policy) err = stmt.QueryRowContext(ctx, localPart).Scan(&policyNull)
return return policyNull.String, err
} }
// batchSelectPrivacyPolicy queries all users which didn't accept the current policy version // batchSelectPrivacyPolicy queries all users which didn't accept the current policy version