Skip to content

Commit 1896807

Browse files
jakubkulhanclaude
andcommitted
Update TEXT and BLOB types to use raw binary data instead of base64 encoding
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c9419d9 commit 1896807

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

data-access-kit-replication/src/mysql.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,11 +698,8 @@ impl MySQLStreamDriver {
698698
}
699699
},
700700
ColumnValue::Blob(bytes) => {
701-
// Encode binary data as base64
702-
use base64::Engine;
703-
let engine = base64::engine::general_purpose::STANDARD;
704-
let encoded = engine.encode(bytes);
705-
zval.set_string(&encoded, false)?;
701+
// Set raw binary data directly to PHP
702+
zval.set_binary(bytes.clone());
706703
},
707704
ColumnValue::Json(bytes) => {
708705
// Try to parse as JSON string and then parse to PHP objects/arrays

data-access-kit-replication/test/StreamIntegrationTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,17 @@ public static function dataTypeProvider(): array
286286
['BINARY(5)', 'X\'48656c6c6f\'', 'Hello', null], // Use hex notation for binary data
287287
['VARBINARY(10)', 'X\'48656c6c6f\'', 'Hello', null], // Use hex notation for binary data
288288

289-
// Text Types - these are base64 encoded in binlog
290-
['TINYTEXT', '\'Tiny text\'', 'VGlueSB0ZXh0', null],
291-
['TEXT', '\'Regular text content\'', 'UmVndWxhciB0ZXh0IGNvbnRlbnQ=', null],
292-
['MEDIUMTEXT', '\'Medium text content\'', 'TWVkaXVtIHRleHQgY29udGVudA==', null],
293-
['LONGTEXT', '\'Long text content\'', 'TG9uZyB0ZXh0IGNvbnRlbnQ=', null],
294-
295-
// Binary Large Object Types - these are base64 encoded in binlog
296-
['TINYBLOB', 'X\'48656c6c6f\'', 'SGVsbG8=', null], // "Hello" in base64
297-
['BLOB', 'X\'48656c6c6f20576f726c64\'', 'SGVsbG8gV29ybGQ=', null], // "Hello World" in base64
298-
['MEDIUMBLOB', 'X\'48656c6c6f204d656469756d\'', 'SGVsbG8gTWVkaXVt', null], // "Hello Medium" in base64
299-
['LONGBLOB', 'X\'48656c6c6f204c6f6e67\'', 'SGVsbG8gTG9uZw==', null], // "Hello Long" in base64
289+
// Text Types - now returned as UTF-8 strings
290+
['TINYTEXT', '\'Tiny text\'', 'Tiny text', null],
291+
['TEXT', '\'Regular text content\'', 'Regular text content', null],
292+
['MEDIUMTEXT', '\'Medium text content\'', 'Medium text content', null],
293+
['LONGTEXT', '\'Long text content\'', 'Long text content', null],
294+
295+
// Binary Large Object Types - now returned as raw binary data
296+
['TINYBLOB', 'X\'48656c6c6f\'', 'Hello', null], // "Hello" from hex
297+
['BLOB', 'X\'48656c6c6f20576f726c64\'', 'Hello World', null], // "Hello World" from hex
298+
['MEDIUMBLOB', 'X\'48656c6c6f204d656469756d\'', 'Hello Medium', null], // "Hello Medium" from hex
299+
['LONGBLOB', 'X\'48656c6c6f204c6f6e67\'', 'Hello Long', null], // "Hello Long" from hex
300300

301301
// Special String Types - now return actual string values with fix-enum-set-metadata branch
302302
['ENUM(\'red\',\'green\',\'blue\')', '\'red\'', 'red', null], // ENUM returns actual string value
@@ -311,8 +311,8 @@ public static function dataTypeProvider(): array
311311

312312
// JSON Data Type - MySQL returns parsed stdClass objects
313313
['JSON', '\'{"key": "value", "number": 42}\'', (object)['key' => 'value', 'number' => 42], 'mysql'],
314-
// JSON Data Type - MariaDB returns base64 encoded strings
315-
['JSON', '\'{"key": "value", "number": 42}\'', 'eyJrZXkiOiAidmFsdWUiLCAibnVtYmVyIjogNDJ9', 'mariadb'],
314+
// JSON Data Type - MariaDB returns JSON string (not parsed)
315+
['JSON', '\'{"key": "value", "number": 42}\'', '{"key": "value", "number": 42}', 'mariadb'],
316316

317317
// NULL values for various types
318318
['VARCHAR(50)', 'NULL', null, null],

0 commit comments

Comments
 (0)