Skip to content

Fix MySQL CAST AS TEXT regression#3710

Merged
bobvandevijver merged 4 commits intobolt:6.1from
shirkalab:6.1
Apr 27, 2026
Merged

Fix MySQL CAST AS TEXT regression#3710
bobvandevijver merged 4 commits intobolt:6.1from
shirkalab:6.1

Conversation

@kouz75
Copy link
Copy Markdown
Contributor

@kouz75 kouz75 commented Apr 25, 2026

With MySQL/MariaDB orderby failed.

A test have been replaced for bolt 6 :

  // Before (Bolt 5 / pre-DBAL v4) — correct:
  // TEXT→CHAR for everything EXCEPT SQLite → MySQL gets CHAR ✓                                                                                 
  if (! mb_strpos($backend_driver, 'sqlite') && $this->second === 'TEXT') {
      $this->second = 'CHAR';                                                                                                                   
  }                                                                                                                                           
                                                                                                                                                
  // After (Bolt 6.1.x) — regression:                                                                                                         
  // TEXT→CHAR ONLY for SQLite → MySQL gets TEXT ✗
  if ($platform instanceof SQLitePlatform && $this->second === 'TEXT') {                                                                        
      $this->second = 'CHAR';
  }                                                                                                                                             

to reproduce the bug:

Create the content type

  products:
      name: Products                                                                                                                            
      singular_name: Product
      title_format: "{title}-{subtitle}"                                                                                                        
      fields:                                                                                                                                 
          title:
              type: text
          subtitle:                                                                                                                             
              type: text

in a twig file

 {% setcontent allProducts = 'products' limit 200 orderby 'title' %}                                                                         
 {{ allProducts|length }}                                                                                                                      

you should have the error
Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TEXT)), LOWER(value_21) FROM (SELECT b0_.id AS id_0, b0_.content_type AS content' at line 1")

Comment thread src/Doctrine/Query/Cast.php Outdated
Co-authored-by: Bob van de Vijver <bobvandevijver@users.noreply.github.com>
@kouz75 kouz75 marked this pull request as ready for review April 27, 2026 07:32
Comment thread src/Doctrine/Query/Cast.php
Co-authored-by: Bob van de Vijver <bobvandevijver@users.noreply.github.com>
@bobvandevijver bobvandevijver enabled auto-merge (squash) April 27, 2026 09:54
@bobvandevijver bobvandevijver merged commit 183d208 into bolt:6.1 Apr 27, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants