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
a65ea05f
Commit
a65ea05f
authored
Sep 04, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Fixed scale/precision support in SchemaTool
parent
60b31c7a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
0 deletions
+40
-0
SchemaTool.php
lib/Doctrine/ORM/Tools/SchemaTool.php
+6
-0
DecimalModel.php
tests/Doctrine/Tests/Models/Generic/DecimalModel.php
+20
-0
AllTests.php
tests/Doctrine/Tests/ORM/Functional/SchemaTool/AllTests.php
+1
-0
MySqlSchemaToolTest.php
...e/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php
+13
-0
No files found.
lib/Doctrine/ORM/Tools/SchemaTool.php
View file @
a65ea05f
...
...
@@ -236,6 +236,12 @@ class SchemaTool
$column
[
'type'
]
=
Type
::
getType
(
$mapping
[
'type'
]);
$column
[
'length'
]
=
isset
(
$mapping
[
'length'
])
?
$mapping
[
'length'
]
:
null
;
$column
[
'notnull'
]
=
isset
(
$mapping
[
'nullable'
])
?
!
$mapping
[
'nullable'
]
:
false
;
if
(
isset
(
$mapping
[
'precision'
]))
{
$column
[
'precision'
]
=
$mapping
[
'precision'
];
}
if
(
isset
(
$mapping
[
'scale'
]))
{
$column
[
'scale'
]
=
$mapping
[
'scale'
];
}
if
(
isset
(
$mapping
[
'default'
]))
{
$column
[
'default'
]
=
$mapping
[
'default'
];
}
...
...
tests/Doctrine/Tests/Models/Generic/DecimalModel.php
0 → 100644
View file @
a65ea05f
<?php
namespace
Doctrine\Tests\Models\Generic
;
/**
* @Entity
* @Table(name="date_time_model")
*/
class
DecimalModel
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public
$id
;
/**
* @Column(type="decimal", scale=5, precision=2)
*/
public
$decimal
;
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Functional/SchemaTool/AllTests.php
View file @
a65ea05f
...
...
@@ -20,6 +20,7 @@ class AllTests
$suite
=
new
\Doctrine\Tests\DoctrineTestSuite
(
'Doctrine Orm Functional Tools'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\SchemaTool\MySqlSchemaToolTest'
);
//$suite->addTestSuite('Doctrine\Tests\ORM\Functional\SchemaTool\PostgreSqlSchemaToolTest');
return
$suite
;
}
...
...
tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php
View file @
a65ea05f
...
...
@@ -37,6 +37,19 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertEquals
(
"ALTER TABLE cms_phonenumbers ADD FOREIGN KEY (user_id) REFERENCES cms_users(id)"
,
$sql
[
7
]);
}
public
function
testGetCreateSchemaSql2
()
{
$classes
=
array
(
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\Models\Generic\DecimalModel'
)
);
$tool
=
new
SchemaTool
(
$this
->
_em
);
$sql
=
$tool
->
getCreateSchemaSql
(
$classes
);
$this
->
assertEquals
(
1
,
count
(
$sql
));
$this
->
assertEquals
(
"CREATE TABLE date_time_model (id INT AUTO_INCREMENT NOT NULL, decimal NUMERIC(2, 5) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB"
,
$sql
[
0
]);
}
public
function
testGetUpdateSchemaSql
()
{
$classes
=
array
(
...
...
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