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
b959fa3d
Commit
b959fa3d
authored
Dec 07, 2011
by
Fabio B. Silva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for bit comparison
parent
23d2950c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
0 deletions
+94
-0
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+24
-0
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+30
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+28
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+12
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
b959fa3d
...
@@ -786,6 +786,30 @@ abstract class AbstractPlatform
...
@@ -786,6 +786,30 @@ abstract class AbstractPlatform
throw
DBALException
::
notSupported
(
__METHOD__
);
throw
DBALException
::
notSupported
(
__METHOD__
);
}
}
/**
* Gets SQL bit and comparison expression
*
* @param string $value1
* @param string $value2
* @return string
*/
public
function
getBitAndComparisonExpression
(
$value1
,
$value2
)
{
return
'('
.
$value1
.
' & '
.
$value2
.
')'
;
}
/**
* Gets SQL bit and comparison expression
*
* @param string $value1
* @param string $value2
* @return string
*/
public
function
getBitOrComparisonExpression
(
$value1
,
$value2
)
{
return
'('
.
$value1
.
' | '
.
$value2
.
')'
;
}
public
function
getForUpdateSQL
()
public
function
getForUpdateSQL
()
{
{
return
'FOR UPDATE'
;
return
'FOR UPDATE'
;
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
b959fa3d
...
@@ -116,25 +116,55 @@ class OraclePlatform extends AbstractPlatform
...
@@ -116,25 +116,55 @@ class OraclePlatform extends AbstractPlatform
return
"TRUNC(TO_NUMBER(SUBSTR(("
.
$date1
.
"-"
.
$date2
.
"), 1, INSTR("
.
$date1
.
"-"
.
$date2
.
", ' '))))"
;
return
"TRUNC(TO_NUMBER(SUBSTR(("
.
$date1
.
"-"
.
$date2
.
"), 1, INSTR("
.
$date1
.
"-"
.
$date2
.
", ' '))))"
;
}
}
/**
* {@inheritdoc}
*/
public
function
getDateAddDaysExpression
(
$date
,
$days
)
public
function
getDateAddDaysExpression
(
$date
,
$days
)
{
{
return
'('
.
$date
.
'+'
.
$days
.
')'
;
return
'('
.
$date
.
'+'
.
$days
.
')'
;
}
}
/**
* {@inheritdoc}
*/
public
function
getDateSubDaysExpression
(
$date
,
$days
)
public
function
getDateSubDaysExpression
(
$date
,
$days
)
{
{
return
'('
.
$date
.
'-'
.
$days
.
')'
;
return
'('
.
$date
.
'-'
.
$days
.
')'
;
}
}
/**
* {@inheritdoc}
*/
public
function
getDateAddMonthExpression
(
$date
,
$months
)
public
function
getDateAddMonthExpression
(
$date
,
$months
)
{
{
return
"ADD_MONTHS("
.
$date
.
", "
.
$months
.
")"
;
return
"ADD_MONTHS("
.
$date
.
", "
.
$months
.
")"
;
}
}
/**
* {@inheritdoc}
*/
public
function
getDateSubMonthExpression
(
$date
,
$months
)
public
function
getDateSubMonthExpression
(
$date
,
$months
)
{
{
return
"ADD_MONTHS("
.
$date
.
", -"
.
$months
.
")"
;
return
"ADD_MONTHS("
.
$date
.
", -"
.
$months
.
")"
;
}
}
/**
* {@inheritdoc}
*/
public
function
getBitAndComparisonExpression
(
$value1
,
$value2
)
{
return
'BITAND('
.
$value1
.
', '
.
$value2
.
')'
;
}
/**
* {@inheritdoc}
*/
public
function
getBitOrComparisonExpression
(
$value1
,
$value2
)
{
return
'('
.
$value1
.
'-'
.
$this
->
getBitAndComparisonExpression
(
$value1
,
$value2
)
.
'+'
.
$value2
.
')'
;
}
/**
/**
* Gets the SQL used to create a sequence that starts with a given value
* Gets the SQL used to create a sequence that starts with a given value
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
b959fa3d
...
@@ -130,6 +130,34 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
...
@@ -130,6 +130,34 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$sql
=
$this
->
_platform
->
getCreateConstraintSQL
(
$fk
,
'test'
);
$sql
=
$this
->
_platform
->
getCreateConstraintSQL
(
$fk
,
'test'
);
$this
->
assertEquals
(
$this
->
getGenerateConstraintForeignKeySql
(),
$sql
);
$this
->
assertEquals
(
$this
->
getGenerateConstraintForeignKeySql
(),
$sql
);
}
}
protected
function
getBitAndComparisonExpressionSql
(
$value1
,
$value2
)
{
return
'('
.
$value1
.
' & '
.
$value2
.
')'
;
}
/**
* @group DDC-1213
*/
public
function
testGeneratesBitAndComparisonExpressionSql
()
{
$sql
=
$this
->
_platform
->
getBitAndComparisonExpression
(
2
,
4
);
$this
->
assertEquals
(
$this
->
getBitAndComparisonExpressionSql
(
2
,
4
),
$sql
);
}
protected
function
getBitOrComparisonExpressionSql
(
$value1
,
$value2
)
{
return
'('
.
$value1
.
' | '
.
$value2
.
')'
;
}
/**
* @group DDC-1213
*/
public
function
testGeneratesBitOrComparisonExpressionSql
()
{
$sql
=
$this
->
_platform
->
getBitOrComparisonExpression
(
2
,
4
);
$this
->
assertEquals
(
$this
->
getBitOrComparisonExpressionSql
(
2
,
4
),
$sql
);
}
public
function
getGenerateConstraintUniqueIndexSql
()
public
function
getGenerateConstraintUniqueIndexSql
()
{
{
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
b959fa3d
...
@@ -204,4 +204,16 @@ class OraclePlatformTest extends AbstractPlatformTestCase
...
@@ -204,4 +204,16 @@ class OraclePlatformTest extends AbstractPlatformTestCase
"COMMENT ON COLUMN mytable.baz IS 'B comment'"
,
"COMMENT ON COLUMN mytable.baz IS 'B comment'"
,
);
);
}
}
public
function
getBitAndComparisonExpressionSql
(
$value1
,
$value2
)
{
return
'BITAND('
.
$value1
.
', '
.
$value2
.
')'
;
}
public
function
getBitOrComparisonExpressionSql
(
$value1
,
$value2
)
{
return
'('
.
$value1
.
'-'
.
$this
->
getBitAndComparisonExpressionSql
(
$value1
,
$value2
)
.
'+'
.
$value2
.
')'
;
}
}
}
\ 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