OAuth Email missing in data explorer

AI-generated summary

The discussion revolves around an issue with retrieving OAuth email addresses in the Data Explorer. Bas initially queries the users table, but the email column returns NULL for users who signed up using Google OAuth2, despite the emails being visible in their profiles. zogstrip explains that the email column is no longer used and suggests joining the users table with the user_emails table, using the primary = true condition. Bas successfully implements this solution. zogstrip notes that the email column is currently in read-only mode and will be completely removed once it’s safe to do so.

Using this query:

SELECT id, username, email
FROM users

The following is returned

All those NULL results are people who have signed up using Google OAuth2

The emails are in the system correctly, I can see them in their profiles.

What am I doing wrong? :slight_smile:

We no longer use the email column on the users table.

You need to join the users table with the user_emails table with the primary = true condition :wink:

SELECT u.id, u.username, u.email, ue.email
FROM users u
INNER JOIN user_emails ue ON u.id = ue.id
WHERE ue.primary = true

That worked :slight_smile:

I was thrown off by the one email that was there; but I guess that’s a remnant of running

cd /var/discourse
./launcher enter app
rake admin:create

when I was troubleshooting my email troubles.

The column is in readonly mode. We’ll completely remove it when we’re 100% it’s safe to do so.