Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/features/mysql/mysql_sql_workspace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,28 @@ class MysqlSqlExecutionDelegate extends BaseSqlExecutionDelegate {
},
);
final colList = rs.cols.toList();
final outRows = [
for (final row in taken.items)
final pool = StringInternPool();
final outRows = <List<String>>[];
for (var r = 0; r < taken.items.length; r++) {
final row = taken.items[r];
outRows.add(
List.generate(
row.numOfColumns,
(i) {
final col = i < colList.length ? colList[i] : null;
return mysqlResultCellToDisplayString(
row.colAt(i),
column: col,
pool: pool,
);
},
),
];
);
if (kResultStringConvertYieldEvery > 0 &&
(r + 1) % kResultStringConvertYieldEvery == 0) {
await Future<void>.delayed(Duration.zero);
}
}
final truncated =
taken.truncated || (effectiveSql != sql && outRows.length >= cap);
final n = outRows.length;
Expand Down
12 changes: 12 additions & 0 deletions test/core/database/mysql_grid_types_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:mysql_client/mysql_client.dart';
import 'package:mysql_client/mysql_protocol.dart';
import 'package:querya_desktop/core/database/mysql_result_cells.dart';
import 'package:querya_desktop/core/database/result_row_string_convert.dart';
import 'package:querya_desktop/core/database/table_mutation_engine.dart';

void main() {
Expand Down Expand Up @@ -134,5 +135,16 @@ void main() {
expect(mysqlResultCellToDisplayString('1', column: col), 'true');
expect(mysqlResultCellToDisplayString('0', column: col), 'false');
});

test('deduplicates identical strings via StringInternPool', () {
final pool = StringInternPool();
final str1 = String.fromCharCodes('intern_test'.codeUnits);
final str2 = String.fromCharCodes('intern_test'.codeUnits);
expect(identical(str1, str2), isFalse);

final res1 = mysqlResultCellToDisplayString(str1, pool: pool);
final res2 = mysqlResultCellToDisplayString(str2, pool: pool);
expect(identical(res1, res2), isTrue);
});
});
}
Loading