# Flair\_url is always NULL in SQL query?

**URL:** https://meta.discourse.org/t/flair-url-is-always-null-in-sql-query/230555
**Category:** Development
**Created:** [June 21, 2022, 3:39am UTC](https://meta.discourse.org/t/flair-url-is-always-null-in-sql-query/230555 "2022-06-21T03:39:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [June 21, 2022, 3:39am UTC](https://meta.discourse.org/t/flair-url-is-always-null-in-sql-query/230555/1 "2022-06-21T03:39:11Z")

</div>

I’m working on a plugin that uses the Group flair image.

When I perform a SQL query to grab the `flair_url` from the `groups` table, it returns NULL for every group despite having an image uploaded. The Discourse [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin also confirms this (`SELECT flair_url from groups`)

 ![image](https://global.discourse-cdn.com/meta/original/4X/6/9/d/69d1298ebd58e92454f806fa81da171baf6945e6.png)

However, the /g.json page does provide a valid `flair_url`:

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/8/0/880e621c38d32fc572505f74e6ebcec4b2ac47fd.png)

What’s up with this? is there some quirk about fetching this url that makes it hard to get from a SQL query? I’m still pretty new to Ruby and Rails so I don’t know exactly where I would look in the Discourse source to figure this out. I did notice on line 9 on [app/models/group.rb](https://github.com/discourse/discourse/blob/9db8f00b3dd6f2881adf1b786e29426889225e7a/app/models/group.rb) that the `flair_url` is added to “`ignored_columns`”, - I’m not sure what the implications of that are, if any.

Just wondering if this column appearing NULL is intentional and if so, I would appreciate any tips to get that data from the Ruby back-end of my plugin

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 21, 2022, 6:22am UTC](https://meta.discourse.org/t/flair-url-is-always-null-in-sql-query/230555/2 "2022-06-21T06:22:20Z")

</div>

I think the data from that column may have been moved at some point. `flair_upload_id` seems promising:

```plaintext
SELECT g.name,
       g.flair_upload_id, 
       u.url, 
       u.original_filename
FROM groups g
JOIN uploads u on g.flair_upload_id = u.id

```

---

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [June 21, 2022, 8:06am UTC](https://meta.discourse.org/t/flair-url-is-always-null-in-sql-query/230555/3 "2022-06-21T08:06:26Z")

</div>

Thanks! This seems like a bit circuitous but it worked! 😁

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [June 21, 2022, 8:59am UTC](https://meta.discourse.org/t/flair-url-is-always-null-in-sql-query/230555/4 "2022-06-21T08:59:31Z")

</div>

Yeah, the `flair_url` column isn’t used any more - we tell Rails to ignore it in our ruby code:

> <https://github.com/discourse/discourse/blob/03ffb0bf27d76a47ef5a3049ea76a4240b5dc3b8/app/models/group.rb#L7-L10>

Looks like that’s been the case for a while now. @vinothkannans any reason we shouldn’t go ahead and drop it in a post-deploy migration?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [June 21, 2022, 12:31pm UTC](https://meta.discourse.org/t/flair-url-is-always-null-in-sql-query/230555/5 "2022-06-21T12:31:59Z")

</div>

> <https://github.com/discourse/discourse/blob/03ffb0bf27d76a47ef5a3049ea76a4240b5dc3b8/app/models/group.rb#L6-L7>

Yes, we should drop it now. We already passed that time long ago.
