SQL strict mode fixes. Closes #127

This commit is contained in:
Dan Cryer 2013-10-08 07:45:20 +01:00
commit cc09d95a3d
7 changed files with 145 additions and 32 deletions

View file

@ -0,0 +1,42 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2013, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
*/
namespace PHPCI\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Generate console command - Reads the database and generates models and stores.
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*/
class UpdateCommand extends Command
{
protected function configure()
{
$this
->setName('phpci:update')
->setDescription('Update the database to reflect modified models.');
}
/**
* Generates Model and Store classes by reading database meta data.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// Update the database:
$gen = new \b8\Database\Generator(\b8\Database::getConnection(), 'PHPCI', './PHPCI/Model/Base/');
$gen->generate();
}
}

View file

@ -90,52 +90,64 @@ class BuildBase extends Model
'length' => '11',
'primary_key' => true,
'auto_increment' => true,
'default' => null,
),
'project_id' => array(
'type' => 'int',
'length' => '11',
'default' => null,
),
'commit_id' => array(
'type' => 'varchar',
'length' => '50',
'nullable' => true,
'default' => null,
),
'status' => array(
'type' => 'tinyint',
'length' => '4',
'default' => '0',
),
'log' => array(
'type' => 'longtext',
'length' => '',
'nullable' => true,
'default' => null,
),
'branch' => array(
'type' => 'varchar',
'length' => '50',
'default' => 'master',
),
'created' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
'default' => null,
),
'started' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
'default' => null,
),
'finished' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
'default' => null,
),
'plugins' => array(
'type' => 'text',
'length' => '',
'nullable' => true,
'default' => null,
),
'committer_email' => array(
'type' => 'varchar',
'length' => '512',
'nullable' => true,
'default' => null,
),
);
@ -330,7 +342,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('Id', $value);
$this->_validateInt('Id', $value);
if ($this->data['id'] == $value) {
if ($this->data['id'] === $value) {
return;
}
@ -349,7 +361,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('ProjectId', $value);
$this->_validateInt('ProjectId', $value);
if ($this->data['project_id'] == $value) {
if ($this->data['project_id'] === $value) {
return;
}
@ -361,14 +373,13 @@ class BuildBase extends Model
/**
* Set the value of CommitId / commit_id.
*
* Must not be null.
* @param $value string
*/
public function setCommitId($value)
{
$this->_validateNotNull('CommitId', $value);
$this->_validateString('CommitId', $value);
if ($this->data['commit_id'] == $value) {
if ($this->data['commit_id'] === $value) {
return;
}
@ -387,7 +398,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('Status', $value);
$this->_validateInt('Status', $value);
if ($this->data['status'] == $value) {
if ($this->data['status'] === $value) {
return;
}
@ -405,7 +416,7 @@ class BuildBase extends Model
{
$this->_validateString('Log', $value);
if ($this->data['log'] == $value) {
if ($this->data['log'] === $value) {
return;
}
@ -424,7 +435,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('Branch', $value);
$this->_validateString('Branch', $value);
if ($this->data['branch'] == $value) {
if ($this->data['branch'] === $value) {
return;
}
@ -442,7 +453,7 @@ class BuildBase extends Model
{
$this->_validateDate('Created', $value);
if ($this->data['created'] == $value) {
if ($this->data['created'] === $value) {
return;
}
@ -460,7 +471,7 @@ class BuildBase extends Model
{
$this->_validateDate('Started', $value);
if ($this->data['started'] == $value) {
if ($this->data['started'] === $value) {
return;
}
@ -478,7 +489,7 @@ class BuildBase extends Model
{
$this->_validateDate('Finished', $value);
if ($this->data['finished'] == $value) {
if ($this->data['finished'] === $value) {
return;
}
@ -496,7 +507,7 @@ class BuildBase extends Model
{
$this->_validateString('Plugins', $value);
if ($this->data['plugins'] == $value) {
if ($this->data['plugins'] === $value) {
return;
}
@ -514,7 +525,7 @@ class BuildBase extends Model
{
$this->_validateString('CommitterEmail', $value);
if ($this->data['committer_email'] == $value) {
if ($this->data['committer_email'] === $value) {
return;
}

View file

@ -33,6 +33,7 @@ class BuildMetaBase extends Model
*/
protected $data = array(
'id' => null,
'project_id' => null,
'build_id' => null,
'key' => null,
'value' => null,
@ -43,6 +44,7 @@ class BuildMetaBase extends Model
*/
protected $getters = array(
'id' => 'getId',
'project_id' => 'getProjectId',
'build_id' => 'getBuildId',
'key' => 'getKey',
'value' => 'getValue',
@ -54,6 +56,7 @@ class BuildMetaBase extends Model
*/
protected $setters = array(
'id' => 'setId',
'project_id' => 'setProjectId',
'build_id' => 'setBuildId',
'key' => 'setKey',
'value' => 'setValue',
@ -69,19 +72,29 @@ class BuildMetaBase extends Model
'length' => '10',
'primary_key' => true,
'auto_increment' => true,
'default' => null,
),
'project_id' => array(
'type' => 'int',
'length' => '11',
'default' => null,
),
'build_id' => array(
'type' => 'int',
'length' => '11',
'nullable' => true,
'default' => null,
),
'key' => array(
'type' => 'varchar',
'length' => '255',
'default' => '',
),
'value' => array(
'type' => 'text',
'length' => '',
'nullable' => true,
'default' => null,
),
);
@ -120,6 +133,19 @@ class BuildMetaBase extends Model
return $rtn;
}
/**
* Get the value of ProjectId / project_id.
*
* @return int
*/
public function getProjectId()
{
$rtn = $this->data['project_id'];
return $rtn;
}
/**
* Get the value of BuildId / build_id.
*
@ -169,7 +195,7 @@ class BuildMetaBase extends Model
{
$this->_validateNotNull('Id', $value);
$this->_validateInt('Id', $value);
if ($this->data['id'] == $value) {
if ($this->data['id'] === $value) {
return;
}
@ -179,16 +205,34 @@ class BuildMetaBase extends Model
}
/**
* Set the value of BuildId / build_id.
* Set the value of ProjectId / project_id.
*
* Must not be null.
* @param $value int
*/
public function setProjectId($value)
{
$this->_validateNotNull('ProjectId', $value);
$this->_validateInt('ProjectId', $value);
if ($this->data['project_id'] === $value) {
return;
}
$this->data['project_id'] = $value;
$this->_setModified('project_id');
}
/**
* Set the value of BuildId / build_id.
*
* @param $value int
*/
public function setBuildId($value)
{
$this->_validateNotNull('BuildId', $value);
$this->_validateInt('BuildId', $value);
if ($this->data['build_id'] == $value) {
if ($this->data['build_id'] === $value) {
return;
}
@ -207,7 +251,7 @@ class BuildMetaBase extends Model
{
$this->_validateNotNull('Key', $value);
$this->_validateString('Key', $value);
if ($this->data['key'] == $value) {
if ($this->data['key'] === $value) {
return;
}
@ -225,7 +269,7 @@ class BuildMetaBase extends Model
{
$this->_validateString('Value', $value);
if ($this->data['value'] == $value) {
if ($this->data['value'] === $value) {
return;
}

View file

@ -76,31 +76,38 @@ class ProjectBase extends Model
'length' => '11',
'primary_key' => true,
'auto_increment' => true,
'default' => null,
),
'title' => array(
'type' => 'varchar',
'length' => '250',
'default' => '',
),
'reference' => array(
'type' => 'varchar',
'length' => '250',
'default' => '',
),
'git_key' => array(
'type' => 'text',
'length' => '',
'default' => null,
),
'type' => array(
'type' => 'varchar',
'length' => '50',
'default' => '',
),
'token' => array(
'type' => 'varchar',
'length' => '50',
'nullable' => true,
'default' => null,
),
'access_information' => array(
'type' => 'varchar',
'length' => '250',
'default' => null,
),
);
@ -219,7 +226,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('Id', $value);
$this->_validateInt('Id', $value);
if ($this->data['id'] == $value) {
if ($this->data['id'] === $value) {
return;
}
@ -238,7 +245,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('Title', $value);
$this->_validateString('Title', $value);
if ($this->data['title'] == $value) {
if ($this->data['title'] === $value) {
return;
}
@ -257,7 +264,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('Reference', $value);
$this->_validateString('Reference', $value);
if ($this->data['reference'] == $value) {
if ($this->data['reference'] === $value) {
return;
}
@ -276,7 +283,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('GitKey', $value);
$this->_validateString('GitKey', $value);
if ($this->data['git_key'] == $value) {
if ($this->data['git_key'] === $value) {
return;
}
@ -295,7 +302,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('Type', $value);
$this->_validateString('Type', $value);
if ($this->data['type'] == $value) {
if ($this->data['type'] === $value) {
return;
}
@ -313,7 +320,7 @@ class ProjectBase extends Model
{
$this->_validateString('Token', $value);
if ($this->data['token'] == $value) {
if ($this->data['token'] === $value) {
return;
}
@ -332,7 +339,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('AccessInformation', $value);
$this->_validateString('AccessInformation', $value);
if ($this->data['access_information'] == $value) {
if ($this->data['access_information'] === $value) {
return;
}

View file

@ -70,22 +70,27 @@ class UserBase extends Model
'length' => '11',
'primary_key' => true,
'auto_increment' => true,
'default' => null,
),
'email' => array(
'type' => 'varchar',
'length' => '250',
'default' => '',
),
'hash' => array(
'type' => 'varchar',
'length' => '250',
'default' => '',
),
'is_admin' => array(
'type' => 'tinyint',
'length' => '1',
'default' => '0',
),
'name' => array(
'type' => 'varchar',
'length' => '250',
'default' => '',
),
);
@ -179,7 +184,7 @@ class UserBase extends Model
{
$this->_validateNotNull('Id', $value);
$this->_validateInt('Id', $value);
if ($this->data['id'] == $value) {
if ($this->data['id'] === $value) {
return;
}
@ -198,7 +203,7 @@ class UserBase extends Model
{
$this->_validateNotNull('Email', $value);
$this->_validateString('Email', $value);
if ($this->data['email'] == $value) {
if ($this->data['email'] === $value) {
return;
}
@ -217,7 +222,7 @@ class UserBase extends Model
{
$this->_validateNotNull('Hash', $value);
$this->_validateString('Hash', $value);
if ($this->data['hash'] == $value) {
if ($this->data['hash'] === $value) {
return;
}
@ -236,7 +241,7 @@ class UserBase extends Model
{
$this->_validateNotNull('IsAdmin', $value);
$this->_validateInt('IsAdmin', $value);
if ($this->data['is_admin'] == $value) {
if ($this->data['is_admin'] === $value) {
return;
}
@ -255,7 +260,7 @@ class UserBase extends Model
{
$this->_validateNotNull('Name', $value);
$this->_validateString('Name', $value);
if ($this->data['name'] == $value) {
if ($this->data['name'] === $value) {
return;
}

View file

@ -23,6 +23,7 @@ require('bootstrap.php');
use PHPCI\Command\RunCommand;
use PHPCI\Command\GenerateCommand;
use PHPCI\Command\UpdateCommand;
use PHPCI\Command\InstallCommand;
use PHPCI\Command\DaemonCommand;
use Symfony\Component\Console\Application;
@ -30,6 +31,7 @@ use Symfony\Component\Console\Application;
$application = new Application();
$application->add(new RunCommand);
$application->add(new InstallCommand);
$application->add(new UpdateCommand);
$application->add(new GenerateCommand);
$application->add(new DaemonCommand);
$application->run();

View file

@ -27,7 +27,9 @@ var timePlugin = PHPCI.UiPlugin.extend({
'</table>';
},
onUpdate: function(build) {
onUpdate: function(e) {
var build = e.queryData;
$('#created').text(build.created);
$('#started').text(build.started);
$('#finished').text(build.finished);