@@ -2895,6 +2895,91 @@ public function testTranslatesUtf8SELECT() {
28952895 $ this ->assertQuery ( 'DELETE FROM _options ' );
28962896 }
28972897
2898+ public function testTranslateLikeBinaryAndGlob () {
2899+ // Create a temporary table for testing
2900+ $ this ->assertQuery (
2901+ "CREATE TABLE _tmp_table (
2902+ ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
2903+ name varchar(20) NOT NULL default ''
2904+ ); "
2905+ );
2906+
2907+ // Insert data into the table
2908+ $ this ->assertQuery ( "INSERT INTO _tmp_table (name) VALUES ('first'); " );
2909+ $ this ->assertQuery ( "INSERT INTO _tmp_table (name) VALUES ('FIRST'); " );
2910+ $ this ->assertQuery ( "INSERT INTO _tmp_table (name) VALUES ('second'); " );
2911+ $ this ->assertQuery ( "INSERT INTO _tmp_table (name) VALUES (''); " );
2912+ $ this ->assertQuery ( "INSERT INTO _tmp_table (name) VALUES ('%special%'); " );
2913+ $ this ->assertQuery ( 'INSERT INTO _tmp_table (name) VALUES (NULL); ' );
2914+ $ this ->assertQuery ( "INSERT INTO _tmp_table (name) VALUES ('special%chars'); " );
2915+ $ this ->assertQuery ( "INSERT INTO _tmp_table (name) VALUES ('special_chars'); " );
2916+ $ this ->assertQuery ( "INSERT INTO _tmp_table (name) VALUES ('special \\chars'); " );
2917+
2918+ // Test case-sensitive LIKE BINARY
2919+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name LIKE BINARY 'first' " );
2920+ $ this ->assertCount ( 1 , $ result );
2921+ $ this ->assertEquals ( 'first ' , $ result [0 ]->name );
2922+
2923+ // Test case-sensitive LIKE BINARY with wildcard %
2924+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name LIKE BINARY 'f%' " );
2925+ $ this ->assertCount ( 1 , $ result );
2926+ $ this ->assertEquals ( 'first ' , $ result [0 ]->name );
2927+
2928+ // Test case-sensitive LIKE BINARY with wildcard _
2929+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name LIKE BINARY 'f_rst' " );
2930+ $ this ->assertCount ( 1 , $ result );
2931+ $ this ->assertEquals ( 'first ' , $ result [0 ]->name );
2932+
2933+ // Test case-insensitive LIKE
2934+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name LIKE 'FIRST' " );
2935+ $ this ->assertCount ( 2 , $ result ); // Should match both 'first' and 'FIRST'
2936+
2937+ // Test mixed case with LIKE BINARY
2938+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name LIKE BINARY 'First' " );
2939+ $ this ->assertCount ( 0 , $ result );
2940+
2941+ // Test no matches with LIKE BINARY
2942+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name LIKE BINARY 'third' " );
2943+ $ this ->assertCount ( 0 , $ result );
2944+
2945+ // Test GLOB equivalent for case-sensitive matching with wildcard
2946+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name GLOB 'f*' " );
2947+ $ this ->assertCount ( 1 , $ result );
2948+ $ this ->assertEquals ( 'first ' , $ result [0 ]->name );
2949+
2950+ // Test GLOB with single character wildcard
2951+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name GLOB 'f?rst' " );
2952+ $ this ->assertCount ( 1 , $ result );
2953+ $ this ->assertEquals ( 'first ' , $ result [0 ]->name );
2954+
2955+ // Test GLOB with no matches
2956+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name GLOB 'S*' " );
2957+ $ this ->assertCount ( 0 , $ result );
2958+
2959+ // Test GLOB case sensitivity with LIKE and GLOB
2960+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name GLOB 'first'; " );
2961+ $ this ->assertCount ( 1 , $ result ); // Should only match 'first'
2962+
2963+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name GLOB 'FIRST'; " );
2964+ $ this ->assertCount ( 1 , $ result ); // Should only match 'FIRST'
2965+
2966+ // Test NULL comparison with LIKE BINARY
2967+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name LIKE BINARY 'first'; " );
2968+ $ this ->assertCount ( 1 , $ result );
2969+ $ this ->assertEquals ( 'first ' , $ result [0 ]->name );
2970+
2971+ $ result = $ this ->assertQuery ( 'SELECT * FROM _tmp_table WHERE name LIKE BINARY NULL; ' );
2972+ $ this ->assertCount ( 0 , $ result ); // NULL comparison should return no results
2973+
2974+ // Test pattern with special characters using LIKE BINARY
2975+ $ result = $ this ->assertQuery ( "SELECT * FROM _tmp_table WHERE name LIKE BINARY '%special%'; " );
2976+ $ this ->assertCount ( 4 , $ result );
2977+ $ this ->assertEquals ( '%special% ' , $ result [0 ]->name );
2978+ $ this ->assertEquals ( 'special%chars ' , $ result [1 ]->name );
2979+ $ this ->assertEquals ( 'special_chars ' , $ result [2 ]->name );
2980+ $ this ->assertEquals ( 'specialchars ' , $ result [3 ]->name );
2981+ }
2982+
28982983 public function testOnConflictReplace () {
28992984 $ this ->assertQuery (
29002985 "CREATE TABLE _tmp_table (
0 commit comments