laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 31 forks source link

Laravel + Vitess Compatibility #1417

Open hellracer opened 5 years ago

hellracer commented 5 years ago

Vitess is a database clustering system for horizontal scaling of MySQL (born at youtube)

In order for us to connect our framework to vitess we can disable sending this construct set this option first.

options' => array(
                PDO::ATTR_EMULATE_PREPARES => true
             ),
vitess => true,

then code change on src/Illuminate/Database/Connectors/MySqlConnector.php

{
        if (isset($config['modes'])) {
            $this->setCustomModes($connection, $config);
        } elseif (isset($config['strict'])) {
            if ($config['strict']) {
                $connection->prepare($this->strictMode($connection))->execute();
            } else {
                if(!$config['vitess'])
                $connection->prepare("set session sql_mode='NO_ENGINE_SUBSTITUTION'")->execute();
            }
        }
  }
hellracer commented 5 years ago

Actually it shouldn't be considered as a feature request at all because if you set the modes => null This shouldn't be executed in the first place, it just so happen that it was on the else part of the code } elseif (isset($config['strict'])) { the code assumes the developer want the code below

$connection->prepare("set session sql_mode='NO_ENGINE_SUBSTITUTION'")->execute();

Imho the application was fine wether you don't set this explicitly because if the administrator really want to implement whatever modes he/she wants, then I believed that the mysql config is the right place to do it not in the code/framework.

This is just my 0.2$

ans-4175 commented 4 years ago

Hey @hellracer how is it going integrating Vitess to used by Laravel app?