Skip to content

Commit 21ad545

Browse files
authored
Merge pull request #1400 from testn/patch-1
Cache lazy-evaluated field
2 parents 61d473f + f2abaa8 commit 21ad545

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/packets/column_definition.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,19 @@ const addString = function(name) {
112112
get: function() {
113113
const start = this[`_${name}Start`];
114114
const end = start + this[`_${name}Length`];
115-
return StringParser.decode(
115+
const val = StringParser.decode(
116116
this._buf.slice(start, end),
117117
this.encoding === 'binary' ? this._clientEncoding : this.encoding
118118
);
119+
120+
Object.defineProperty(this, name, {
121+
value: val,
122+
writable: false,
123+
configurable: false,
124+
enumerable: false
125+
});
126+
127+
return val;
119128
}
120129
});
121130
};

0 commit comments

Comments
 (0)