Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow comments in queries to contain characters after # #43

Merged
merged 1 commit into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/ETL/DbEntity/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function initialize(stdClass $config, $force = false)
}

foreach ( $config as $property => $value ) {
if ( '#' == $property ) {
if ( $this->isComment($property) ) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/ETL/DbEntity/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function initialize(stdClass $config, $force = false)
}

foreach ( $config as $property => $value ) {
if ( '#' == $property ) {
if ( $this->isComment($property) ) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/ETL/DbEntity/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ public function getSelectSql($includeSchema = true)
$columnList = array();
$thisObj = $this;
foreach ( $this->records as $columnName => $formula ) {
if ( "#" == $columnName ) {
if ( $this->isComment($columnName) ) {
continue;
}

Expand Down
18 changes: 9 additions & 9 deletions classes/ETL/DbEntity/Trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Trigger extends aNamedEntity
public function __construct($config, $systemQuoteChar = null, Log $logger = null)
{
parent::__construct($systemQuoteChar, $logger);

if ( ! is_object($config) ) {
$msg = __CLASS__ . ": Argument is not an object";
$this->logAndThrowException($msg);
Expand All @@ -68,7 +68,7 @@ protected function initialize(stdClass $config, $force = false)
}

foreach ( $config as $property => $value ) {
if ( '#' == $property ) {
if ( $this->isComment($property) ) {
continue;
}

Expand All @@ -78,13 +78,13 @@ protected function initialize(stdClass $config, $force = false)
}

$this->$property = $value;

} // foreach ( $config as $property => $value )

$this->initialized = true;

} // initialize()

/* ------------------------------------------------------------------------------------------
* @return The time that the trigger will fire, null if not specified
* ------------------------------------------------------------------------------------------
Expand All @@ -94,7 +94,7 @@ public function getTime()
{
return $this->time;
} // getTime()

/* ------------------------------------------------------------------------------------------
* @return The trigger event, null if not specified
* ------------------------------------------------------------------------------------------
Expand All @@ -104,7 +104,7 @@ public function getEvent()
{
return $this->event;
} // getEvent()

/* ------------------------------------------------------------------------------------------
* @return The table that the trigger is associated with, null if not specified
* ------------------------------------------------------------------------------------------
Expand All @@ -114,7 +114,7 @@ public function getTable()
{
return $this->table;
} // getTable()

/* ------------------------------------------------------------------------------------------
* @return The trigger body, null if not specified
* ------------------------------------------------------------------------------------------
Expand All @@ -124,7 +124,7 @@ public function getBody()
{
return $this->body;
} // getBody()

/* ------------------------------------------------------------------------------------------
* @return The trigger definer, null if not specified
* ------------------------------------------------------------------------------------------
Expand All @@ -134,7 +134,7 @@ public function getDefiner()
{
return $this->definer;
} // getDefiner()

/* ------------------------------------------------------------------------------------------
* @see iTableItem::compare()
* ------------------------------------------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions classes/ETL/DbEntity/aNamedEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ abstract class aNamedEntity extends aEtlObject

protected $systemQuoteChar = '`';

// Keys starting with this character are considered comments
const COMMENT_KEY = "#";

/* ------------------------------------------------------------------------------------------
* Construct a database entity object from a JSON definition file or a definition object.
*
Expand Down Expand Up @@ -159,4 +162,18 @@ public function quote($identifier)
return $this->systemQuoteChar . $identifier . $this->systemQuoteChar;
} // quote()

/* ------------------------------------------------------------------------------------------
* Identify commented out keys in JSON definition/specification files.
*
* @param $key The string to examine
*
* @return TRUE if the key is considered a comment, FALSE otherwise.
* ------------------------------------------------------------------------------------------
*/

protected function isComment($key)
{
return ( 0 === strpos($key, self::COMMENT_KEY) );
} // isComment()

} // abstract class aNamedEntity