FIX: custom SQL with a trailing comment might break BadgeGranter SQL (PR #9285)

For example given a custom badge with SQL:

SELECT 1
-- I am a comment

You end up with

FROM (SELECT 1
-- I am a comment) q

This fix adds newlines so you end up with the now-valid:

FROM (
  SELECT 1
-- I am a comment
) q

GitHub

Can we add a test to this one?

1 Like

@Supermathie, there are other lines with similar problems in the same file, discourse/badge_granter.rb at 7180fcd39f20ca2a77ed33d4b09960193033e97c · discourse/discourse · GitHub for example.

1 Like