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
01c5461f
Commit
01c5461f
authored
Sep 25, 2014
by
Thomas Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix quoted sequence name
parent
d8a96fcf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
15 deletions
+58
-15
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+5
-2
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+53
-13
No files found.
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
01c5461f
...
@@ -494,7 +494,10 @@ BEGIN
...
@@ -494,7 +494,10 @@ BEGIN
END IF;
END IF;
END;'
;
END;'
;
$sequenceName
=
$this
->
getIdentitySequenceName
(
$unquotedTableName
,
$unquotedName
);
$sequenceName
=
$this
->
getIdentitySequenceName
(
$tableIdentifier
->
isQuoted
()
?
$quotedTableName
:
$unquotedTableName
,
$nameIdentifier
->
isQuoted
()
?
$quotedName
:
$unquotedName
);
$sequence
=
new
Sequence
(
$sequenceName
,
$start
);
$sequence
=
new
Sequence
(
$sequenceName
,
$start
);
$sql
[]
=
$this
->
getCreateSequenceSQL
(
$sequence
);
$sql
[]
=
$this
->
getCreateSequenceSQL
(
$sequence
);
...
@@ -512,7 +515,7 @@ BEGIN
...
@@ -512,7 +515,7 @@ BEGIN
ELSE
ELSE
SELECT NVL(Last_Number, 0) INTO last_Sequence
SELECT NVL(Last_Number, 0) INTO last_Sequence
FROM User_Sequences
FROM User_Sequences
WHERE Sequence_Name = \''
.
$sequence
Name
.
'\';
WHERE Sequence_Name = \''
.
$sequence
->
getName
()
.
'\';
SELECT :NEW.'
.
$quotedName
.
' INTO last_InsertID FROM DUAL;
SELECT :NEW.'
.
$quotedName
.
' INTO last_InsertID FROM DUAL;
WHILE (last_InsertID > last_Sequence) LOOP
WHILE (last_InsertID > last_Sequence) LOOP
SELECT '
.
$sequenceName
.
'.NEXTVAL INTO last_Sequence FROM DUAL;
SELECT '
.
$sequenceName
.
'.NEXTVAL INTO last_Sequence FROM DUAL;
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
01c5461f
...
@@ -602,4 +602,44 @@ class OraclePlatformTest extends AbstractPlatformTestCase
...
@@ -602,4 +602,44 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
)
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
)
);
);
}
}
public
function
testQuotedTableNames
()
{
$table
=
new
Table
(
'"test"'
);
$table
->
addColumn
(
'"id"'
,
'integer'
,
array
(
'autoincrement'
=>
true
));
// assert tabel
$this
->
assertTrue
(
$table
->
isQuoted
());
$this
->
assertEquals
(
'test'
,
$table
->
getName
());
$this
->
assertEquals
(
'"test"'
,
$table
->
getQuotedName
(
$this
->
_platform
));
$sql
=
$this
->
_platform
->
getCreateTableSQL
(
$table
);
$this
->
assertEquals
(
'CREATE TABLE "test" ("id" NUMBER(10) NOT NULL)'
,
$sql
[
0
]);
$this
->
assertEquals
(
'CREATE SEQUENCE "test_SEQ" START WITH 1 MINVALUE 1 INCREMENT BY 1'
,
$sql
[
2
]);
$createTriggerStatement
=
<<<EOD
CREATE TRIGGER "test_AI_PK"
BEFORE INSERT
ON "test"
FOR EACH ROW
DECLARE
last_Sequence NUMBER;
last_InsertID NUMBER;
BEGIN
SELECT "test_SEQ".NEXTVAL INTO :NEW."id" FROM DUAL;
IF (:NEW."id" IS NULL OR :NEW."id" = 0) THEN
SELECT "test_SEQ".NEXTVAL INTO :NEW."id" FROM DUAL;
ELSE
SELECT NVL(Last_Number, 0) INTO last_Sequence
FROM User_Sequences
WHERE Sequence_Name = 'test_SEQ';
SELECT :NEW."id" INTO last_InsertID FROM DUAL;
WHILE (last_InsertID > last_Sequence) LOOP
SELECT "test_SEQ".NEXTVAL INTO last_Sequence FROM DUAL;
END LOOP;
END IF;
END;
EOD;
$this
->
assertEquals
(
$createTriggerStatement
,
$sql
[
3
]);
}
}
}
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