#1096: Support for uniqueidentifier type in MS SQL
----------------------------+-----------------------------------------------
Reporter: sgriffin | Owner: jwage
Type: defect | Status: new
Priority: major | Milestone:
Component: Import/Export | Version:
Resolution: | Keywords:
Has_test: 0 | Mystatus: Pending Core Response
Has_patch: 0 |
----------------------------+-----------------------------------------------
Changes (by jwage):
* version: 1.0.2 =>
* milestone: 1.0.4 =>
Old description:
> Vitals:[[BR]]
> -------------------------[[BR]]
> OS: Ubuntu Linux 8.04[[BR]]
> Doctrine: 0.10.4-Sandbox[[BR]]
> PHP 5.2.5[[BR]]
> MS SQL Server 2000[[BR]]
> dblib pdo driver[[BR]]
>
> Description:[[BR]]
> ------------------------------------------------------------------------------------------------------------------------------------------[[BR]]
> Most MS SQL databases use uniqueidentifier for primary keys. When
> importing an existing schema using Doctrine I get this output:[[BR]]
> [[BR]]
> Fatal error: Uncaught exception 'Doctrine_DataDict_Exception' with
> message 'unknown database attribute type: uniqueidentifier' in
> [[BR]][redacted]/Doctrine-0.10.4-Sandbox/lib/Doctrine/DataDict/Mssql.php:187[[BR]]
>
> Notes:[[BR]]
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------[[BR]]
> This data type is in fact binary, and PDO will return it as garbage if
> the query doesn't specify to cast it as CHAR(36). These id's are also
> used in applications so it is[[BR]] important that they are usable in
> program code:[[BR]]
>
> echo "<a href="thepage.php?id=" . $file->Id ."">$file->name</a>";[[BR]]
> [[BR]]
> Also, as these are typically used to define primary keys in tables, it is
> important that Doctrine knows to use them (where appropriate) to find
> related items.[[BR]]
> [[BR]]
> Steps to reproduce:[[BR]]
> -----------------------------------------------------------------------[[BR]]
> Run the following database scripts:[[BR]]
> [[BR]]
> CREATE TABLE ImportThis ([[BR]]
> guid uniqueidentifier ROWGUIDCOL NOT NULL,[[BR]]
> value nvarchar(255) NOT NULL[[BR]]
> )[[BR]]
> [[BR]]
> INSERT INTO ImportThis VALUES (newid(), 'I can has an ORM?')[[BR]]
> [[BR]]
> In doctrine sandbox directory create a file called import.php[[BR]]
> [[BR]]
> <?php[[BR]]
> [[BR]]
> require_once('lib/Doctrine.php');[[BR]]
> [[BR]]
> spl_autoload_register(array('Doctrine', 'autoload'));[[BR]]
> Doctrine_Manager::connection('dblib://username:[EMAIL
> PROTECTED]/dbname');[[BR]]
> Doctrine::generateModelsFromDb('models');[[BR]]
> [[BR]]
> ?>[[BR]]
> [[BR]]
> on the command line:[[BR]]
> [[BR]]
> php import.php
New description:
Vitals:[[BR]]
-------------------------[[BR]]
OS: Ubuntu Linux 8.04[[BR]]
Doctrine: 0.10.4-Sandbox[[BR]]
PHP 5.2.5[[BR]]
MS SQL Server 2000[[BR]]
dblib pdo driver[[BR]]
Description:[[BR]]
------------------------------------------------------------------------------------------------------------------------------------------[[BR]]
Most MS SQL databases use uniqueidentifier for primary keys. When
importing an existing schema using Doctrine I get this output:[[BR]]
[[BR]]
Fatal error: Uncaught exception 'Doctrine_DataDict_Exception' with message
'unknown database attribute type: uniqueidentifier' in
[[BR]][redacted]/Doctrine-0.10.4-Sandbox/lib/Doctrine/DataDict/Mssql.php:187[[BR]]
Notes:[[BR]]
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------[[BR]]
This data type is in fact binary, and PDO will return it as garbage if the
query doesn't specify to cast it as CHAR(36). These id's are also used in
applications so it is[[BR]] important that they are usable in program
code:[[BR]]
echo "<a href="thepage.php?id=" . $file->Id ."">$file->name</a>";[[BR]]
[[BR]]
Also, as these are typically used to define primary keys in tables, it is
important that Doctrine knows to use them (where appropriate) to find
related items.[[BR]]
[[BR]]
Steps to reproduce:[[BR]]
-----------------------------------------------------------------------[[BR]]
Run the following database scripts:[[BR]]
[[BR]]
CREATE TABLE ImportThis ([[BR]]
guid uniqueidentifier ROWGUIDCOL NOT NULL,[[BR]]
value nvarchar(255) NOT NULL[[BR]]
)[[BR]]
[[BR]]
INSERT INTO ImportThis VALUES (newid(), 'I can has an ORM?')[[BR]]
[[BR]]
In doctrine sandbox directory create a file called import.php[[BR]]
[[BR]]
<?php[[BR]]
[[BR]]
require_once('lib/Doctrine.php');[[BR]]
[[BR]]
spl_autoload_register(array('Doctrine', 'autoload'));[[BR]]
Doctrine_Manager::connection('dblib://username:[EMAIL
PROTECTED]/dbname');[[BR]]
Doctrine::generateModelsFromDb('models');[[BR]]
[[BR]]
?>[[BR]]
[[BR]]
on the command line:[[BR]]
[[BR]]
php import.php
--
Ticket URL: <http://trac.doctrine-project.org/ticket/1096#comment:6>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"doctrine-svn" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---