diff --git a/TODO b/TODO
index e0db5ee900040a4bdffef79102a90b6770253ebf..5a3bae3295490d6bc7b106ff2e218bcbbbc78812 100644
--- a/TODO
+++ b/TODO
@@ -6,4 +6,4 @@
 - [ ] Support for other SQL dialects
 - [ ] JSON output
 - [ ] Huge files
-- [ ] Maybe truncate long 'at or near "blah"' strings
+- [X] Maybe truncate long 'at or near "blah"' strings
diff --git a/lib/sqlint/linter.rb b/lib/sqlint/linter.rb
index 432383a0a46a127d419a0e36287b723494ccae1b..848cf6d3825e45bb4e5f6024e1cf858a906115f0 100644
--- a/lib/sqlint/linter.rb
+++ b/lib/sqlint/linter.rb
@@ -31,7 +31,7 @@ module SQLint
       rescue PgQuery::ParseError => e
         offset = e.location + parse_state.offset
         line_number, column_number = find_absolute_position(offset)
-        lint = Lint.new(@filename, line_number, column_number, :error, e.message)
+        lint = Lint.new(@filename, line_number, column_number, :error, clean_message(e.message))
 
         input_from_error = parse_state.input[e.location..-1]
         semicolon_pos = input_from_error.index(";") if input_from_error
@@ -54,5 +54,9 @@ module SQLint
       column_number = lines_before_error.any? ? lines_before_error.last.size : 1
       [line_number, column_number]
     end
+
+    def clean_message(message)
+      message.gsub(/(?<=at or near ")(.*)(?=")/) { |match| match[0..49] }
+    end
   end
 end
diff --git a/spec/linter_spec.rb b/spec/linter_spec.rb
index 941aa50be4a10b193736e80cdc869f84765837c7..dc05c9761ca21f900ee5535a76ddb50ebc55adaa 100644
--- a/spec/linter_spec.rb
+++ b/spec/linter_spec.rb
@@ -69,10 +69,19 @@ RSpec.describe SQLint::Linter do
 
     context "when there is a second error at the end of the file" do
       let(:input) { "WIBBLE; SELECT 1 FROM" }
-      it "report 2 errors" do
+      it "reports 2 errors" do
         expect(results).to eq([error(1, 1, WIBBLE_ERROR),
                                error(1, 21, "syntax error at end of input")])
       end
     end
   end
+
+  describe "long error messages" do
+    context "when the 'at or near' fragment is longer than 50 characters" do
+      let(:input) { "SELECT '" + 'x' * 100 }
+      it "truncates the fragment" do
+        expect(results).to eq([error(1, 8, "unterminated quoted string at or near \"'#{'x' * 49}\"")])
+      end
+    end
+  end
 end