Skip to content

Commit

Permalink
Shift traits around.
Browse files Browse the repository at this point in the history
This solves the parent + child drivers from including sql related
traits. Instead the child class includes only its platform related
trait.
  • Loading branch information
markstory committed Mar 25, 2013
1 parent c24d6e6 commit b7f1848
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 30 deletions.
17 changes: 17 additions & 0 deletions lib/Cake/Model/Datasource/Database/Dialect/MysqlDialectTrait.php
Expand Up @@ -18,13 +18,30 @@
namespace Cake\Model\Datasource\Database\Dialect;

use Cake\Error;
use Cake\Model\Datasource\Database\SqlDialectTrait;

/**
* Contains functions that encapsulates the SQL dialect used by MySQL,
* including query translators and schema introspection.
*/
trait MysqlDialectTrait {

use SqlDialectTrait;

/**
* String used to start a database identifier quoting to make it safe
*
* @var string
*/
public $startQuote = '`';

/**
* String used to end a database identifier quoting to make it safe
*
* @var string
*/
public $endQuote = '`';

/**
* Get the SQL to list the tables in MySQL
*
Expand Down
Expand Up @@ -20,13 +20,30 @@
use Cake\Model\Datasource\Database\Expression\UnaryExpression;
use Cake\Model\Datasource\Database\Expression\FunctionExpression;
use Cake\Model\Datasource\Database\Query;
use Cake\Model\Datasource\Database\SqlDialectTrait;

/**
* Contains functions that encapsulates the SQL dialect used by Postgres,
* including query translators and schema introspection.
*/
trait PostgresDialectTrait {

use SqlDialectTrait;

/**
* String used to start a database identifier quoting to make it safe
*
* @var string
**/
public $startQuote = '"';

/**
* String used to end a database identifier quoting to make it safe
*
* @var string
**/
public $endQuote = '"';

/**
* Returns a query that has been transformed to the specific SQL dialect
* by changing or re-arranging SQL clauses as required.
Expand Down
17 changes: 17 additions & 0 deletions lib/Cake/Model/Datasource/Database/Dialect/SqliteDialectTrait.php
Expand Up @@ -19,9 +19,26 @@

use Cake\Model\Datasource\Database\Expression\FunctionExpression;
use Cake\Model\Datasource\Database\Query;
use Cake\Model\Datasource\Database\SqlDialectTrait;

trait SqliteDialectTrait {

use SqlDialectTrait;

/**
* String used to start a database identifier quoting to make it safe
*
* @var string
**/
public $startQuote = '"';

/**
* String used to end a database identifier quoting to make it safe
*
* @var string
**/
public $endQuote = '"';

/**
* Returns an dictionary of expressions to be transformed when compiling a Query
* to SQL. Array keys are method names to be called in this class
Expand Down
2 changes: 0 additions & 2 deletions lib/Cake/Model/Datasource/Database/Driver.php
Expand Up @@ -26,8 +26,6 @@
**/
abstract class Driver {

use SqlDialectTrait;

/**
* Establishes a connection to the database server
*
Expand Down
14 changes: 0 additions & 14 deletions lib/Cake/Model/Datasource/Database/Driver/Mysql.php
Expand Up @@ -25,20 +25,6 @@ class Mysql extends \Cake\Model\Datasource\Database\Driver {
use PDODriverTrait;
use MysqlDialectTrait;

/**
* String used to start a database identifier quoting to make it safe
*
* @var string
**/
public $startQuote = '`';

/**
* String used to end a database identifier quoting to make it safe
*
* @var string
**/
public $endQuote = '`';

/**
* Base configuration settings for MySQL driver
*
Expand Down
14 changes: 0 additions & 14 deletions lib/Cake/Model/Datasource/Database/SqlDialectTrait.php
Expand Up @@ -19,20 +19,6 @@

trait SqlDialectTrait {

/**
* String used to start a database identifier quoting to make it safe
*
* @var string
**/
public $startQuote = '"';

/**
* String used to end a database identifier quoting to make it safe
*
* @var string
**/
public $endQuote = '"';

/**
* Quotes a database identifier (a column name, table name, etc..) to
* be used safely in queries without the risk of using reserver words
Expand Down

0 comments on commit b7f1848

Please sign in to comment.