Skip to content

Commit cd61d7b

Browse files
committed
avoid column length expectations for integers
The column length returned as result set metadata from the server only makes sense for DECIMAL column data types. For any other type, the value is non-deterministic and this kind of display width for integer data types was deprecated on MySQL 8.0.17. https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html This patch updates some integration tests that are failing due to an incorrect assumption about the "columnLength" value, by avoiding to assert any expectation about it altogether. In this case, the tests are expecting a statement to yield a column length of a number of digits, which is the case on MySQL 8.0.24 or older versions. However, MySQL 8.0.25 reports an additional digit to accommodate the sign for signed integers. The breaking change was introduced by the server to address the issues described in the following bug report: https://bugs.mysql.com/bug.php?id=99567
1 parent ed73cc5 commit cd61d7b

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

test/integration/connection/test-binary-multiple-results.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// This file was modified by Oracle on June 2, 2021.
2+
// The test has been updated to remove all expectations with regards to the
3+
// "columnLength" metadata field.
4+
// Modifications copyright (c) 2021, Oracle and/or its affiliates.
5+
16
'use strict';
27

38
const mysql = require('../../common.js').createConnection({
@@ -33,7 +38,6 @@ const fields1 = [
3338
{
3439
catalog: 'def',
3540
characterSet: 63,
36-
columnLength: 1,
3741
columnType: 8,
3842
decimals: 0,
3943
flags: 129,
@@ -48,7 +52,6 @@ const nr_fields = [
4852
{
4953
catalog: 'def',
5054
characterSet: 63,
51-
columnLength: 11,
5255
columnType: 3,
5356
decimals: 0,
5457
flags: 0,
@@ -140,7 +143,13 @@ function do_test(testIndex) {
140143
return void 0;
141144
}
142145

143-
return c.inspect();
146+
const column = c.inspect();
147+
// "columnLength" is non-deterministic and the display width for integer
148+
// data types was deprecated on MySQL 8.0.17.
149+
// https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
150+
delete column.columnLength;
151+
152+
return column;
144153
};
145154

146155
assert.deepEqual(expectation[0], _rows);

test/integration/connection/test-execute-nocolumndef.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// This file was modified by Oracle on June 2, 2021.
2+
// The test has been updated to remove all expectations with regards to the
3+
// "columnLength" metadata field.
4+
// Modifications copyright (c) 2021, Oracle and/or its affiliates.
5+
16
'use strict';
27

38
const common = require('../../common');
@@ -47,7 +52,6 @@ const expectedFields = [
4752
table: '',
4853
orgTable: '',
4954
characterSet: 63,
50-
columnLength: 3,
5155
columnType: 8,
5256
flags: 161,
5357
decimals: 0
@@ -60,7 +64,6 @@ const expectedFields = [
6064
table: '',
6165
orgTable: '',
6266
characterSet: 224,
63-
columnLength: 76,
6467
columnType: 253,
6568
flags: 1,
6669
decimals: 31
@@ -73,7 +76,6 @@ const expectedFields = [
7376
table: '',
7477
orgTable: '',
7578
characterSet: 224,
76-
columnLength: 256,
7779
columnType: 253,
7880
flags: 0,
7981
decimals: 31
@@ -86,7 +88,6 @@ const expectedFields = [
8688
table: '',
8789
orgTable: '',
8890
characterSet: 224,
89-
columnLength: 25264128,
9091
columnType: 250,
9192
flags: 0,
9293
decimals: 31
@@ -99,7 +100,6 @@ const expectedFields = [
99100
table: '',
100101
orgTable: '',
101102
characterSet: 224,
102-
columnLength: 40,
103103
columnType: 253,
104104
flags: 0,
105105
decimals: 31
@@ -112,7 +112,6 @@ const expectedFields = [
112112
table: '',
113113
orgTable: '',
114114
characterSet: 224,
115-
columnLength: 16384,
116115
columnType: 253,
117116
flags: 0,
118117
decimals: 31
@@ -125,7 +124,6 @@ const expectedFields = [
125124
table: '',
126125
orgTable: '',
127126
characterSet: 224,
128-
columnLength: 256,
129127
columnType: 253,
130128
flags: 0,
131129
decimals: 31
@@ -138,7 +136,6 @@ const expectedFields = [
138136
table: '',
139137
orgTable: '',
140138
characterSet: 224,
141-
columnLength: 16384,
142139
columnType: 253,
143140
flags: 0,
144141
decimals: 31
@@ -151,7 +148,6 @@ const expectedFields = [
151148
table: '',
152149
orgTable: '',
153150
characterSet: 224,
154-
columnLength: 4096,
155151
columnType: 253,
156152
flags: 0,
157153
decimals: 31
@@ -164,7 +160,6 @@ const expectedFields = [
164160
table: '',
165161
orgTable: '',
166162
characterSet: 63,
167-
columnLength: 10,
168163
columnType: 8,
169164
flags: 160,
170165
decimals: 0
@@ -177,7 +172,6 @@ const expectedFields = [
177172
table: '',
178173
orgTable: '',
179174
characterSet: 63,
180-
columnLength: 4,
181175
columnType: 5,
182176
flags: 128,
183177
decimals: 2
@@ -190,7 +184,6 @@ const expectedFields = [
190184
table: '',
191185
orgTable: '',
192186
characterSet: 224,
193-
columnLength: 1020,
194187
columnType: 253,
195188
flags: 1,
196189
decimals: 31
@@ -201,6 +194,9 @@ process.on('exit', () => {
201194
assert.deepEqual(rows, expectedRows);
202195
fields.forEach((f, index) => {
203196
const fi = f.inspect();
197+
// "columnLength" is non-deterministic
198+
delete fi.columnLength;
199+
204200
assert.deepEqual(
205201
Object.keys(fi).sort(),
206202
Object.keys(expectedFields[index]).sort()

test/integration/connection/test-multiple-results.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// This file was modified by Oracle on June 2, 2021.
2+
// The test has been updated to remove all expectations with regards to the
3+
// "columnLength" metadata field.
4+
// Modifications copyright (c) 2021, Oracle and/or its affiliates.
5+
16
'use strict';
27

38
const mysql = require('../../common.js').createConnection({
@@ -32,7 +37,6 @@ const fields1 = [
3237
{
3338
catalog: 'def',
3439
characterSet: 63,
35-
columnLength: 1,
3640
columnType: 8,
3741
decimals: 0,
3842
flags: 129,
@@ -47,7 +51,6 @@ const nr_fields = [
4751
{
4852
catalog: 'def',
4953
characterSet: 63,
50-
columnLength: 11,
5154
columnType: 3,
5255
decimals: 0,
5356
flags: 0,
@@ -137,7 +140,13 @@ function do_test(testIndex) {
137140
return void 0;
138141
}
139142

140-
return c.inspect();
143+
const column = c.inspect();
144+
// "columnLength" is non-deterministic and the display width for integer
145+
// data types was deprecated on MySQL 8.0.17.
146+
// https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
147+
delete column.columnLength;
148+
149+
return column;
141150
};
142151

143152
assert.deepEqual(expectation, [_rows, arrOrColumn(_columns), _numResults]);

0 commit comments

Comments
 (0)