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
58b03f35
Commit
58b03f35
authored
Jun 26, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Oracle testfailures and problem with Date Diff calculation
parent
ffff175c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+12
-1
DataAccessTest.php
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+4
-2
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+1
-1
No files found.
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
58b03f35
...
...
@@ -100,9 +100,20 @@ class OraclePlatform extends AbstractPlatform
return
'SYS_GUID()'
;
}
/**
* Get the number of days difference between two dates.
*
* Note: Since Oracle timestamp differences are calculated down to the microsecond we have to truncate
* them to the difference in days. This is obviously a restriction of the original functionality, but we
* need to make this a portable function.
*
* @param type $date1
* @param type $date2
* @return type
*/
public
function
getDateDiffExpression
(
$date1
,
$date2
)
{
return
'('
.
$date1
.
'-'
.
$date2
.
')'
;
return
"TRUNC(TO_NUMBER(SUBSTR(("
.
$date1
.
"-"
.
$date2
.
"), 1, INSTR("
.
$date1
.
"-"
.
$date2
.
", ' '))))"
;
}
public
function
getDateAddDaysExpression
(
$date
,
$days
)
...
...
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
View file @
58b03f35
...
...
@@ -252,7 +252,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
{
$p
=
$this
->
_conn
->
getDatabasePlatform
();
$sql
=
'SELECT '
;
$sql
.=
$p
->
getDateDiffExpression
(
'test_datetime'
,
"'2010-12-24 12:00:00'"
)
.
' AS diff, '
;
$sql
.=
$p
->
getDateDiffExpression
(
'test_datetime'
,
$p
->
getCurrentTimestampSQL
()
)
.
' AS diff, '
;
$sql
.=
$p
->
getDateAddDaysExpression
(
'test_datetime'
,
10
)
.
' AS add_days, '
;
$sql
.=
$p
->
getDateSubDaysExpression
(
'test_datetime'
,
10
)
.
' AS sub_days, '
;
$sql
.=
$p
->
getDateAddMonthExpression
(
'test_datetime'
,
2
)
.
' AS add_month, '
;
...
...
@@ -260,8 +260,10 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql
.=
'FROM fetch_table'
;
$row
=
$this
->
_conn
->
fetchAssoc
(
$sql
);
$row
=
array_change_key_case
(
$row
,
CASE_LOWER
);
$this
->
assertEquals
(
-
357
,
(
int
)
$row
[
'diff'
],
"Date difference should be -356 days."
);
$diff
=
floor
(
(
strtotime
(
'2010-01-01'
)
-
time
())
/
3600
/
24
);
$this
->
assertEquals
(
$diff
,
(
int
)
$row
[
'diff'
],
"Date difference should be approx. "
.
$diff
.
" days."
,
1
);
$this
->
assertEquals
(
'2010-01-11'
,
date
(
'Y-m-d'
,
strtotime
(
$row
[
'add_days'
])),
"Adding date should end up on 2010-01-11"
);
$this
->
assertEquals
(
'2009-12-22'
,
date
(
'Y-m-d'
,
strtotime
(
$row
[
'sub_days'
])),
"Subtracting date should end up on 2009-12-22"
);
$this
->
assertEquals
(
'2010-03-01'
,
date
(
'Y-m-d'
,
strtotime
(
$row
[
'add_month'
])),
"Adding month should end up on 2010-03-01"
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
58b03f35
...
...
@@ -32,7 +32,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase
return
array
(
'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL)'
,
"ALTER TABLE mytable MODIFY (baz VARCHAR2(255) DEFAULT 'def' NOT NULL)"
,
"ALTER TABLE mytable DROP
COLUMN foo
"
,
"ALTER TABLE mytable DROP
(foo)
"
,
"ALTER TABLE mytable RENAME TO userlist"
,
);
}
...
...
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