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
ffa7ff54
Commit
ffa7ff54
authored
Jan 21, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed pgsql and sqlite sequence handlers and test cases
parent
1eb8b54d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
9 deletions
+19
-9
Pgsql.php
lib/Doctrine/Sequence/Pgsql.php
+1
-1
Sqlite.php
lib/Doctrine/Sequence/Sqlite.php
+3
-4
DriverTestCase.php
tests/DriverTestCase.php
+7
-2
AggregateValueTestCase.php
tests/Query/AggregateValueTestCase.php
+4
-0
PgsqlTestCase.php
tests/Sequence/PgsqlTestCase.php
+2
-2
SqliteTestCase.php
tests/Sequence/SqliteTestCase.php
+2
-0
No files found.
lib/Doctrine/Sequence/Pgsql.php
View file @
ffa7ff54
...
...
@@ -69,7 +69,7 @@ class Doctrine_Sequence_Pgsql extends Doctrine_Sequence
*/
public
function
lastInsertId
(
$table
=
null
,
$field
=
null
)
{
$seq
=
$table
.
(
empty
(
$field
)
?
''
:
'_'
.
$field
);
$seq
Name
=
$table
.
(
empty
(
$field
)
?
''
:
'_'
.
$field
);
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getSequenceName
(
$seqName
),
true
);
return
(
int
)
$this
->
conn
->
fetchOne
(
"SELECT CURRVAL('"
.
$sequenceName
.
"')"
);
...
...
lib/Doctrine/Sequence/Sqlite.php
View file @
ffa7ff54
...
...
@@ -67,16 +67,15 @@ class Doctrine_Sequence_Sqlite extends Doctrine_Sequence
}
}
$value
=
$this
->
conn
->
getDbh
()
->
lastInsertI
D
();
$value
=
$this
->
conn
->
getDbh
()
->
lastInsertI
d
();
if
(
is_numeric
(
$value
))
{
$query
=
'DELETE FROM '
.
$sequenceName
.
' WHERE '
.
$seqcolName
.
' < '
.
$value
;
$this
->
conn
->
exec
(
$query
);
/**
TODO: is the following needed ?
if (PEAR::isError($result)) {
$this->warnings[] = 'nextID: could not delete previous sequence table values from '.$seq_name;
}
$this->warnings[] = 'nextID: could not delete previous sequence table values from '.$seq_name;
*/
}
return
$value
;
...
...
tests/DriverTestCase.php
View file @
ffa7ff54
...
...
@@ -68,8 +68,13 @@ class AdapterMock implements Doctrine_Adapter_Interface {
return
0
;
}
public
function
forceLastInsertIdFail
()
{
$this
->
lastInsertIdFail
=
true
;
public
function
forceLastInsertIdFail
(
$fail
=
true
)
{
if
(
$fail
)
{
$this
->
lastInsertIdFail
=
true
;
}
else
{
$this
->
lastInsertIdFail
=
false
;
}
}
public
function
lastInsertId
()
{
...
...
tests/Query/AggregateValueTestCase.php
View file @
ffa7ff54
...
...
@@ -127,6 +127,10 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
$users
=
$q
->
execute
();
$this
->
assertEqual
(
$users
->
count
(),
1
);
}
public
function
testAggregateValueMappingSupportsLeftJoins3
()
{
}
public
function
testAggregateValueMappingSupportsInnerJoins
()
{
...
...
tests/Sequence/PgsqlTestCase.php
View file @
ffa7ff54
...
...
@@ -34,7 +34,7 @@ class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase {
public
function
testCurrIdExecutesSql
()
{
$this
->
sequence
->
currId
(
'user'
);
$q
=
"SELECT
(last_number-1) FROM user_sequences WHERE sequence_name='user_seq' OR sequence_name='USER_SEQ'
"
;
$q
=
"SELECT
last_value FROM user_seq
"
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
...
...
@@ -49,6 +49,6 @@ class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase {
{
$this
->
sequence
->
lastInsertId
(
'user'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SELECT user_seq.currval'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
"SELECT CURRVAL('user_seq')"
);
}
}
tests/Sequence/SqliteTestCase.php
View file @
ffa7ff54
...
...
@@ -34,6 +34,8 @@ class Doctrine_Sequence_Sqlite_TestCase extends Doctrine_UnitTestCase
{
public
function
testCurrIdExecutesSql
()
{
$this
->
adapter
->
forceLastInsertIdFail
(
false
);
$this
->
sequence
->
currId
(
'user'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SELECT MAX(id) FROM user_seq'
);
...
...
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