diff --git a/lib/parsers/text_parser.js b/lib/parsers/text_parser.js
index 5af86674aa..573d09ad4d 100644
--- a/lib/parsers/text_parser.js
+++ b/lib/parsers/text_parser.js
@@ -105,7 +105,7 @@ function compile(fields, options, config) {
       );
       parserFn(`this.wrap${i} = {
         type: ${helpers.srcEscape(typeNames[field.columnType])},
-        length: ${helpers.srcEscape(field.columnLength)},
+        length: ${field.columnLength},
         db: ${helpers.srcEscape(field.schema)},
         table: ${helpers.srcEscape(field.table)},
         name: ${helpers.srcEscape(field.name)},
diff --git a/test/integration/connection/test-typecast.js b/test/integration/connection/test-typecast.js
index 8dd82812d0..db5a741abe 100644
--- a/test/integration/connection/test-typecast.js
+++ b/test/integration/connection/test-typecast.js
@@ -11,7 +11,9 @@ connection.query(
   {
     sql: 'select "foo uppercase" as foo',
     typeCast: function(field, next) {
+      assert.equal("number", typeof field.length);
       if (field.type === 'VAR_STRING') {
+
         return field.string().toUpperCase();
       }
       return next();