summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDeven Bansod <devenbansod.bits@gmail.com>2018-12-20 22:34:01 +0530
committerDeven Bansod <devenbansod.bits@gmail.com>2018-12-20 22:34:01 +0530
commitd046cb2b4bf0a0c072644efe391c0cdbd3cfd7f4 (patch)
tree81b532235b1a04d0d08580257772c82150861901 /src
parent5e8dbcf3ff0d1123efd731863083a9af539e5992 (diff)
downloadsql-parser-d046cb2b4bf0a0c072644efe391c0cdbd3cfd7f4.zip
sql-parser-d046cb2b4bf0a0c072644efe391c0cdbd3cfd7f4.tar.gz
sql-parser-d046cb2b4bf0a0c072644efe391c0cdbd3cfd7f4.tar.bz2
Fix building of RenameStatement
* The nuance here is that we don't treat `RENAME TABLE` as the keyword of the clause, only `RENAME` is considered. * That's why we can't use `Statement::$CLAUSES` directly here (even with value of `3` (see `Statement::$CLAUSES`)) * Providing an overriden definition of `build()` in RenameStatement Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/Components/RenameOperation.php2
-rw-r--r--src/Statements/CreateStatement.php2
-rw-r--r--src/Statements/RenameStatement.php8
3 files changed, 10 insertions, 2 deletions
diff --git a/src/Components/RenameOperation.php b/src/Components/RenameOperation.php
index 2e3d6ef..e9bd9ce 100644
--- a/src/Components/RenameOperation.php
+++ b/src/Components/RenameOperation.php
@@ -68,7 +68,7 @@ class RenameOperation extends Component
*
* 1 ------------------------[ TO ]-----------------------> 2
*
- * 2 ---------------------[ old name ]--------------------> 3
+ * 2 ---------------------[ new name ]--------------------> 3
*
* 3 ------------------------[ , ]------------------------> 0
* 3 -----------------------[ else ]----------------------> (END)
diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php
index 808109e..65cdbbb 100644
--- a/src/Statements/CreateStatement.php
+++ b/src/Statements/CreateStatement.php
@@ -411,7 +411,7 @@ class CreateStatement extends Statement
$this->select = new SelectStatement($parser, $list);
} elseif ($token->type === Token::TYPE_KEYWORD
&& $token->keyword === 'LIKE') {
- /* CREATE TABLE `new_tbl` LIKE 'orig_tbl' */
+ /* CREATE TABLE `new_tbl` LIKE 'orig_tbl' */
$list->idx = $nextidx;
$this->like = Expression::parse(
$parser,
diff --git a/src/Statements/RenameStatement.php b/src/Statements/RenameStatement.php
index 90533c2..e1bcf0d 100644
--- a/src/Statements/RenameStatement.php
+++ b/src/Statements/RenameStatement.php
@@ -47,4 +47,12 @@ class RenameStatement extends Statement
$list->getNextOfTypeAndValue(Token::TYPE_KEYWORD, 'TABLE');
}
}
+
+ /**
+ * @return string
+ */
+ public function build()
+ {
+ return 'RENAME TABLE ' . RenameOperation::build($this->renames);
+ }
}