Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
547eaaff
Commit
547eaaff
authored
Feb 27, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-45'
parents
05f6fc93
aceb3eeb
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1831 additions
and
6 deletions
+1831
-6
doctrine-dbal.php
bin/doctrine-dbal.php
+1
-0
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+28
-0
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+5
-0
DB2Keywords.php
lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php
+439
-0
KeywordList.php
lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php
+63
-0
MsSQLKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php
+243
-0
MySQLKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php
+268
-0
OracleKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php
+156
-0
PostgreSQLKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php
+131
-0
ReservedKeywordsValidator.php
...ine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php
+116
-0
SQLiteKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php
+164
-0
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+5
-0
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+5
-0
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+5
-0
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+5
-0
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+5
-0
ImportCommand.php
lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
+0
-3
ReservedWordsCommand.php
...trine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
+133
-0
RunSqlCommand.php
lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
+0
-3
AllTests.php
tests/Doctrine/Tests/DBAL/AllTests.php
+1
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+11
-0
ReservedKeywordsValidatorTest.php
...ne/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php
+47
-0
No files found.
bin/doctrine-dbal.php
View file @
547eaaff
...
...
@@ -37,6 +37,7 @@ $cli->addCommands(array(
// DBAL Commands
new
\Doctrine\DBAL\Tools\Console\Command\RunSqlCommand
(),
new
\Doctrine\DBAL\Tools\Console\Command\ImportCommand
(),
new
\Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand
(),
));
$cli
->
run
();
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
547eaaff
...
...
@@ -2188,4 +2188,32 @@ abstract class AbstractPlatform
{
return
'ROLLBACK TO SAVEPOINT '
.
$savepoint
;
}
/**
* Return the keyword list instance of this platform.
*
* Throws exception if no keyword list is specified.
*
* @throws DBALException
* @return KeywordList
*/
final
public
function
getReservedKeywordsList
()
{
$class
=
$this
->
getReservedKeywordsClass
();
$keywords
=
new
$class
;
if
(
!
$keywords
instanceof
\Doctrine\DBAL\Platforms\Keywords\KeywordList
)
{
throw
DBALException
::
notSupported
(
__METHOD__
);
}
return
$keywords
;
}
/**
* The class name of the reserved keywords list.
*
* @return string
*/
protected
function
getReservedKeywordsClass
()
{
throw
DBALException
::
notSupported
(
__METHOD__
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
547eaaff
...
...
@@ -550,4 +550,9 @@ class DB2Platform extends AbstractPlatform
{
return
false
;
}
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\DB2Keywords'
;
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* DB2 Keywords
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class
DB2Keywords
extends
KeywordList
{
public
function
getName
()
{
return
'DB2'
;
}
protected
function
getKeywords
()
{
return
array
(
'ACTIVATE'
,
'ADD'
,
'AFTER'
,
'ALIAS'
,
'ALL'
,
'ALLOCATE'
,
'DOCUMENT'
,
'DOUBLE'
,
'DROP'
,
'DSSIZE'
,
'DYNAMIC'
,
'EACH'
,
'LOCK'
,
'LOCKMAX'
,
'LOCKSIZE'
,
'LONG'
,
'LOOP'
,
'MAINTAINED'
,
'ROUND_CEILING'
,
'ROUND_DOWN'
,
'ROUND_FLOOR'
,
'ROUND_HALF_DOWN'
,
'ROUND_HALF_EVEN'
,
'ROUND_HALF_UP'
,
'ALLOW'
,
'ALTER'
,
'AND'
,
'ANY'
,
'AS'
,
'ASENSITIVE'
,
'ASSOCIATE'
,
'ASUTIME'
,
'AT'
,
'ATTRIBUTES'
,
'AUDIT'
,
'AUTHORIZATION'
,
'AUX'
,
'AUXILIARY'
,
'BEFORE'
,
'BEGIN'
,
'BETWEEN'
,
'BINARY'
,
'BUFFERPOOL'
,
'BY'
,
'CACHE'
,
'CALL'
,
'CALLED'
,
'CAPTURE'
,
'CARDINALITY'
,
'CASCADED'
,
'CASE'
,
'CAST'
,
'CCSID'
,
'CHAR'
,
'CHARACTER'
,
'CHECK'
,
'CLONE'
,
'CLOSE'
,
'CLUSTER'
,
'COLLECTION'
,
'COLLID'
,
'COLUMN'
,
'COMMENT'
,
'COMMIT'
,
'CONCAT'
,
'CONDITION'
,
'CONNECT'
,
'CONNECTION'
,
'CONSTRAINT'
,
'CONTAINS'
,
'CONTINUE'
,
'COUNT'
,
'COUNT_BIG'
,
'CREATE'
,
'CROSS'
,
'CURRENT'
,
'CURRENT_DATE'
,
'CURRENT_LC_CTYPE'
,
'CURRENT_PATH'
,
'CURRENT_SCHEMA'
,
'CURRENT_SERVER'
,
'CURRENT_TIME'
,
'CURRENT_TIMESTAMP'
,
'CURRENT_TIMEZONE'
,
'CURRENT_USER'
,
'CURSOR'
,
'CYCLE'
,
'DATA'
,
'DATABASE'
,
'DATAPARTITIONNAME'
,
'DATAPARTITIONNUM'
,
'EDITPROC'
,
'ELSE'
,
'ELSEIF'
,
'ENABLE'
,
'ENCODING'
,
'ENCRYPTION'
,
'END'
,
'END-EXEC'
,
'ENDING'
,
'ERASE'
,
'ESCAPE'
,
'EVERY'
,
'EXCEPT'
,
'EXCEPTION'
,
'EXCLUDING'
,
'EXCLUSIVE'
,
'EXECUTE'
,
'EXISTS'
,
'EXIT'
,
'EXPLAIN'
,
'EXTERNAL'
,
'EXTRACT'
,
'FENCED'
,
'FETCH'
,
'FIELDPROC'
,
'FILE'
,
'FINAL'
,
'FOR'
,
'FOREIGN'
,
'FREE'
,
'FROM'
,
'FULL'
,
'FUNCTION'
,
'GENERAL'
,
'GENERATED'
,
'GET'
,
'GLOBAL'
,
'GO'
,
'GOTO'
,
'GRANT'
,
'GRAPHIC'
,
'GROUP'
,
'HANDLER'
,
'HASH'
,
'HASHED_VALUE'
,
'HAVING'
,
'HINT'
,
'HOLD'
,
'HOUR'
,
'HOURS'
,
'IDENTITY'
,
'IF'
,
'IMMEDIATE'
,
'IN'
,
'INCLUDING'
,
'INCLUSIVE'
,
'INCREMENT'
,
'INDEX'
,
'INDICATOR'
,
'INF'
,
'INFINITY'
,
'INHERIT'
,
'INNER'
,
'INOUT'
,
'INSENSITIVE'
,
'INSERT'
,
'INTEGRITY'
,
'MATERIALIZED'
,
'MAXVALUE'
,
'MICROSECOND'
,
'MICROSECONDS'
,
'MINUTE'
,
'MINUTES'
,
'MINVALUE'
,
'MODE'
,
'MODIFIES'
,
'MONTH'
,
'MONTHS'
,
'NAN'
,
'NEW'
,
'NEW_TABLE'
,
'NEXTVAL'
,
'NO'
,
'NOCACHE'
,
'NOCYCLE'
,
'NODENAME'
,
'NODENUMBER'
,
'NOMAXVALUE'
,
'NOMINVALUE'
,
'NONE'
,
'NOORDER'
,
'NORMALIZED'
,
'NOT'
,
'NULL'
,
'NULLS'
,
'NUMPARTS'
,
'OBID'
,
'OF'
,
'OLD'
,
'OLD_TABLE'
,
'ON'
,
'OPEN'
,
'OPTIMIZATION'
,
'OPTIMIZE'
,
'OPTION'
,
'OR'
,
'ORDER'
,
'OUT'
,
'OUTER'
,
'OVER'
,
'OVERRIDING'
,
'PACKAGE'
,
'PADDED'
,
'PAGESIZE'
,
'PARAMETER'
,
'PART'
,
'PARTITION'
,
'PARTITIONED'
,
'PARTITIONING'
,
'PARTITIONS'
,
'PASSWORD'
,
'PATH'
,
'PIECESIZE'
,
'PLAN'
,
'POSITION'
,
'PRECISION'
,
'PREPARE'
,
'PREVVAL'
,
'PRIMARY'
,
'PRIQTY'
,
'PRIVILEGES'
,
'PROCEDURE'
,
'PROGRAM'
,
'PSID'
,
'ROUND_UP'
,
'ROUTINE'
,
'ROW'
,
'ROW_NUMBER'
,
'ROWNUMBER'
,
'ROWS'
,
'ROWSET'
,
'RRN'
,
'RUN'
,
'SAVEPOINT'
,
'SCHEMA'
,
'SCRATCHPAD'
,
'SCROLL'
,
'SEARCH'
,
'SECOND'
,
'SECONDS'
,
'SECQTY'
,
'SECURITY'
,
'SELECT'
,
'SENSITIVE'
,
'SEQUENCE'
,
'SESSION'
,
'SESSION_USER'
,
'SET'
,
'SIGNAL'
,
'SIMPLE'
,
'SNAN'
,
'SOME'
,
'SOURCE'
,
'SPECIFIC'
,
'SQL'
,
'SQLID'
,
'STACKED'
,
'STANDARD'
,
'START'
,
'STARTING'
,
'STATEMENT'
,
'STATIC'
,
'STATMENT'
,
'STAY'
,
'STOGROUP'
,
'STORES'
,
'STYLE'
,
'SUBSTRING'
,
'SUMMARY'
,
'SYNONYM'
,
'SYSFUN'
,
'SYSIBM'
,
'SYSPROC'
,
'SYSTEM'
,
'SYSTEM_USER'
,
'TABLE'
,
'TABLESPACE'
,
'THEN'
,
'TIME'
,
'TIMESTAMP'
,
'TO'
,
'TRANSACTION'
,
'TRIGGER'
,
'TRIM'
,
'TRUNCATE'
,
'TYPE'
,
'UNDO'
,
'UNION'
,
'UNIQUE'
,
'UNTIL'
,
'UPDATE'
,
'DATE'
,
'DAY'
,
'DAYS'
,
'DB2GENERAL'
,
'DB2GENRL'
,
'DB2SQL'
,
'DBINFO'
,
'DBPARTITIONNAME'
,
'DBPARTITIONNUM'
,
'DEALLOCATE'
,
'DECLARE'
,
'DEFAULT'
,
'DEFAULTS'
,
'DEFINITION'
,
'DELETE'
,
'DENSE_RANK'
,
'DENSERANK'
,
'DESCRIBE'
,
'DESCRIPTOR'
,
'DETERMINISTIC'
,
'DIAGNOSTICS'
,
'DISABLE'
,
'DISALLOW'
,
'DISCONNECT'
,
'DISTINCT'
,
'DO'
,
'INTERSECT'
,
'PUBLIC'
,
'USAGE'
,
'INTO'
,
'QUERY'
,
'USER'
,
'IS'
,
'QUERYNO'
,
'USING'
,
'ISOBID'
,
'RANGE'
,
'VALIDPROC'
,
'ISOLATION'
,
'RANK'
,
'VALUE'
,
'ITERATE'
,
'READ'
,
'VALUES'
,
'JAR'
,
'READS'
,
'VARIABLE'
,
'JAVA'
,
'RECOVERY'
,
'VARIANT'
,
'JOIN'
,
'REFERENCES'
,
'VCAT'
,
'KEEP'
,
'REFERENCING'
,
'VERSION'
,
'KEY'
,
'REFRESH'
,
'VIEW'
,
'LABEL'
,
'RELEASE'
,
'VOLATILE'
,
'LANGUAGE'
,
'RENAME'
,
'VOLUMES'
,
'LATERAL'
,
'REPEAT'
,
'WHEN'
,
'LC_CTYPE'
,
'RESET'
,
'WHENEVER'
,
'LEAVE'
,
'RESIGNAL'
,
'WHERE'
,
'LEFT'
,
'RESTART'
,
'WHILE'
,
'LIKE'
,
'RESTRICT'
,
'WITH'
,
'LINKTYPE'
,
'RESULT'
,
'WITHOUT'
,
'LOCAL'
,
'RESULT_SET_LOCATOR WLM'
,
'LOCALDATE'
,
'RETURN'
,
'WRITE'
,
'LOCALE'
,
'RETURNS'
,
'XMLELEMENT'
,
'LOCALTIME'
,
'REVOKE'
,
'XMLEXISTS'
,
'LOCALTIMESTAMP RIGHT'
,
'XMLNAMESPACES'
,
'LOCATOR'
,
'ROLE'
,
'YEAR'
,
'LOCATORS'
,
'ROLLBACK'
,
'YEARS'
,
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* Abstract interface for a SQL reserved keyword dictionary.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
abstract
class
KeywordList
{
private
$keywords
=
null
;
/**
* Check if the given word is a keyword of this dialect/vendor platform.
*
* @param string $word
* @return bool
*/
public
function
isKeyword
(
$word
)
{
if
(
$this
->
keywords
===
null
)
{
$this
->
initializeKeywords
();
}
return
isset
(
$this
->
keywords
[
strtoupper
(
$word
)]);
}
protected
function
initializeKeywords
()
{
$this
->
keywords
=
array_flip
(
array_map
(
'strtoupper'
,
$this
->
getKeywords
()));
}
abstract
protected
function
getKeywords
();
/**
* Name of this keyword list.
*
* @return string
*/
abstract
public
function
getName
();
}
lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* MsSQL Keywordlist
*
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author David Coallier <davidc@php.net>
*/
class
MsSQLKeywords
extends
KeywordList
{
public
function
getName
()
{
return
'MsSQL'
;
}
protected
function
getKeywords
()
{
return
array
(
'ADD'
,
'CURRENT_TIMESTAMP'
,
'GROUP'
,
'OPENQUERY'
,
'SERIALIZABLE'
,
'ALL'
,
'CURRENT_USER'
,
'HAVING'
,
'OPENROWSET'
,
'SESSION_USER'
,
'ALTER'
,
'CURSOR'
,
'HOLDLOCK'
,
'OPTION'
,
'SET'
,
'AND'
,
'DATABASE'
,
'IDENTITY'
,
'OR'
,
'SETUSER'
,
'ANY'
,
'DBCC'
,
'IDENTITYCOL'
,
'ORDER'
,
'SHUTDOWN'
,
'AS'
,
'DEALLOCATE'
,
'IDENTITY_INSERT'
,
'OUTER'
,
'SOME'
,
'ASC'
,
'DECLARE'
,
'IF'
,
'OVER'
,
'STATISTICS'
,
'AUTHORIZATION'
,
'DEFAULT'
,
'IN'
,
'PERCENT'
,
'SUM'
,
'AVG'
,
'DELETE'
,
'INDEX'
,
'PERM'
,
'SYSTEM_USER'
,
'BACKUP'
,
'DENY'
,
'INNER'
,
'PERMANENT'
,
'TABLE'
,
'BEGIN'
,
'DESC'
,
'INSERT'
,
'PIPE'
,
'TAPE'
,
'BETWEEN'
,
'DISK'
,
'INTERSECT'
,
'PLAN'
,
'TEMP'
,
'BREAK'
,
'DISTINCT'
,
'INTO'
,
'PRECISION'
,
'TEMPORARY'
,
'BROWSE'
,
'DISTRIBUTED'
,
'IS'
,
'PREPARE'
,
'TEXTSIZE'
,
'BULK'
,
'DOUBLE'
,
'ISOLATION'
,
'PRIMARY'
,
'THEN'
,
'BY'
,
'DROP'
,
'JOIN'
,
'PRINT'
,
'TO'
,
'CASCADE'
,
'DUMMY'
,
'KEY'
,
'PRIVILEGES'
,
'TOP'
,
'CASE'
,
'DUMP'
,
'KILL'
,
'PROC'
,
'TRAN'
,
'CHECK'
,
'ELSE'
,
'LEFT'
,
'PROCEDURE'
,
'TRANSACTION'
,
'CHECKPOINT'
,
'END'
,
'LEVEL'
,
'PROCESSEXIT'
,
'TRIGGER'
,
'CLOSE'
,
'ERRLVL'
,
'LIKE'
,
'PUBLIC'
,
'TRUNCATE'
,
'CLUSTERED'
,
'ERROREXIT'
,
'LINENO'
,
'RAISERROR'
,
'TSEQUAL'
,
'COALESCE'
,
'ESCAPE'
,
'LOAD'
,
'READ'
,
'UNCOMMITTED'
,
'COLUMN'
,
'EXCEPT'
,
'MAX'
,
'READTEXT'
,
'UNION'
,
'COMMIT'
,
'EXEC'
,
'MIN'
,
'RECONFIGURE'
,
'UNIQUE'
,
'COMMITTED'
,
'EXECUTE'
,
'MIRROREXIT'
,
'REFERENCES'
,
'UPDATE'
,
'COMPUTE'
,
'EXISTS'
,
'NATIONAL'
,
'REPEATABLE'
,
'UPDATETEXT'
,
'CONFIRM'
,
'EXIT'
,
'NOCHECK'
,
'REPLICATION'
,
'USE'
,
'CONSTRAINT'
,
'FETCH'
,
'NONCLUSTERED'
,
'RESTORE'
,
'USER'
,
'CONTAINS'
,
'FILE'
,
'NOT'
,
'RESTRICT'
,
'VALUES'
,
'CONTAINSTABLE'
,
'FILLFACTOR'
,
'NULL'
,
'RETURN'
,
'VARYING'
,
'CONTINUE'
,
'FLOPPY'
,
'NULLIF'
,
'REVOKE'
,
'VIEW'
,
'CONTROLROW'
,
'FOR'
,
'OF'
,
'RIGHT'
,
'WAITFOR'
,
'CONVERT'
,
'FOREIGN'
,
'OFF'
,
'ROLLBACK'
,
'WHEN'
,
'COUNT'
,
'FREETEXT'
,
'OFFSETS'
,
'ROWCOUNT'
,
'WHERE'
,
'CREATE'
,
'FREETEXTTABLE'
,
'ON'
,
'ROWGUIDCOL'
,
'WHILE'
,
'CROSS'
,
'FROM'
,
'ONCE'
,
'RULE'
,
'WITH'
,
'CURRENT'
,
'FULL'
,
'ONLY'
,
'SAVE'
,
'WORK'
,
'CURRENT_DATE'
,
'GOTO'
,
'OPEN'
,
'SCHEMA'
,
'WRITETEXT'
,
'CURRENT_TIME'
,
'GRANT'
,
'OPENDATASOURCE'
,
'SELECT'
,
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* MySQL Keywordlist
*
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author David Coallier <davidc@php.net>
*/
class
MySQLKeywords
extends
KeywordList
{
public
function
getName
()
{
return
'MySQL'
;
}
protected
function
getKeywords
()
{
return
array
(
'ADD'
,
'ALL'
,
'ALTER'
,
'ANALYZE'
,
'AND'
,
'AS'
,
'ASC'
,
'ASENSITIVE'
,
'BEFORE'
,
'BETWEEN'
,
'BIGINT'
,
'BINARY'
,
'BLOB'
,
'BOTH'
,
'BY'
,
'CALL'
,
'CASCADE'
,
'CASE'
,
'CHANGE'
,
'CHAR'
,
'CHARACTER'
,
'CHECK'
,
'COLLATE'
,
'COLUMN'
,
'CONDITION'
,
'CONNECTION'
,
'CONSTRAINT'
,
'CONTINUE'
,
'CONVERT'
,
'CREATE'
,
'CROSS'
,
'CURRENT_DATE'
,
'CURRENT_TIME'
,
'CURRENT_TIMESTAMP'
,
'CURRENT_USER'
,
'CURSOR'
,
'DATABASE'
,
'DATABASES'
,
'DAY_HOUR'
,
'DAY_MICROSECOND'
,
'DAY_MINUTE'
,
'DAY_SECOND'
,
'DEC'
,
'DECIMAL'
,
'DECLARE'
,
'DEFAULT'
,
'DELAYED'
,
'DELETE'
,
'DESC'
,
'DESCRIBE'
,
'DETERMINISTIC'
,
'DISTINCT'
,
'DISTINCTROW'
,
'DIV'
,
'DOUBLE'
,
'DROP'
,
'DUAL'
,
'EACH'
,
'ELSE'
,
'ELSEIF'
,
'ENCLOSED'
,
'ESCAPED'
,
'EXISTS'
,
'EXIT'
,
'EXPLAIN'
,
'FALSE'
,
'FETCH'
,
'FLOAT'
,
'FLOAT4'
,
'FLOAT8'
,
'FOR'
,
'FORCE'
,
'FOREIGN'
,
'FROM'
,
'FULLTEXT'
,
'GOTO'
,
'GRANT'
,
'GROUP'
,
'HAVING'
,
'HIGH_PRIORITY'
,
'HOUR_MICROSECOND'
,
'HOUR_MINUTE'
,
'HOUR_SECOND'
,
'IF'
,
'IGNORE'
,
'IN'
,
'INDEX'
,
'INFILE'
,
'INNER'
,
'INOUT'
,
'INSENSITIVE'
,
'INSERT'
,
'INT'
,
'INT1'
,
'INT2'
,
'INT3'
,
'INT4'
,
'INT8'
,
'INTEGER'
,
'INTERVAL'
,
'INTO'
,
'IS'
,
'ITERATE'
,
'JOIN'
,
'KEY'
,
'KEYS'
,
'KILL'
,
'LABEL'
,
'LEADING'
,
'LEAVE'
,
'LEFT'
,
'LIKE'
,
'LIMIT'
,
'LINES'
,
'LOAD'
,
'LOCALTIME'
,
'LOCALTIMESTAMP'
,
'LOCK'
,
'LONG'
,
'LONGBLOB'
,
'LONGTEXT'
,
'LOOP'
,
'LOW_PRIORITY'
,
'MATCH'
,
'MEDIUMBLOB'
,
'MEDIUMINT'
,
'MEDIUMTEXT'
,
'MIDDLEINT'
,
'MINUTE_MICROSECOND'
,
'MINUTE_SECOND'
,
'MOD'
,
'MODIFIES'
,
'NATURAL'
,
'NOT'
,
'NO_WRITE_TO_BINLOG'
,
'NULL'
,
'NUMERIC'
,
'ON'
,
'OPTIMIZE'
,
'OPTION'
,
'OPTIONALLY'
,
'OR'
,
'ORDER'
,
'OUT'
,
'OUTER'
,
'OUTFILE'
,
'PRECISION'
,
'PRIMARY'
,
'PROCEDURE'
,
'PURGE'
,
'RAID0'
,
'READ'
,
'READS'
,
'REAL'
,
'REFERENCES'
,
'REGEXP'
,
'RELEASE'
,
'RENAME'
,
'REPEAT'
,
'REPLACE'
,
'REQUIRE'
,
'RESTRICT'
,
'RETURN'
,
'REVOKE'
,
'RIGHT'
,
'RLIKE'
,
'SCHEMA'
,
'SCHEMAS'
,
'SECOND_MICROSECOND'
,
'SELECT'
,
'SENSITIVE'
,
'SEPARATOR'
,
'SET'
,
'SHOW'
,
'SMALLINT'
,
'SONAME'
,
'SPATIAL'
,
'SPECIFIC'
,
'SQL'
,
'SQLEXCEPTION'
,
'SQLSTATE'
,
'SQLWARNING'
,
'SQL_BIG_RESULT'
,
'SQL_CALC_FOUND_ROWS'
,
'SQL_SMALL_RESULT'
,
'SSL'
,
'STARTING'
,
'STRAIGHT_JOIN'
,
'TABLE'
,
'TERMINATED'
,
'THEN'
,
'TINYBLOB'
,
'TINYINT'
,
'TINYTEXT'
,
'TO'
,
'TRAILING'
,
'TRIGGER'
,
'TRUE'
,
'UNDO'
,
'UNION'
,
'UNIQUE'
,
'UNLOCK'
,
'UNSIGNED'
,
'UPDATE'
,
'USAGE'
,
'USE'
,
'USING'
,
'UTC_DATE'
,
'UTC_TIME'
,
'UTC_TIMESTAMP'
,
'VALUES'
,
'VARBINARY'
,
'VARCHAR'
,
'VARCHARACTER'
,
'VARYING'
,
'WHEN'
,
'WHERE'
,
'WHILE'
,
'WITH'
,
'WRITE'
,
'X509'
,
'XOR'
,
'YEAR_MONTH'
,
'ZEROFILL'
,
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* Oracle Keywordlist
*
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author David Coallier <davidc@php.net>
*/
class
OracleKeywords
extends
KeywordList
{
public
function
getName
()
{
return
'Oracle'
;
}
protected
function
getKeywords
()
{
return
array
(
'ACCESS'
,
'ELSE'
,
'MODIFY'
,
'START'
,
'ADD'
,
'EXCLUSIVE'
,
'NOAUDIT'
,
'SELECT'
,
'ALL'
,
'EXISTS'
,
'NOCOMPRESS'
,
'SESSION'
,
'ALTER'
,
'FILE'
,
'NOT'
,
'SET'
,
'AND'
,
'FLOAT'
,
'NOTFOUND '
,
'SHARE'
,
'ANY'
,
'FOR'
,
'NOWAIT'
,
'SIZE'
,
'ARRAYLEN'
,
'FROM'
,
'NULL'
,
'SMALLINT'
,
'AS'
,
'GRANT'
,
'NUMBER'
,
'SQLBUF'
,
'ASC'
,
'GROUP'
,
'OF'
,
'SUCCESSFUL'
,
'AUDIT'
,
'HAVING'
,
'OFFLINE '
,
'SYNONYM'
,
'BETWEEN'
,
'IDENTIFIED'
,
'ON'
,
'SYSDATE'
,
'BY'
,
'IMMEDIATE'
,
'ONLINE'
,
'TABLE'
,
'CHAR'
,
'IN'
,
'OPTION'
,
'THEN'
,
'CHECK'
,
'INCREMENT'
,
'OR'
,
'TO'
,
'CLUSTER'
,
'INDEX'
,
'ORDER'
,
'TRIGGER'
,
'COLUMN'
,
'INITIAL'
,
'PCTFREE'
,
'UID'
,
'COMMENT'
,
'INSERT'
,
'PRIOR'
,
'UNION'
,
'COMPRESS'
,
'INTEGER'
,
'PRIVILEGES'
,
'UNIQUE'
,
'CONNECT'
,
'INTERSECT'
,
'PUBLIC'
,
'UPDATE'
,
'CREATE'
,
'INTO'
,
'RAW'
,
'USER'
,
'CURRENT'
,
'IS'
,
'RENAME'
,
'VALIDATE'
,
'DATE'
,
'LEVEL'
,
'RESOURCE'
,
'VALUES'
,
'DECIMAL'
,
'LIKE'
,
'REVOKE'
,
'VARCHAR'
,
'DEFAULT'
,
'LOCK'
,
'ROW'
,
'VARCHAR2'
,
'DELETE'
,
'LONG'
,
'ROWID'
,
'VIEW'
,
'DESC'
,
'MAXEXTENTS'
,
'ROWLABEL'
,
'WHENEVER'
,
'DISTINCT'
,
'MINUS'
,
'ROWNUM'
,
'WHERE'
,
'DROP'
,
'MODE'
,
'ROWS'
,
'WITH'
,
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* PostgreSQL Keywordlist
*
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Marcelo Santos Araujo <msaraujo@php.net>
*/
class
PostgreSQLKeywords
extends
KeywordList
{
public
function
getName
()
{
return
'PostgreSQL'
;
}
protected
function
getKeywords
()
{
return
array
(
'ALL'
,
'ANALYSE'
,
'ANALYZE'
,
'AND'
,
'ANY'
,
'AS'
,
'ASC'
,
'AUTHORIZATION'
,
'BETWEEN'
,
'BINARY'
,
'BOTH'
,
'CASE'
,
'CAST'
,
'CHECK'
,
'COLLATE'
,
'COLUMN'
,
'CONSTRAINT'
,
'CREATE'
,
'CURRENT_DATE'
,
'CURRENT_TIME'
,
'CURRENT_TIMESTAMP'
,
'CURRENT_USER'
,
'DEFAULT'
,
'DEFERRABLE'
,
'DESC'
,
'DISTINCT'
,
'DO'
,
'ELSE'
,
'END'
,
'EXCEPT'
,
'FALSE'
,
'FOR'
,
'FOREIGN'
,
'FREEZE'
,
'FROM'
,
'FULL'
,
'GRANT'
,
'GROUP'
,
'HAVING'
,
'ILIKE'
,
'IN'
,
'INITIALLY'
,
'INNER'
,
'INTERSECT'
,
'INTO'
,
'IS'
,
'ISNULL'
,
'JOIN'
,
'LEADING'
,
'LEFT'
,
'LIKE'
,
'LIMIT'
,
'LOCALTIME'
,
'LOCALTIMESTAMP'
,
'NATURAL'
,
'NEW'
,
'NOT'
,
'NOTNULL'
,
'NULL'
,
'OFF'
,
'OFFSET'
,
'OLD'
,
'ON'
,
'ONLY'
,
'OR'
,
'ORDER'
,
'OUTER'
,
'OVERLAPS'
,
'PLACING'
,
'PRIMARY'
,
'REFERENCES'
,
'SELECT'
,
'SESSION_USER'
,
'SIMILAR'
,
'SOME'
,
'TABLE'
,
'THEN'
,
'TO'
,
'TRAILING'
,
'TRUE'
,
'UNION'
,
'UNIQUE'
,
'USER'
,
'USING'
,
'VERBOSE'
,
'WHEN'
,
'WHERE'
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
use
Doctrine\DBAL\Schema\Visitor\Visitor
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\Column
;
use
Doctrine\DBAL\Schema\ForeignKeyConstraint
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\DBAL\Schema\Sequence
;
use
Doctrine\DBAL\Schema\Index
;
class
ReservedKeywordsValidator
implements
Visitor
{
/**
* @var KeywordList[]
*/
private
$keywordLists
=
array
();
/**
* @var array
*/
private
$violations
=
array
();
public
function
__construct
(
array
$keywordLists
)
{
$this
->
keywordLists
=
$keywordLists
;
}
public
function
getViolations
()
{
return
$this
->
violations
;
}
/**
* @param string $word
* @return array
*/
private
function
isReservedWord
(
$word
)
{
if
(
$word
[
0
]
==
"`"
)
{
$word
=
str_replace
(
'`'
,
''
,
$word
);
}
$keywordLists
=
array
();
foreach
(
$this
->
keywordLists
AS
$keywordList
)
{
if
(
$keywordList
->
isKeyword
(
$word
))
{
$keywordLists
[]
=
$keywordList
->
getName
();
}
}
return
$keywordLists
;
}
private
function
addViolation
(
$asset
,
$violatedPlatforms
)
{
if
(
!
$violatedPlatforms
)
{
return
;
}
$this
->
violations
[]
=
$asset
.
' keyword violations: '
.
implode
(
', '
,
$violatedPlatforms
);
}
public
function
acceptColumn
(
Table
$table
,
Column
$column
)
{
$this
->
addViolation
(
'Table '
.
$table
->
getName
()
.
' column '
.
$column
->
getName
(),
$this
->
isReservedWord
(
$column
->
getName
())
);
}
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
{
}
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
{
}
public
function
acceptSchema
(
Schema
$schema
)
{
}
public
function
acceptSequence
(
Sequence
$sequence
)
{
}
public
function
acceptTable
(
Table
$table
)
{
$this
->
addViolation
(
'Table '
.
$table
->
getName
(),
$this
->
isReservedWord
(
$table
->
getName
())
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* SQLite Keywords
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class
SQLiteKeywords
extends
KeywordList
{
public
function
getName
()
{
return
'SQLite'
;
}
protected
function
getKeywords
()
{
return
array
(
'ABORT'
,
'ACTION'
,
'ADD'
,
'AFTER'
,
'ALL'
,
'ALTER'
,
'ANALYZE'
,
'AND'
,
'AS'
,
'ASC'
,
'ATTACH'
,
'AUTOINCREMENT'
,
'BEFORE'
,
'BEGIN'
,
'BETWEEN'
,
'BY'
,
'CASCADE'
,
'CASE'
,
'CAST'
,
'CHECK'
,
'COLLATE'
,
'COLUMN'
,
'COMMIT'
,
'CONFLICT'
,
'CONSTRAINT'
,
'CREATE'
,
'CROSS'
,
'CURRENT_DATE'
,
'CURRENT_TIME'
,
'CURRENT_TIMESTAMP'
,
'DATABASE'
,
'DEFAULT'
,
'DEFERRABLE'
,
'DEFERRED'
,
'DELETE'
,
'DESC'
,
'DETACH'
,
'DISTINCT'
,
'DROP'
,
'EACH'
,
'ELSE'
,
'END'
,
'ESCAPE'
,
'EXCEPT'
,
'EXCLUSIVE'
,
'EXISTS'
,
'EXPLAIN'
,
'FAIL'
,
'FOR'
,
'FOREIGN'
,
'FROM'
,
'FULL'
,
'GLOB'
,
'GROUP'
,
'HAVING'
,
'IF'
,
'IGNORE'
,
'IMMEDIATE'
,
'IN'
,
'INDEX'
,
'INDEXED'
,
'INITIALLY'
,
'INNER'
,
'INSERT'
,
'INSTEAD'
,
'INTERSECT'
,
'INTO'
,
'IS'
,
'ISNULL'
,
'JOIN'
,
'KEY'
,
'LEFT'
,
'LIKE'
,
'LIMIT'
,
'MATCH'
,
'NATURAL'
,
'NO'
,
'NOT'
,
'NOTNULL'
,
'NULL'
,
'OF'
,
'OFFSET'
,
'ON'
,
'OR'
,
'ORDER'
,
'OUTER'
,
'PLAN'
,
'PRAGMA'
,
'PRIMARY'
,
'QUERY'
,
'RAISE'
,
'REFERENCES'
,
'REGEXP'
,
'REINDEX'
,
'RELEASE'
,
'RENAME'
,
'REPLACE'
,
'RESTRICT'
,
'RIGHT'
,
'ROLLBACK'
,
'ROW'
,
'SAVEPOINT'
,
'SELECT'
,
'SET'
,
'TABLE'
,
'TEMP'
,
'TEMPORARY'
,
'THEN'
,
'TO'
,
'TRANSACTION'
,
'TRIGGER'
,
'UNION'
,
'UNIQUE'
,
'UPDATE'
,
'USING'
,
'VACUUM'
,
'VALUES'
,
'VIEW'
,
'VIRTUAL'
,
'WHEN'
,
'WHERE'
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
547eaaff
...
...
@@ -774,4 +774,9 @@ class MsSqlPlatform extends AbstractPlatform
{
return
' '
;
}
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\MsSQLKeywords'
;
}
}
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
547eaaff
...
...
@@ -627,4 +627,9 @@ class MySqlPlatform extends AbstractPlatform
{
return
65535
;
}
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords'
;
}
}
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
547eaaff
...
...
@@ -722,4 +722,9 @@ LEFT JOIN all_cons_columns r_cols
{
return
''
;
}
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\OracleKeywords'
;
}
}
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
547eaaff
...
...
@@ -714,4 +714,9 @@ class PostgreSqlPlatform extends AbstractPlatform
{
return
65535
;
}
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords'
;
}
}
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
547eaaff
...
...
@@ -461,4 +461,9 @@ class SqlitePlatform extends AbstractPlatform
'numeric'
=>
'decimal'
,
);
}
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords'
;
}
}
lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
View file @
547eaaff
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -31,7 +29,6 @@ use Symfony\Component\Console\Input\InputArgument,
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
...
...
lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
0 → 100644
View file @
547eaaff
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Tools\Console\Command
;
use
Symfony\Component\Console\Input\InputArgument
,
Symfony\Component\Console\Input\InputOption
,
Symfony\Component\Console\Command\Command
,
Symfony\Component\Console\Input\InputInterface
,
Symfony\Component\Console\Output\OutputInterface
;
use
Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator
;
class
ReservedWordsCommand
extends
Command
{
private
$keywordListClasses
=
array
(
'mysql'
=>
'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords'
,
'mssql'
=>
'Doctrine\DBAL\Platforms\Keywords\MsSQLKeywords'
,
'sqlite'
=>
'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords'
,
'pgsql'
=>
'Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords'
,
'oracle'
=>
'Doctrine\DBAL\Platforms\Keywords\OracleKeywords'
,
'db2'
=>
'Doctrine\DBAL\Platforms\Keywords\DB2Keywords'
,
);
/**
* If you want to add or replace a keywords list use this command
*
* @param string $name
* @param string $class
*/
public
function
setKeywordListClass
(
$name
,
$class
)
{
$this
->
keywordListClasses
[
$name
]
=
$class
;
}
/**
* @see Console\Command\Command
*/
protected
function
configure
()
{
$this
->
setName
(
'dbal:reserved-words'
)
->
setDescription
(
'Checks if the current database contains identifiers that are reserved.'
)
->
setDefinition
(
array
(
new
InputOption
(
'list'
,
'l'
,
InputOption
::
VALUE_OPTIONAL
|
InputOption
::
VALUE_IS_ARRAY
,
'Keyword-List name.'
)
))
->
setHelp
(
<<<EOT
Checks if the current database contains tables and columns
with names that are identifiers in this dialect or in other SQL dialects.
By default SQLite, MySQL, PostgreSQL, MsSQL and Oracle
keywords are checked:
<info>doctrine dbal:reserved-words</info>
If you want to check against specific dialects you can
pass them to the command:
<info>doctrine dbal:reserved-words mysql pgsql</info>
The following keyword lists are currently shipped with Doctrine:
* mysql
* pgsql
* sqlite
* oracle
* mssql
* db2 (Not checked by default)
EOT
);
}
/**
* @see Console\Command\Command
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
/* @var $conn Doctrine\DBAL\Connection */
$conn
=
$this
->
getHelper
(
'db'
)
->
getConnection
();
$keywordLists
=
(
array
)
$input
->
getOption
(
'list'
);
if
(
!
$keywordLists
)
{
$keywordLists
=
array
(
'mysql'
,
'pgsql'
,
'sqlite'
,
'oracle'
,
'mssql'
);
}
$keywords
=
array
();
foreach
(
$keywordLists
AS
$keywordList
)
{
if
(
!
isset
(
$this
->
keywordListClasses
[
$keywordList
]))
{
throw
new
\InvalidArgumentException
(
"There exists no keyword list with name '"
.
$keywordList
.
"'. "
.
"Known lists: "
.
implode
(
", "
,
array_keys
(
$this
->
keywordListClasses
))
);
}
$class
=
$this
->
keywordListClasses
[
$keywordList
];
$keywords
[]
=
new
$class
;
}
$output
->
write
(
'Checking keyword violations for <comment>'
.
implode
(
", "
,
$keywordLists
)
.
"</comment>..."
,
true
);
/* @var $schema \Doctrine\DBAL\Schema\Schema */
$schema
=
$conn
->
getSchemaManager
()
->
createSchema
();
$visitor
=
new
ReservedKeywordsValidator
(
$keywords
);
$schema
->
visit
(
$visitor
);
$violations
=
$visitor
->
getViolations
();
if
(
count
(
$violations
)
==
0
)
{
$output
->
write
(
"No reserved keywords violations have been found!"
,
true
);
}
else
{
$output
->
write
(
'There are <error>'
.
count
(
$violations
)
.
'</error> reserved keyword violations in your database schema:'
,
true
);
foreach
(
$violations
AS
$violation
)
{
$output
->
write
(
' - '
.
$violation
,
true
);
}
}
}
}
lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
View file @
547eaaff
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -32,7 +30,6 @@ use Symfony\Component\Console\Input\InputArgument,
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
...
...
tests/Doctrine/Tests/DBAL/AllTests.php
View file @
547eaaff
...
...
@@ -29,6 +29,7 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\PostgreSqlPlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\MsSqlPlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\OraclePlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\ReservedKeywordsValidatorTest'
);
// Type tests
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Types\ArrayTest'
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
547eaaff
...
...
@@ -204,4 +204,15 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{
$this
->
markTestSkipped
(
'Platform does not support Column comments.'
);
}
/**
* @group DBAL-45
*/
public
function
testKeywordList
()
{
$keywordList
=
$this
->
_platform
->
getReservedKeywordsList
();
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Platforms\Keywords\KeywordList'
,
$keywordList
);
$this
->
assertTrue
(
$keywordList
->
isKeyword
(
'table'
));
}
}
tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php
0 → 100644
View file @
547eaaff
<?php
namespace
Doctrine\Tests\DBAL\Platforms
;
use
Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\Column
;
use
Doctrine\DBAL\Types\Type
;
class
ReservedKeywordsValidatorTest
extends
\Doctrine\Tests\DbalTestCase
{
/**
* @var ReservedKeywordsValidator
*/
private
$validator
;
public
function
setUp
()
{
$this
->
validator
=
new
ReservedKeywordsValidator
(
array
(
new
\Doctrine\DBAL\Platforms\Keywords\MySQLKeywords
()
));
}
public
function
testReservedTableName
()
{
$table
=
new
Table
(
"TABLE"
);
$this
->
validator
->
acceptTable
(
$table
);
$this
->
assertEquals
(
array
(
'Table TABLE keyword violations: MySQL'
),
$this
->
validator
->
getViolations
()
);
}
public
function
testReservedColumnName
()
{
$table
=
new
Table
(
"TABLE"
);
$column
=
$table
->
addColumn
(
'table'
,
'string'
);
$this
->
validator
->
acceptColumn
(
$table
,
$column
);
$this
->
assertEquals
(
array
(
'Table TABLE column table keyword violations: MySQL'
),
$this
->
validator
->
getViolations
()
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment