[DC-1059] Generate Entity From Database Created: 27/Sep/12  Updated: 27/Sep/12

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Draeli Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Problem already report here : https://github.com/symfony/symfony/issues/5617#issuecomment-8934524
But the idea is, on generation of entity from database MySQL, Int and Tinyint type are tranform as booelan.






[DC-1047] hardDelete not resetting flag if exception is thrown Created: 06/Jan/12  Updated: 06/Jan/12

Status: Open
Project: Doctrine 1
Component/s: Behaviors
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Lone Wolf Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File softdelete_exception.patch    

 Description   

To be honest I don't know wich version I have but I believe it to be 1.2.3

The problem is pretty simple, I was trying to do a hardDelete and if it fails I would do a softDelete.
Example

try {
    $record->hardDelete();
}
catch (Exception $e) {
    if ($e instanceof Doctrine_Connection_Mysql_Exception && $e->getPortableCode() == Doctrine_Core::ERR_CONSTRAINT) {
        try {
            $record->delete();
        }
        catch (Exception $e1) {
            throw $e1;
        }
    }
    else {
        throw $e;
    }
}

But when the first exception is thrown from hardDelete() in Doctrine_Template_SoftDelete(line 84) the listener flag for hardDelete is not set to false, so if I try to do the delete, it will still behave as if it was a hardDelete.

The solution would be catch the exception, reset the flag and rethrow it.
Patch attached

Hope this info is enough.






[DC-1044] record Line 2430 Unlink method Warning: Illegal offset type in sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 2459 Created: 05/Dec/11  Updated: 05/Dec/11

Status: Open
Project: Doctrine 1
Component/s: Record
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Kyle Clarke Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None


 Description   

When you have a new unpersisted object and you call a method to a referenced object - when calling the unlink() method on referenced object the above error is called.

Warning: Illegal offset type in sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 2459

eg

$foo = new foo();

$foo->getBar(); This call will bind a reference of Bar against the foo object.

$foo->unlink('bar');

As no objects are yet persisted, the unlink method tries to match ids on the objects that do not exist.






[DC-1028] Doctrine Migrate functions for current version and for creating the migrations table Created: 16/Aug/11  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Migrations
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Stephen Ostrow Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I always tend to find myself needing to implement migrations after the fact. It would be really nice to have a method of having doctrine creating the migration_version table as well as a method of setting that value and getting that value.

This would in-turn allow the implementation in a framework such as symfony to allow you insert the table after the fact, allow you to update the migration version without running the migration and to let you know what version you're currently on.






[DC-1018] Circular references to named entities break during data importing Created: 14/Jul/11  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Record
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Mike Seth Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

If the schema specifies that records relate to each other in both directions:

{{
Kitten:
columns:
basket_id: integer
relations:
Basket:
local: basket_id

Basket:
columns:
fluffiest_kitten_id: integer
relaitons:
FluffiestKitten:
type: one
class: Kitten
local: fluffiest_kitten_id
}}

Then a data dump for such a schema won't properly load one of the keys, e.g:

{{
Kitten:
Kitten1:
Basket: Basket1

Basket:
Basket1:
FluffiestKitten: Kitten1
}}

Will result in either fluffiest_kitten_id or basket_id being set to 0

See also ticket DC-555






[DC-1017] Floats persisted in the database are retrieve as strings. Created: 12/Jul/11  Updated: 12/Jul/11

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Grégoire Paris Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Ubuntu 64 bits, php 5.3



 Description   

Someone complained about symfony padding 0's after floats http://stackoverflow.com/questions/6650786/remove-extra-decimal-place-in-float-datatype-on-symfony/6663829 , I think it's a doctrine problem, since the doctrine:dql task seems to have the same problem:

>> doctrine executing dql query
DQL: FROM UcVideoAspect
found 1 results
-
id: '1'
video_id: null
pixel_ratio: '12.50'
width: null
height: null

Here, pixel ratio is defined as a float in the schema.yml file
Getting the property from a transient object returns a float, while getting it from the db returns a string.






[DC-1016] Set method in update query ignores 'false' if passed as boolean Created: 05/Jul/11  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Paweł Barański Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Symfony 1.4.11 , Ubuntu 11, PHP 5.3



 Description   

I had to define this function:

public function deactivate($segment_id)

{ $query = $this->createQuery() ->update('Segment s') ->set('s.is_active ', false) //not working // ->set('s.is_active ', (int)false) //works ok // ->set('s.is_active ', true) //works ok ->where('s.id = ?', $segment_id); // var_dump($query->getSqlQuery());die; return $query->execute(); }

Problem is that when setting a column using boolean false you get invalid SQL query like this:
UPDATE segment SET is_active = WHERE (id = ?)

Workaround is to do it like this: set('s.is_active ', (int)false) , but since setting the same column with boolean true works, false should work too.






[DC-1012] Doctrine_core specified twice in documentation Defining Models -> Join Table Associations Created: 28/Jun/11  Updated: 28/Jun/11

Status: Open
Project: Doctrine 1
Component/s: Documentation
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Documentation Priority: Minor
Reporter: Justinas Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

$manager->setAttribute(Doctrine_Core::Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);

should be:

$manager->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);

http://www.doctrine-project.org/projects/orm/1.2/docs/manual/defining-models/en#relationships:join-table-associations






[DC-1006] Custom geometric query error with orderBy Created: 22/May/11  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Attributes
Affects Version/s: None
Fix Version/s: 1.2.2

Type: Bug Priority: Minor
Reporter: Leonardo Lazzaro Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Symfony 1.4.11 and Doctrine 1.2.4. Ubuntu 11.04 Apache2 with mod php5. php5 version PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch



 Description   

Mi Doctrine_Query with this Geometric Query fails with orderBy , but with where works.

$distance = "glength(linestringfromwkb(linestring(GeomFromText('POINT( ".$object->getLatitude()." ".$object->getLongitude() .")'),l.point))) "

This works:
SomeObjectTable::getInstance()>createQuery()>where($distance.' < ?',0.05 )

But this one fails at version 1.2.4, with older version was working.
SomeObjectTable::getInstance()>createQuery()>where($distance.' < ?',0.05 )->orderBy($distance)

Well the problem is at line 74 of OrderBy.php :
$componentAlias = implode('.', $e);

the rendered query in the distance has some ".", for example:
POINT( -34.470829 -58.5286102)

then the after line 74 in OrderBy tries to search por '58' class.

I manually added to DataDict in Mysql.php the POINT datatype (this fix solve me the problem in older versions of Doctrine).






[DC-1005] Schema importer sometimes overwrites relations (instead of adding them) due to issue with bugfix DC-281 Created: 17/May/11  Updated: 17/May/11

Status: Open
Project: Doctrine 1
Component/s: Import/Export
Affects Version/s: 1.2.0, 1.2.1, 1.2.2, 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Pelle ten Cate Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

The bugfix for DC-281 (r6802) contains an issue:

When between two tables in a MySQL database there are two relations, one on both sides (i.e. both tables have a FK field to each other), one of the two is overwritten with the second by the schema importer. That is, at one class, there seems to be only one relation instead of both.

The issue came in when the decision was made to store all class names in the definition array lower case, as one of the lookups in the array was not updated appropriately.

See Doctrine/Import.php (1.2.4) line 416 - 435. In line 427, you can clearly see the change made in 6802

Old:
$definitions[$relation['class']]['relations'][$alias] = array(
New:
$definitions[strtolower($relation['class'])]['relations'][$alias] = array(

Line 421 however should also have been updated:

if (in_array($relation['class'], $relClasses) || isset($definitions[$relation['class']]['relations'][$className])) {
Proposed fix:
if (in_array($relation['class'], $relClasses) || isset($definitions[strtolower($relation['class'])]['relations'][$className])) {

This error results in relations that already exist sometimes being overwritten.






[DC-1003] _processWhereIn does not allow the use of named query parameters Created: 05/May/11  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: alex pilon Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None
Environment:

karmic, php 5.2.10, apache2


Attachments: Text File _processWhereIn-named-parameter-v2.patch     Text File _processWhereIn-named-parameter.patch    

 Description   

When writing a query such as

$query = $query->where('entity.myValue = :value', array(':value'=>5));

you are unable to then

$query = $query->whereIn('entity.otherValue', array(':otherValues'=>array(1,2,3)));

Doctrine complains that you may not mix positional and named query parameters.

The attached patch fixes this by checking if the key of the passed in parameter is non numeric and if so setting the "value" of the parameter place holder to the value of the key.



 Comments   
Comment by alex pilon [ 05/May/11 ]

I discovered an issue with the above patch. I am working on a better version.

Comment by alex pilon [ 06/May/11 ]

Here is a second version.. it is a little bit sloppy. Is there a resource I can find on here that will help me to improve code quality/unit test this?





[DC-1001] Doctrine Caching page does not mention the "prefix" option Created: 29/Apr/11  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Caching, Documentation
Affects Version/s: None
Fix Version/s: None

Type: Documentation Priority: Minor
Reporter: Arend van Waart Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 1
Labels: None


 Description   

http://www.doctrine-project.org/documentation/manual/1_1/en/caching

When not using a prefix with multiple / yet similay projects a mixup of query caching will occur (for example with sfDoctrineGuard queries). This is very easialy fixed with a prefix - but I only realized after two months - that this feature actually existed. There is no mention of this in the documention.

A mention of the feature

$q = Doctrine_Query::create()
->useResultCache(new Doctrine_Cache_Apc(array('prefix'=>'myproject_')));

Would have helped me and I think it will also help others.



 Comments   
Comment by Pablo Grass [ 27/Jun/11 ]

I concur with Arend - mentioning of 'prefix' in the documentation could make this valuable feature much less of a pain to find...
Still holds true in 1.2. documentation: http://www.doctrine-project.org/projects/orm/1.2/docs/manual/caching/en





[DC-995] Doctrine deprecated in favor of Doctrine_Core - phpdoc Created: 06/Apr/11  Updated: 06/Apr/11

Status: Open
Project: Doctrine 1
Component/s: Documentation
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Documentation Priority: Minor
Reporter: Pablo Grass Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

all environments



 Description   

http://www.doctrine-project.org/projects/orm/1.2/docs/whats-new/en clearly states that the Doctrine class is deprecated - e.g. in order to allow for proper autoloading.
To enable IDEs to perform proper autocomplete and to encourage programmers not to use the Doctrine class anymore, it's phpdoc block shuld by changed in order to contain a

@deprecated In favor of Doctrine_Core - this class extends Doctrine_Core for BC






[DC-993] Many-to-many Relation defined one way Created: 05/Apr/11  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Relations
Affects Version/s: 1.2.2, 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Klaas van der Weij Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

MySQL database, Lenny



 Description   

When a many-tomany relation has been defined on only one of the end of the relation, and ofcourse in the cross-refClass, things get weird. I'll use the user-groups relation (as found in the documentation) as example.

If in the group model has not defined the hasMany, then a user can be instantiated and saved. When instantiated, the relation groups would return an empty array, groups can ben added like:

$u = new User();
var_dump($u->groups);
$u->groups[] = new Group();
var_dump($u->groups);

This would output an empty array, and subsequently an array containing the new group.

However, if a user would be retrieved from the database, and the relation groups would be called, then the following message will appear (which is not helpfull at alllll, I've spend hours figuring it out!):

Uncaught exception 'Doctrine_Record_UnknownPropertyException' with message 'Unknown record property / related component "groups"' .....

I will never forget this, but it's not described in the documentation and the error is not helping either. So either one of these step hvae to be taken. Or even better, making it work without requiring the hasMany in group, to users.






[DC-990] Values not escaped Created: 26/Mar/11  Updated: 26/Mar/11

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: 1.2.0
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Nick Bartlett Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

windows and linux OS, mysql database



 Description   

When I save inputs from a form, special characters such as single quotes are inserted into the mysql database without being escaped. It's my understanding that doctrine uses PDO and PDO should handle this escaping automatically, but it is not. Is there a configuration setting that I can set with doctrine to enable this?

Thanks
Nick






[DC-987] redundant sql statement in Doctrine_Export_Oracle::_makeAutoincrement() Created: 21/Mar/11  Updated: 21/Mar/11

Status: Open
Project: Doctrine 1
Component/s: Import/Export
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: David Dixon Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

linux, oracle



 Description   

line 121-128 of Doctrine_Export_Oracle appears to generate redundant code for creating a primary key constraint as primary keys (defined in schema.yml) are already generated during CREATE TABLE statements.






[DC-976] Invalid long constraint name Created: 19/Feb/11  Updated: 19/Feb/11

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Sébastien Rannou Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

OS: Linux
Soft platform: Symfony 1.4.8, mysql5


Attachments: Text File constraint_name.patch    

 Description   

When the constraint's name is too long, a shorter one is generated using information such as the name of the database. If the database's name begins with a numeric value, the constraint name also begins with a numeric value which results in an invalid constraint name.






[DC-975] Treat sql server error 2601 as Doctrine_Core::ERR_ALREADY_EXISTS Created: 17/Feb/11  Updated: 17/Feb/11

Status: Open
Project: Doctrine 1
Component/s: Connection
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Ben Davies Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Sql server


Attachments: Text File Doctrine_Connection_Mssql_Exception.patch    

 Description   

Patch attached to treat sql server error 2601 (Integrity constraint violation) as Doctrine_Core::ERR_ALREADY_EXISTS






[DC-970] Diff Tool doesn't generate the down() method if a field attribute is changed in YAML Created: 11/Nov/10  Updated: 07/Apr/11

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: taha bayrak Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Doctrine 1.2



 Description   

Diff Tool doesn't generate the down() method if a field attribute is changed in YAML. Below is an example

scheme.yaml
    email:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
scheme2.yaml
    email:
      type: string(160)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false

And below is the generated migration class (down() method is missing):

1239898949_Version39.php
class Version39 extends Doctrine_Migration_Base
{
    public function up()
    {
        $this->changeColumn('support_tickets', 'email', 'string', '160', array(
             'fixed' => '0',
             'unsigned' => '',
             'primary' => '',
             'notnull' => '',
             'autoincrement' => '',
             ));
    }

    public function down()
    {

    }
}


 Comments   
Comment by Ton Sharp [ 07/Apr/11 ]

How I can see "changeColumn" doesn't work in the "down" section





[DC-969] When I add a text field to a mysql table the migration code generated fails Created: 07/May/10  Updated: 23/Feb/11

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Mauro Chojrin Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Linux, Symfony 1.4, Doctrine 1.2



 Description   

I am using a database designed using schema.yml with a MySql Server.

When I add a field of type text the generated code for the migrations (using diff) is as follows:

$this->addColumn('<tableName>', '<fieldName>, 'text', '', array(
'notnull' => '',
));

Which produces a MySQL error like this:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1. Failing Query: "ALTER TABLE <tableName> ADD <fieldName> text()"

The solution I found was to manipulate manually the generated class to use an addColumn like this:

$this->addColumn('<tableName>', '<fieldName>, 'text', null, array(
'notnull' => '',
));

Which would generate an SQL statement like this:

ALTER TABLE <tableName> ADD <fieldName> text

Which works fine with MySQL, don't know about other RDBMS



 Comments   
Comment by Siegfried DuDragon [ 23/Feb/11 ]

My understanding is that you need to put a size to the text so it will choose between tinytext, text, mediumtext, bigtext, so instead of
$this->addColumn('<tableName>', '<fieldName>, 'text', '', array(
'notnull' => '',
));
use
$this->addColumn('<tableName>', '<fieldName>, 'text', '<somenumber>', array(
'notnull' => '',
));





[DC-965] Doctrine is passing timestamps to Doctrine_Validator_Unsigned Created: 11/Feb/11  Updated: 11/Feb/11

Status: Open
Project: Doctrine 1
Component/s: Validators
Affects Version/s: 1.2.2, 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Alex Dean Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Debian Lenny (5.0.8) with MySQL (5.0.51a-24+lenny5O). Doctrine hosted within CodeIgniter v1.7.2



 Description   

Since April last year I've been unable to use Doctrine Timestampable functionality because I get errors like this:

Uncaught exception 'Doctrine_Validator_Exception' with message 'Validation failed in class XXX 1 field had validation error: * 1 validator failed on created_at (unsigned) ' in ...

I've tried lots of different configurations for the timestampable functionality (see my Stack Overflow question for details) to no avail.

I've done some further investigation and the reason for the problem is that the timestamps are being sent to Doctrine_Validator_Unsigned for validation; they are then failing the following regexp test:

        if (preg_match('/[^0-9\-\.]/', $value)) {
            return false;
        }

I'm not smart enough to figure out why Doctrine is calling an unsigned validation test for these timestamps, so for now I've fixed the problem by hacking the following into Doctrine_Validator_Unsigned:

        if (preg_match('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $value)) {
            return true;
        }

Very ugly I know, but when I add this in the rest of the timestamping functionality works perfectly. Would love to get to the bottom of this bug - is particularly strange because nobody else seems to be experiencing it.



 Comments   
Comment by Alex Dean [ 11/Feb/11 ]

Added CodeIgniter details to environment





[DC-964] Alias name error when using interval(MySQL) Created: 03/Feb/11  Updated: 03/Feb/11

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Tibor Erdész Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None
Environment:

PHP Version 5.3.3-1ubuntu9.3; Apache/2.2.16 (Ubuntu); MySQL: 5.1.41; Symfony 1.4; Doctrine 1.2.3 (Revision: 7490)



 Description   

I'm using Doctrine with Symfony and i have some troubles when i'm using the mysql command: interval. Here's a detailed explanation:
Part of the schema:

User:
  columns:
    name: { type: string(255), notnull: true }
    nick: { type: string(255), notnull: true, unique: true }
    email: { type: string(255), notnull: true, unique: true }
    password: { type: string(40), notnull: true }

VirtualConferenceRoom:
  columns:
    adminId: { type: integer, notnull: true }
    name: { type: string(255), notnull: true }
    startDate: { type: timestamp, notnull: true }
    duration: { type: integer, notnull: true }
  relations:
    Admin:
      class: User
      foreign: id
      local: adminId

VirtualConferenceRoomUser:
  columns:
    virtualConferenceRoomId: { type: integer, notnull: true }
    userId: { type: integer, notnull: true }
  relations:
    VirtualConferenceRoom:
      class: VirtualConferenceRoom
      foreign: id
      local: virtualConferenceRoomId
    User:
      class: User
      foreign: id
      local: userId

I've generated my model with symfony's built in command(symfony doctrine:build --model --sql)
When I try to get the conference rooms which are in progress at the moment I try it like this:

// In the project/lib/model/doctrine/VirtualConferenceRoomTable.class.php which is extends from Doctrine_Table
public function getRoomsInProgressByUserId($userId)
{
    return Doctrine_Query::create()
                ->select('vcr.*')
                ->from('VirtualConferenceRoom vcr')
                ->innerJoin('vcr.VirtualConferenceRoomUser vcru')
                ->where('(vcr.StartDate < now()) and (vcr.StartDate + interval vcr.Duration minute > now()) and vcru.UserId = ?', array($userId))
                ->execute();
}

When I try to run my app I get an error message: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vcr.Duration' in 'where clause'"
The generated sql command is:

" SELECT v.id AS v__id, v.userid AS v__userid, v.name AS v__name, v.startdate AS v__startdate, v.duration AS v__duration FROM virtual_conference_room v INNER JOIN virtual_conference_room_user v2 ON v.id = v2.virtualconferenceroomid WHERE (v.startdate < NOW() AND v.startdate + interval vcr.Duration minute > NOW() AND v2.userid = ?) - (2)"

The problem is the vcr.Duration section. If I change my function from:

->where('(vcr.StartDate < now()) and (vcr.StartDate + interval vcr.Duration minute > now()) and vcru.UserId = ?', array($userId))

to:

->where('(vcr.StartDate < now()) and (vcr.StartDate + interval v.Duration minute > now()) and vcru.UserId = ?', array($userId))

it works perfectly.

I hope my report is useful and clear and i can help you to improve this great ORM
Best wishes: Tibor Erdész <erdeszt@gmail.com>



 Comments   
Comment by Tibor Erdész [ 03/Feb/11 ]

Just figured out that I can use


notations and I fixed my report.





[DC-959] DSN style problems in documentation 1.2 Created: 25/Jan/11  Updated: 25/Jan/11

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Documentation Priority: Minor
Reporter: Luis Felipe Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

MAMP



 Description   

This page:

http://www.doctrine-project.org/projects/orm/1.2/docs/manual/introduction-to-connections/en

states the DSN can either be provided as an associative array or as a string, but it's not true, specially if you're doing lazy connection, because this type of connection only accepts doctrine dsn style and it doesn't seem to know how to handle unix socket type connections (is it correct?).

I would suggest the manual clarify that lazy connection will only accept string type dsn and also will not accept socket connections.

Related links:
http://groups.google.com/group/doctrine-user/browse_thread/thread/1eecb07a2f6df447/3e74857c3a076939?lnk=gst&q=dsn#3e74857c3a076939
http://www.doctrine-project.org/jira/browse/DC-647






[DC-950] Doctrine_Record magic _set() doesn't validate field type for timestamp/datetime/etc.. Created: 23/Dec/10  Updated: 24/Jan/11

Status: Open
Project: Doctrine 1
Component/s: Record
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Gennady Feldman Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

So I ran into this recently. the magic _set() in Doctrine_Record doesn't check/validate the type of the field. The use case is when you you do something like:
setCreatedAt(time()); This will not work correctly with date/time or timestamp types in Doctrine, even though Propel handles this fine. Also MYSQL will not throw an error with default sql_mode and will put garbage data into the database.

The only way to generate the right date/time value is to always format that string with the "right" format. This should be easier and can be easier if it supported either a timestamp (time() or a DateTime() object (just like Symfony plugin does for setDateTimeObject() function). This is just a few lines of code, let me know if I should attach a patch.

I would love to see the Doctrine_Record implement this functionality. There's a ton of results on frustrated users trying to figure out how to set the date/time values properly using Doctrine.



 Comments   
Comment by Gennady Feldman [ 24/Jan/11 ]

Symfony actually added a work around by writing another function "setDateTimeObject()" to set these fields in a more friendly way. Ideally I would love to see support for time() and date_create() natively in Doctrine.





[DC-948] 3 underscores in my yaml file lead to error Created: 09/Dec/10  Updated: 09/Dec/10

Status: Open
Project: Doctrine 1
Component/s: Schema Files
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Lawrence Krubner Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Linux 2.6.31-15-generic #50-Ubuntu SMP Tue Nov 10 14:54:29 UTC 2009

Symfony 1.4



 Description   

I had this yaml:

OldAppellations:

connection: doctrine

tableName: old_appellations

columns:

appellations___sql:

{ type: text }

appellationsapcode_sql:

{ type: text }

appellationsappellation_sql:

{ type: text }

appellationscolor_sql:

{ type: text }

appellationscountry_sql:

{ type: text }

appellationsregion_sql:

{ type: text }

appellationsregion_for_link_sql:

{ type: text }

appellationssubt_sql:

{ type: text }

appellationstaster_appel_sql:

{ type: text }

appellationstotal_r_sql:

{ type: text }

appellationstype_sql:

{ type: text }

export_record_id_sql:

{ type: text }

I got this error:

Notice: Undefined index: o__appellations in /home/lkrubner/dev/tastingnotes/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Hydrator/Graph.php on line 302
Notice: Undefined index: in /home/lkrubner/dev/tastingnotes/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Hydrator/Graph.php on line 303
Fatal error: Call to a member function getFieldName() on a non-object in /home/lkrubner/dev/tastingnotes/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Hydrator/Graph.php on line 304

Then I changed the 3 underscores to 1:

appellations_sql:

{ type: text }

I rebuilt the model and the error was gone.

More details and screenshots are here:

http://www.symfonyexperts.com/question/show/id/178






[DC-947] getRandom() method for Doctrine_Table Created: 08/Dec/10  Updated: 08/Dec/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: ddead profile Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Consider adding this method into Doctrine_Table

public static function getRandom()
{
return
self::getInstance()->createQuery()
->select('*, RANDOM() as rand')
->limit(1)
->orderBy('rand')
->fetchOne();
}

It is portable and very useful.






[DC-945] Doctrine_Query::create()->where('table.field =') unexpectedly returns a result Created: 06/Dec/10  Updated: 07/Dec/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: John Huijbers Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

PHP 5.3.0



 Description   

While firing the following query with Doctrine, I did not expect Doctrine to return me a record, however, even though there is a syntax error (in my opinion) it gave me the first record of the table.

$q = \Doctrine_Query::create()
->from('User u')
->where('u.Id =', $userId);

$r = $q->fetchOne();

Note that the question mark in the where method is ommitted. This will return a User model with an Id of 1.

I would expect this to generate an invalid SQL statement (or even fail to pass the DQL validation).

Giving the first record doesn't seem to be appropriate in my opinion.






[DC-943] Memory leaks in find* magic methods owing to failure to free queries Created: 03/Dec/10  Updated: 03/Dec/10

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Garpini Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File doctrine_query_patch.patch    

 Description   

The following methods on Doctrine_Table create Doctrine_Query objects that are never free()d:
findAll()
findBySql()
findByDql()
findBy()
findOneBy()



 Comments   
Comment by Garpini [ 03/Dec/10 ]

The attachment contains a patch that addresses the memory leak by free()ing the query objects generated before returning the results of the query.





[DC-923] Documentation 1.2 #working-with-models error Created: 10/Nov/10  Updated: 10/Nov/10

Status: Open
Project: Doctrine 1
Component/s: Documentation
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Martin Babic Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Ubuntu 10.4, LAMP



 Description   

In documentation

http://www.doctrine-project.org/projects/orm/1.2/docs/manual/working-with-models/en#many-to-many-relations:creating-a-new-link

There's an error in example code:

// test.php

// ...
$user = new User();
$user->username = 'Some User';
$user->Groups[0]->username = 'Some Group';
$user->Groups[1]->username = 'Some Other Group';
$user->save();

The error is on lines:

$user->Groups[0]->username = 
$user->Groups[1]->username = 

they shoud be:

$user->Groups[0]->name = 
$user->Groups[1]->name = 

as there's no username column in schema.yml definition of Group object.






[DC-905] Fields with foreign key shouldn't require definition Created: 29/Oct/10  Updated: 31/Oct/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Alaattin Kahramanlar Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File schema.yml    

 Description   

Sample schema attached.

Now, keeping attached schema in mind.

We have core tables that lots of other tables refer via foreign keys to them, like user, company, etc.

We need to explicitly define foreign keys (like user_id) "definitely same as" User.id on each table. By design, this seems unnecessary, and has load on refactoring processes, ie. type change on User.id.

Doctrine is already parsing foreign relations from schema, It can use parent table field definition (User.id) in refering table fields (user_id) and on the schema user_id can be defined as:

user_id: ~






[DC-901] Several test cases using CRLF endings Created: 24/Oct/10  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Damian Bushong Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Windows 7 x86_64, PHP 5.3



 Description   

Hi there. I'm finding several test cases that are using CRLF line endings, instead of the standard UNIX LF line endings as it seems the rest of the codebase uses.

The test case files are as follows:

tests/Ticket/2158TestCase.php
tests/Ticket/2251TestCase.php
tests/Ticket/2334TestCase.php
This is causing my git pull on the doctrine 1 github repository to fail due to so called "unmerged" files, and has rendered my git submodule for doctrine just about useless.

I'd appreciate it if someone would run a fromdos on these files and commit them.






[DC-900] HYDRATE_SINGLE_SCALAR option always returns false Created: 23/Oct/10  Updated: 23/Oct/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Junaid Ebrahim Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Ubuntu Linux Karmic, Apache 2, Symfony 1.4.3



 Description   

I notice that the fetchone with HYDRATE_SINGLE_SCALAR option always returns false as the return to the $collection object is a string type, this is returned by the hydrateResultSet with driver mode set to 6 (I assume this is for scalar values)

My code is a two table query with which returns a string of "10" (g.id in query below) and returns false because it is not a doctrine collection, I did check the doctrine examples and it seems to be the way its used. Not sure if its the doctrine version issue with symfony, my code or an actual bug

$q = Doctrine_Core::getTable('ClipGroup')
->createQuery('g')
->select('g.id')
->leftJoin('g.sfGuardUser u')
->Where('g.completed_at IS NULL')
->andWhere('g.expires_at > ?', date('Y-m-d H:i:s', time()))
->andWhere('u.id = ?', $userId);
return $q->fetchOne(array(), Doctrine_Core::HYDRATE_SINGLE_SCALAR);

I am using doctrine included in symfony 1.4.3, here is the comment on the Query.php file * @version $Revision: 6792 $,
public function fetchOne($params = array(), $hydrationMode = null)
{
$collection = $this->execute($params, $hydrationMode);

if (count($collection) === 0)

{ return false; }

if ($collection instanceof Doctrine_Collection)

{ return $collection->getFirst(); }

else if (is_array($collection))

{ return array_shift($collection); }

return false;
}

Hydrator.php - returns a string * @version $Revision: 3192 $

public function hydrateResultSet($stmt, $tableAliases)

{ $driver = $this->getHydratorDriver($this->_hydrationMode, $tableAliases); $result = $driver->hydrateResultSet($stmt); return $result; }




[DC-896] MySQL Limit implementation leads to incorrect results if the original where clause contains an "OR" operator Created: 20/Oct/10  Updated: 20/Oct/10

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: James Pakele Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Doctrine + MySQL



 Description   

If adding the Where In clause for the subquery "limit" implementation, the original where clause needs to be isolated with parenthesis. In my sample where clause the first character is in fact an opening parenthesis and the last character is in fact a closing parenthesis, however, there are a bunch of conditions and parenthesis between them as well that may contain "OR" operators. When this is combined with the Where In clause generated by the Pager tool's "limit" implementation for MySQL it leads to incorrect results.

Here is my "Before" Where condition:

WHERE c.id IN ('25', '31', '6', '28', '30', '16', '32', '26', '22', '14') AND (a2.data_item_id = ? AND a2.value = ?) AND (a3.data_item_id = ? AND a3.value = ?) OR (a4.data_item_id = ? AND a4.value = ?) AND (a5.data_item_id = ? AND a5.value = ?)

And the "After" Where condition
WHERE c.id IN ('25', '31', '6', '28', '30', '16', '32', '26', '22', '14') AND ((a2.data_item_id = ? AND a2.value = ?) AND (a3.data_item_id = ? AND a3.value = ?) OR (a4.data_item_id = ? AND a4.value = ?) AND (a5.data_item_id = ? AND a5.value = ?))

Fix:

Line 1305 in Query.php:
$where = ($where == '' || (substr($where, 0, 1) === '(' && substr($where, -1) === ')'))
? $where : '(' . $where . ')';

I ended up just adding the following just after the above statement in the code:
if (!empty($limitSubquerySql) && !empty($where))

{ $where = '(' . $where . ')'; }




[DC-894] Typo in Doctrine_Manager::getConnectionDrivers() Created: 19/Oct/10  Updated: 19/Oct/10

Status: Open
Project: Doctrine 1
Component/s: Connection
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Akitaka Kohno Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None
Environment:

symfony 1.4 / PHP 5.2.13 / CentOS5.4



 Description   

Hello.

getConnectionDrivers is returning member variable '_connectionsDrivers' at line 809.
It's probably typo, I think this variable name should be '_connectionDrivers'.






[DC-891] [PATCH] Relation array as the result of Doctrine_Table::bind() Created: 18/Oct/10  Updated: 18/Oct/10

Status: Open
Project: Doctrine 1
Component/s: Relations
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Eugene Leonovich Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File bind.patch    

 Description   

It would be handy to return a relation array as the result of Doctrine_Table::bind(), because the relation parser's bind() already returns this value.






[DC-890] public function detach break the nested set tree [patch attached] Created: 14/Oct/10  Updated: 14/Oct/10

Status: Open
Project: Doctrine 1
Component/s: Nested Set
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Alexandre PAIXAO Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

not environment dependant


Attachments: Text File NestedSet.patch    

 Description   

If I detach a node from the tree using $node->detach(); it set the left and right value to zero without shifting, creating a possible tree corruption.
It still work somehow because inserting a new node will shift the value but keep the hole in the tree.

I've looked to the original commit in Trac (http://trac.doctrine-project.org/changeset/4089) and I don't think the original idea of the commit was to leave a hole.
I've added 3 lines of code (that I copied from the delete function which works properly), the coresponding patch is joigned to the bug ticket



 Comments   
Comment by Alexandre PAIXAO [ 14/Oct/10 ]

ex:

root 1 4
- node A 2 3

after detach :

root 1 4
- node A 0 0

then a new one :

root 1 6
- node B 4 5
- node A 0 0





[DC-883] Help for Test CLI does not list available test groups Created: 10/Oct/10  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Andrew Coulton Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

The CLI Test Runner is supposed to print a list of available test groups when used with the --help parameter, but this fails as the Doctrine_Test::run() method erroneously expects php sort() to return an array rather than a boolean.

Fixed by http://github.com/acoulton/doctrine1/tree/DC-883






[DC-879] MSSQL - missing function date_part() in Expression/Mssql.php [+patch] Created: 05/Oct/10  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Connection
Affects Version/s: 1.2.2, 1.2.3
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Enrico Stahn Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Missing function date_part() in Expression/Mssql.php. I don't know why the set of expressions is different for each driver. This makes it hard to develop database independent.






[DC-872] 1.2 Documentation on Aggregate Functions Error Created: 21/Sep/10  Updated: 21/Sep/10

Status: Open
Project: Doctrine 1
Component/s: Documentation
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Isaac Foster Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

In the documentation for using aggregate values with Doctrine Query (link below), there is a code snippet that shows how to access the value of the aggregate field, which does not work.

The code snippet is:

//firstsnippet after header
$q = Doctrine_Query::create()
->select('u.id, COUNT(t.id) AS num_threads')
->from('User u, u.Threads t')
->where('u.id = ?', 1)
->groupBy('u.id');

//second snippet after header
$users = $q->execute();

//fourth snippet after header
echo $users->num_threads . ' threads found';

The code from the last snippet for accessing the count value, $users->num_threads, doesn't seem to work. What does work for me is:

//access count value
echo $users[0]->num_threads

//My exact code is:
$query = Doctrine_Query::create()
->select('COUNT as batchCount')
->from('Batch');
$result = $query->execute();

echo $result->batchCount; //10
echo $result[0]->batchCount; //3 (3 is correct, from direct MySQL command line query)

It's certainly possible I'm doing something wrong, or that there is a Doctrine_Core attribute I need to set. If there is a Doctrine_Core attribute to set to automatically access aggregate values from the Collection, it would be worth noting at the top of the section.

Thanks, and thanks for Doctrine (so awesome).

Link:
http://www.doctrine-project.org/projects/orm/1.2/docs/manual/dql-doctrine-query-language/hu#select-queries:aggregate-values






[DC-868] [Documentation] Column aggregation Created: 16/Sep/10  Updated: 16/Sep/10

Status: Open
Project: Doctrine 1
Component/s: Documentation
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Michael Simpson Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

The example in the documentation at http://www.doctrine-project.org/documentation/manual/1_2/en/inheritance:column-aggregation suggests that the discriminator (in this case 'type') column does not need to be defined in the parent class 'Entity'.

This did not work for me, I had to declare the discriminator column as shown in the 'Taking advantage of column aggregation inheritance' chapter at http://www.doctrine-project.org/projects/orm/1.2/docs/cookbook/taking-advantage-of-column-aggregation-inheritance/en.






[DC-864] Generating YAML schema from model should pick up also charset, collate and other options Created: 10/Sep/10  Updated: 10/Jan/11

Status: Open
Project: Doctrine 1
Component/s: Import/Export, Schema Files
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Peter Helcmanovsky Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File Export_Schema.patch    

 Description   

I did change Doctrine/Export/Schema.php to pick up some options from model, then they get exported into YAML schema by current code.

Adding the patch. (sorry, can't run the tests, so I'm not sure whether it does break something, really shouldn't)

In my project it works just as expected (did need it for the way I do migrations).

TODO for Doctrine devs:

  • run tests with my patch and let me know if there's a problem
  • consider other option names, which are worth of export, so far I did need "charset" and "collate", and I added "queryParts" as well.

I hope my additions make sense and will help you to improve Doctrine project. (and that you will include it, so I don't have custom modified Doctrine )



 Comments   
Comment by Peter Helcmanovsky [ 10/Jan/11 ]

By hunting down an eluding bug I figured out (i.e. by hard way) that the indexes are dropped as well during YAML generation.

I will do another pull request on github including another 3 lines to fix that...

I see this issue is ignored anyway by core devs.





[DC-861] Make sure doctrine uses the right connection when creating a query from a table object Created: 08/Sep/10  Updated: 08/Sep/10

Status: Open
Project: Doctrine 1
Component/s: Connection
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Emmanuel Delescolle Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

All



 Description   

Line# 1036
When using Table::createQuery, null is specified as the connection when calling Doctrine_Query::create() which results in using the default connection while the "correct" connection can be know ($this->getConnection())

here is the fix:

— a/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Table.php
+++ b/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Table.php
@@ -1033,7 +1033,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable

$class = $this->getAttribute(Doctrine_Core::ATTR_QUERY_CLASS);

  • return Doctrine_Query::create(null, $class)
    + return Doctrine_Query::create($this->getConnection(), $class)
    >from($this>getComponentName() . $alias);
    }





[DC-855] Notify via Exception when a feature is specifically not supported for compatability Created: 02/Sep/10  Updated: 02/Sep/10

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Jacob Mather Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None
Environment:

N/A



 Description   

For situations like with http://www.doctrine-project.org/jira/browse/DC-646 would it be possible to look at throwing an exception with an explanation of why it does not work, rather than simply let the query fail because of intentionally incorrect query generation?

Granted, the fix is relatively simple (just select and delete the results, instead), but if I don't know why the wrong query is being made, I don't know to change my approach rather than simply assume I'm doing something wrong.






[DC-852] CLONE -Fix returned type value : SQL integers to PHP integers when getting a value from the database. Created: 01/Sep/10  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Attributes, Data Fixtures, Native SQL, Query, Record
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Enrico Stahn Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Hi Jon,

I have a request for you to improve Doctrine. When declaring a column as an integer, it seems that Doctrine returns a string when getting the value of that column. For example, if I have a "status" column, which can take 0, 1 or 2 as its value, Doctrine will return these values as string, which is not really logical and returning the good PHP type is the goal of an ORM. I'm fond of the triple equal symbol to test a value and I did not understand why this did not work at start :

// in my myModel class
class myModel extends Doctrine_Record
{
const STATUS_VALIDATED = 1;

public function isValidated()

{ return self::STATUS_VALIDATED === $this->getStatus(); }

}

That's why getStatus() gives me a string instead of an integer, whereas the column is declared as an integer in my schema. I'm forced to cast myself the returned value of getStatus() in my model.



 Comments   
Comment by Enrico Stahn [ 01/Sep/10 ]

Proposal for a solution: http://github.com/estahn/doctrine1/compare/master...DC-852

Comment by Jonathan H. Wage [ 01/Sep/10 ]

So if you enable this attribute you live with the fact that casting a string to an integer that is longer than php max integer will give weird results?

Comment by Enrico Stahn [ 02/Sep/10 ]

i'm far from happy with this solution. if an integer that is greater than php max int gets casted it will be casted into a value of type double. if you enable that attribute only values that could successfully casted into an integer will be casted otherwise an exception will be thrown.





[DC-846] Provide documentation for connection options Created: 29/Aug/10  Updated: 29/Aug/10

Status: Open
Project: Doctrine 1
Component/s: Documentation
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Ritty Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

All



 Description   

Provide additional information on connection options.

$conn = Doctrine_Manager::connection('mysql://username:password@localhost/test', 'connection 1');

just skims the surface. At least link to PDO docs. Also, what is the second parameter? I can look in API docs, but it would be helpful to have in the reference guide.

Are there any other ways to make a connection, such as through an array of parameters?






[DC-843] MSSQL - Equal-to Operator doesn't work with columns of type text in where condition [+patch] Created: 26/Aug/10  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Connection
Affects Version/s: 1.2.2, 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Enrico Stahn Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Example:

Doctrine::getTable('Ticket_DCXXX2_Model')->findByUsernameAndFoo('foo', 'bar');

foo is of type "text". Doctrine generates "where .... foo = 'bar'", but this will throw an mssql exception because you cant use the equal to operator in mssql for text and varchar types. Doctrine should consider this database related behavoir, shouldn't it?



 Comments   
Comment by Enrico Stahn [ 26/Aug/10 ]

TestCase added http://github.com/estahn/doctrine1/compare/master...DC-843

Comment by Enrico Stahn [ 27/Aug/10 ]

Patch added to github (see above)

commit msg: DC-843 fix (TestCase need fix for DC-841 to run successfully)

Comment by Enrico Stahn [ 02/Sep/10 ]

I made a mistake with github, the updated branch can be found at
http://github.com/estahn/doctrine1/tree/DC-843-2





[DC-811] calculateQueryCacheHash causes a fatal error when used in combination with output buffering Created: 06/Aug/10  Updated: 24/Aug/10

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Carl Alexander Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File query_abstract.patch    

 Description   

When using output buffering in combination with a doctrine caching driver. var_export causes a fatal error as described here:

http://marc.info/?l=phpdoc&m=114122422804066
http://php.net/manual/en/function.var-export.php

Here is the proposed patch.



 Comments   
Comment by Jonathan H. Wage [ 24/Aug/10 ]

This seems to break the test suite in several places so it cannot be applied. If you can provide a patch that passes the test suite we can discuss applying the patch.





[DC-808] Doctrine_Connection_Statement->execute() Do not pass failing query to Doctrine_Connection->rethrowException() Created: 05/Aug/10  Updated: 05/Aug/10

Status: Open
Project: Doctrine 1
Component/s: Connection
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Alexandre Ravey Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File Doctrine_Connection_Statement.patch    

 Description   

When Doctrine_Connection_Statement->execute() fail on a query, Exception is rethrown by Doctrine_Connection.

But the failing query is not passed to rethrowException() as third parameter, which make debug very difficult.

See attached patch file to correct this.






[DC-805] Test fails randomly (race condition?) Created: 31/Jul/10  Updated: 31/Jul/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Federico Gimenez Nieto Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Debian Lenny 5.0



 Description   

Hi,

During one of my test builds, one of the test cases failed, probably because of a race condition:

Doctrine_Ticket_1441_TestCase : method testTest failed on line 60
Value1: array (
0 => 'test',
1 => '2010-07-10 02:21:34',
2 => 'jwage',
)
!=
Value2: array (
0 => 'test',
1 => '2010-07-10 02:21:35',
2 => 'jwage',
)

Thanks,
Federico






[DC-803] Syntax error in MySQL migration to drop constraint (patch supplied) Created: 29/Jul/10  Updated: 29/Jul/10

Status: Open
Project: Doctrine 1
Component/s: Migrations
Affects Version/s: 1.2.2
Fix Version/s: 1.2.2

Type: Bug Priority: Minor
Reporter: Gavin Davies Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Debian, PHP 5.3.2, MySQL


Attachments: Text File SyntaxFixForMySQLDropConstraintInExport.patch    

 Description   

I have a migration that adds constraints correctly. When migrating down, however, I get a syntax error

ErrorMessage
  Error #1 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT unique_username_idx' at line 1. Failing Query: "ALTER TABLE conUser DROP CONSTRAINT unique_username_idx"

Here is the down migration:

DownMigration
    public function down() {
        $this->dropConstraint('conUser', 'unique_username_idx');
    }

The SQL generated is "ALTER TABLE conUser DROP CONSTRAINT unique_username_idx". This post (http://forums.mysql.com/read.php?98,70887,70974#msg-70974) suggests that in MySQL the syntax should be "ALTER TABLE conUser DROP INDEX unique_username_idx" as constraints are basically indexes in MySQL (unlike MSSQL and Oracle). Doctrine's lib/Doctrine/Export/MySql.php appears to have a syntax error in the dropConstraint method. I attach a patch for this, but the only change is replacing "$name = 'CONSTRAINT '" with "$name = 'INDEX '" in dropConstraint. The migration then runs as I would expect.

Sorry if this has been fixed elsewhere, I did a search but couldn't find a similar ticket.



 Comments   
Comment by Gavin Davies [ 29/Jul/10 ]

fixing syntax





[DC-796] Correct way to count all files from a table ? Created: 22/Jul/10  Updated: 22/Jul/10

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Pablo Mateos Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Debian Lenny / MySQL 5.1



 Description   

If I execute this to get the amount of records in a table I get the correct result, but it takes too long and consumes a lot of resources as if I get all the fields from table:

Doctrine::getTable('Recurso')>findAll()>count();

Am I doing it wrong?, The only other option I've found is to use DSQL and execute a query like "SELECT count from recurso".

Thank you in advance.

Pablo.






[DC-781] Column order in generated SQL is based on relationships, instead of SELECT clause Created: 10/Jul/10  Updated: 10/Jul/10

Status: Open
Project: Doctrine 1
Component/s: Native SQL
Affects Version/s: 1.2.0
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Prasad Gupte Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Windows / PHP 5.2.4 / MySQL 5.1.41 / Symfony 1.4.0



 Description   

When executing below query as follows:
$q = Doctrine_Query::create()
->select('bc.id, bbl.printed_name, bbl.rate, bc.name, bc.is_rate_variable')
->from('BillBatchLine bbl, bbl.Bill_Charge bc')
->where('bbl.bill_batch_id = ?', $bill_batch_id);
return $q->execute(array(), Doctrine::HYDRATE_NONE);

SQL generated is:
SELECT b.printed_name AS b_printed_name, b.rate AS brate, b2.id AS b2id, b2.name AS b2name, b2.is_rate_variable AS b2_is_rate_variable FROM Bill_Batch_Lines b LEFT JOIN bill_charges b2 ON b.bill_charge_id = b2.id AND (b2.deleted_at IS NULL) WHERE (b.bill_batch_id = '2' AND b.society_id = '1' AND b2.society_id = '1' AND (b.deleted_at IS NULL))

Basically, columns are ordered based on relationships and not as defined in the SELECT clause






[DC-780] Foreign key creation fails with MySQL 5.0.44 Created: 09/Jul/10  Updated: 09/Jul/10

Status: Open
Project: Doctrine 1
Component/s: Import/Export
Affects Version/s: 1.2.0
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Claudia Kosny Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

gentoo, MySQL 5.0.44-log, Doctrine 1.2, symfony 1.4.4


Attachments: Text File Doctrine-Export.patch    

 Description   

Hi there,

When executing symfony doctrine:build --all --and-load on a machine using Mysql 5.0.44 I get the following error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dimension(id)' at line 1. Failing Query: "ALTER TABLE kpi_dimension ADD CONSTRAINT kpi_dimension_dimension_id_dimension_id FOREIGN KEY (dimension_id) REFERENCES dimension(id)".

The problem can be fixed by adding a space between the table name and the column name that is referenced. So instead of
REFERENCES dimension(id)
it should be
REFERENCES dimension (id)

Since it works fine on MySQL 5.1.37, I normally would file this under Mysql bug. But as the syntax for a foreign key constraint in MySQL mentions this space it should be ok to simply add the space to the script creating the sql for the foreign key. I have not tried any other DBMS though.

The patch for the file Export.php is attached.

Best regards

Claudia






[DC-776] $record->link('Alias', $id) throws an exception because of getIdentifier returns array, not string Created: 05/Jul/10  Updated: 05/Jul/10

Status: Open
Project: Doctrine 1
Component/s: Record, Relations, Schema Files
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Viktoras Bezaras Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Symfony 1.4.6-DEV


Sub-Tasks:
Key
Summary
Type
Status
Assignee
DC-775 $record->link('Alias', $id) throws an... Sub-task Resolved Jonathan H. Wage  

 Description   

I want to bookmark ads on my site. So i have Ads table, users table (sfDoctrineGuard) and a refclass Bookmarks. I've created an ajax link to an action, where i retrieved $ad object, $user_id and
$ad->link('Bookmarks', $user_id, true);
So I expected a record in a database to be created.

Bookmarks:
...
columns:
user_id:

{ type: integer(4), primary: true }

ad_id:

{ type: integer(4), primary: true }

relations:
sfGuardUser:

{ onDelete: CASCADE, local: user_id, foreign: id }

Ads:

{ onDelete: CASCADE, local: ad_id, foreign: ad_id }

As my Bookmarks table has 2 primary keys in the link method

if (count($ids) > 0)

{ $q->whereIn($rel->getTable()->getIdentifier(), array_values($this->identifier())); }

$rel->getTable()->getIdentifier() returned me an array('user_id', 'ad_id') instead of a string. So the query which was generated looked like
UPDATE bookmarks SET ad_id = ? WHERE (Array IN )
And Array is not the name of a column.

My schema:
http://pastie.org/private/2lr9gy1h3mtdwdsiwrwylq

I've solved an issue by creating a new Bookmark instance and saving it, but i presume that issue might distract someone.






[DC-772] Different test results in different debian boxes Created: 30/Jun/10  Updated: 01/Aug/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Federico Gimenez Nieto Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Debian Lenny 5.0



 Description   

Hi,

I have two different debian boxes, in one of them all test pass but in the other (a very basic system with just the essential packages installed) i get:

Doctrine_Search_TestCase........................................................failed

Unexpected Doctrine_Record_UnknownPropertyException thrown in [Doctrine_Search_TestCase] with message [Unknown record property / related component "SearchTestIndex" on "SearchTest"] in /home/fgimenez/doctrine/Doctrine-1.2.2/lib/Doctrine/Record/Filter/Standard.php on line 55

#0 /home/fgimenez/doctrine/Doctrine-1.2.2/lib/Doctrine/Record.php(1382): Doctrine_Record_Filter_Standard->filterGet(Object(SearchTest), 'SearchTestIndex')
#1 /home/fgimenez/doctrine/Doctrine-1.2.2/lib/Doctrine/Record.php(1337): Doctrine_Record->_get('SearchTestIndex', true)
#2 /home/fgimenez/doctrine/Doctrine-1.2.2/lib/Doctrine/Access.php(72): Doctrine_Record->get('SearchTestIndex')
#3 /home/fgimenez/doctrine/Doctrine-1.2.2/tests/SearchTestCase.php(48): Doctrine_Access->__get('SearchTestIndex')
#4 /home/fgimenez/doctrine/Doctrine-1.2.2/tests/DoctrineTest/UnitTestCase.php(158): Doctrine_Search_TestCase->testBuildingOfSearchRecordDefinition()
#5 /home/fgimenez/doctrine/Doctrine-1.2.2/tests/DoctrineTest/GroupTest.php(75): UnitTestCase->run()
#6 /home/fgimenez/doctrine/Doctrine-1.2.2/tests/DoctrineTest.php(183): GroupTest->run(Object(DoctrineTest_Reporter_Cli), '')
#7 /home/fgimenez/doctrine/Doctrine-1.2.2/tests/run.php(320): DoctrineTest->run()
#8

{main}

I've been trying to determine which is the package that is installed in one box but not in the other and that make the Doctrine_Search_TestCase test pass, no luck so far (same php and sqlite configuration in both environments).

Any hint on this is highly appreciated, cheers

Federico



 Comments   
Comment by Federico Gimenez Nieto [ 01/Aug/10 ]

Hi,

In other words, what are the minimum requirements to run doctrine successfully, including the tests? After uploading the debian package of doctrine to the archive there have been some errors regarding the tests on a clean environment with just the packages php5-cli and php5-sqlite (and its dependencies) installed, see [1]. This used to work on other boxes.

[1] http://people.debian.org/~lucas/logs/2010/07/31/doctrine_1.2.2-1_lsid64.buildlog

Thanks,
Federico





[DC-771] fetchOne return boolean Created: 29/Jun/10  Updated: 29/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Thomas Tourlourat - Armetiz Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Doctrine_Query::fetchOne could return false..

It a "get" function, so the function should return "null" or an "object", but a boolean isn't a good value..






[DC-767] Doctrine_Migration_Builder::generateMigrationClass() improperly loads migration class Created: 25/Jun/10  Updated: 25/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Migrations
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Brandon Franzke Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

N/A



 Description   

in function: Doctrine_Migration_Builder::generateMigrationClass() the generated migration class is included (require_once) after creation. A loadMigrationClass call is made following [line 513] as:

$this->migration->loadMigrationClass($className);

I propose this should change to include the optional "$path" argument to Doctrine_Migration::loadMigrationClass() as:

$this->migration->loadMigrationClass($className, $path);

Since the $path variable is available for the loadMigrationClass it should be included. More importantly NOT including $path breaks the certains behaviors. This occurs as a side effect in symfony for instance when creating a new task that chains:

doctrine:generate-migrations-diff
doctrine:migrate

The reason for the problem is because the generate-migrations-diff properly creates the version class and file and then has a require_once that pulls the class into scope. doctrine:migrate then runs Doctrine_Migration::loadMigrationClassesFromDirectory() to find all the migration classes. The task does NOT see the newly created migration class because it is not associated with the directory dirname($path) pointed out above. The function thoroughly scans the migration class directory with require_once and array_diff's to find new classes. But the new migrations class is already within declaration scope so is missed. Thus the doctrine:migrate task always migrates to the version BEFORE the executed doctrine:generate-migration-diff.






[DC-763] Timestamp validation does not fail, when missing time in value Created: 24/Jun/10  Updated: 31/Aug/10

Status: Open
Project: Doctrine 1
Component/s: Validators
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Steffen Zeidler Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

php 5.2.6 + mysql 5.0


Attachments: File DC763TestCase.php     Text File Timestamp.patch    

 Description   

Doctrine_Validator_Timestamp does not validate correctly, when missing time information in value!

2009-01-20 -> validator returns true, should be false because of the missing time



 Comments   
Comment by Steffen Zeidler [ 31/Aug/10 ]

patch & test





[DC-752] Data type "decimal" can be unsigned in MySQL 5.0 Created: 18/Jun/10  Updated: 18/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Native SQL, Schema Files
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Ilya Sabelnikov Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

OS: FreeBSD 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 amd64
PHP: 5.2.13 (cli) (built: May 6 2010 01:51:58), Zend Engine v2.2.0, with Xdebug v2.0.5
Symfony: 1.4.6-DEV (/web/vendor/symfony/1.4-svn/lib)
MySQL: Ver 14.14 Distrib 5.1.46, for portbld-freebsd8.0 (amd64) using 5.2



 Description   

I have found in official docs of MySQL v5.0:

Decimals can be unsigned: DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]

Here above is my "schema.yml" file:

schema.yml
 
Project:
  columns:
    id:
      type: integer(4)
      unsigned: true
      primary: true
      autoincrement: true
    salary_range_from:
      type: decimal(12)
      scale: 2
      unsigned: true

After i run:

./symfony doctrine:build --all

my "schema.sql" is:

schema.sql
 
CREATE TABLE `project` (
  `id` INT AUTO_INCREMENT, 
  `salary_range_from` DECIMAL(12, 2), 
  INDEX `company_id_idx` (`company_id`), PRIMARY KEY(`id`)
) DEFAULT CHARACTER SET utf8 ENGINE = INNODB;





[DC-749] Doctrine_Record#getMutators() triggers PHP notice Created: 17/Jun/10  Updated: 17/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Record
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Guilliam X Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Doctrine SVN 1.2 r7676


Attachments: Text File DC-749.patch    

 Description   

When calling getMutators() on an instance of Doctrine_Record (eg. $user = new User();), if it hasn't any defined custom mutator yet, we get a

Notice: Undefined index: User in /[...]/Doctrine/Record.php on line 1312

whereas there's no error with getAccessors() (I suppose it was fixed for the second one but not copied to the first one).

Patch is really simple! please see attachment

Regards






[DC-746] Sluggable canUpdate overridden after subsequent updates Created: 17/Jun/10  Updated: 17/Apr/14

Status: Open
Project: Doctrine 1
Component/s: Behaviors
Affects Version/s: 1.2.0, 1.2.1, 1.2.2, 1.2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Adam Benson Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None
Environment:

WAMP stack - PHP 5.3



 Description   

When allowing the user to manually change a slug using 'canUpdate' the slug reverts back to it's default generated value upon subsequent saves. Pre-Update on the Sluggable Listener Template seems to incorrectly decide to regenerate the default value.

Example:

$this->actAs('Sluggable', array('unique'=>true, 'fields'=>array('title'), 'canUpdate'=>true));
$record->description = "An example Item";
$record->title = "Example Title";
$record->save();

echo $record->slug; //"example-title" (Correct)

$record->description = "An example Item";
$record->title = "Example Title";
$record->slug = "custom-slug";
$record->save();

echo $record->slug; //"custom-slug" (Correct - First Save)

$record->description = "An example Item";
$record->title = "Example Title";
$record->slug = "custom-slug";
$record->save();
echo $record->slug; //"example-title" (Incorrect - Subsequent Save. Has regenerated it's default slug and lost the user defined one - even though we have passed the users custom one to the object prior to saving it.).


 Comments   
Comment by Christian Seaman [ 05/Oct/10 ]

As far as I can see this is a problem with the logic in Sluggable::preUpdate() , I recently posted a comment about this here:
http://groups.google.com/group/doctrine-user/browse_thread/thread/d40c6ac733738d4a

In short, I think that the code should be changed from:

Sluggable.php
    public function preUpdate(Doctrine_Event $event)
    {
        if (false !== $this->_options['unique']) {
            $record = $event->getInvoker();
            $name = $record->getTable()->getFieldName($this->_options['name']);

            if ( ! $record->$name || (
                false !== $this->_options['canUpdate'] &&
                ! array_key_exists($name, $record->getModified())
            )) {
                $record->$name = $this->buildSlugFromFields($record);
            } else if ( ! empty($record->$name) &&
                false !== $this->_options['canUpdate'] &&
                array_key_exists($name, $record->getModified()
            )) {
                $record->$name = $this->buildSlugFromSlugField($record);
            }
        }
    }

To this (i.e. remove the canUpdate conditions from the first inner if):

Sluggable.php (modified)
    public function preUpdate(Doctrine_Event $event)
    {
        if (false !== $this->_options['unique']) {
            $record = $event->getInvoker();
            $name = $record->getTable()->getFieldName($this->_options['name']);

            if ( ! $record->$name) { // i.e. remove the other conditions - you should only build the slug from other fields if it's empty
                $record->$name = $this->buildSlugFromFields($record);
            // possibly add an "else if !canUpdate then make sure the old value is preserved" here
            } else if ( ! empty($record->$name) &&
                false !== $this->_options['canUpdate'] &&
                array_key_exists($name, $record->getModified()
            )) {
                $record->$name = $this->buildSlugFromSlugField($record);
            }
        }
    }

I have modified my local version of the Doctrine code to use this modification and it seems to (a) not have the problem you reported above and (b) generally work ok. However, I have not run the test suite against it.

C

Comment by Adam Benson [ 19/Nov/10 ]

Updated affected versions

Comment by Adam Benson [ 19/Nov/10 ]

Thanks for the update Christian, perhaps you could share your fix as a patch?

Comment by Jean-Sébastien GERARD [ 21/Jan/11 ]

Hi, I'm working on a multilingue web portal with Symfony 1.4 and Doctrine 1.2.3, and man, your fix saves my life
I use Sluggable slaved by i18n and without your fix Sluggable simply does not do the job, instead it messes up all slugs when updating, eventually you can't retrieve object anymore based on it. I would not set it as only minor bug ?
thanks, anyway.





[DC-738] Missing reference to make code usable Created: 15/Jun/10  Updated: 17/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Documentation
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Dennis Gearon Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Doctrine web site



 Description   

Web page documentation is missing some details on following page: // ...
http://www.doctrine-project.org/documentation/manual/1_0/pl/connections:get-connection-name
http://www.doctrine-project.org/documentation/manual/1_2/pl/connections:get-connection-name

I think they were just taken out of context from a page like:
http://www.doctrine-project.org/projects/orm/1.2/docs/manual/connections/en#get-connection-name
where a previous reference to manager .... oops, that page has no previous reference to '$manager' either!!!

Where does the $manager variable come into this? FWIW, I tried that code to get the connection name in a Symfony/Doctrine CLI Task, and it says, 'using object accessor on non object'. I'll keep working on what it's supposed to look like, but the last page above, and every page of documentation derived from it should be checked for the relevance and accuracy of the $manager variable.






[DC-737] generateModelsFromYaml with (generateTableClasses = true) doesn't generate tables classes if (generateBaseClasses = false) Created: 15/Jun/10  Updated: 15/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Import/Export
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Guilliam X Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Doctrine SVN 1.2 r.7676


Attachments: Text File DC-737.patch    

 Description   

I can't see the reason why Table classes are only generated if Base classes are... (the same occurs for Package classes, but regarding code comments a Package is required to extend a Base class... but a Table can't and won't...)

Here is some... patch? :s (it doesn't make unit tests to fail)

Best regards






[DC-734] With loading "conservative" or "PEAR", Doctrine_Core::loadModels returns different results for identical calls Created: 14/Jun/10  Updated: 15/Jun/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Guilliam X Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Mac OS X 10.5, MAMP 1.9, PHP 5.2.13
Doctrine SVN 1.2 r.7676


Attachments: Text File DC-734.patch    

 Description   

Hello,

Edit: sorry I changed issue subject, please have a look at the first comment



 Comments   
Comment by Guilliam X [ 15/Jun/10 ]

Actually I have some interrogations about the way how loadModels() works...

  • If using conservative or PEAR loading, in the directory listing loop:
    • if a class doesn't exist, it is loaded and added to the array to be returned, without verification (because you can't analyse a class that doesn't exist...);
    • but if it already exists, it is not loaded, and it is only added to the returned array if it is a "valid model class".

So, with our "Foo + BaseFoo" example, the first call to loadModels('models') returns an array with both 'Foo' and 'BaseFoo'. Now if you instantiate class Foo, thanks to modelsAutoload() both classes Foo and BaseFoo will then exist. Then, a 2nd call to loadModels('models') will return an array with only 'Foo' because BaseFoo did not pass at l. 691. So loadModels() is not deterministic...

  • If using aggressive loading, each found file is included immediatly (so, the class he defined now exists),
    1. then I see some "hack" for the possible "birth" of core classes (Doctrine_Access, Doctrine_Record_Abstract and Doctrine_Record in my debug session), but that also allows multiple classes definitions in a single model file, or a file defining a class with an arbitrary classname regardless of filename! This drastically differs form other loading modes!
    2. Then the(each) newly-existing class is not loaded nor added to the result unless it is a valid model; this is a big difference too!

IMHO:

  • although aggressive loading isn't meant to be used for production, it shouldn't differ that much (we should be able to switch loading mode without it causes issues)
  • if loading mode is other than "aggressive", loadModels() should always (not only on first call) return all the models found (recursively) in given directory(ies). If you want an array with only "valid models", either use getLoadedModels() (after loadModels()), or filter the return of loadModels() with filterInvalidModels() (which is already used in Doctrine_Export, Doctrine_Export_Schema, ...)

Edit: oh my... I just found this in documentation:

Aggressive model loading is the default model loading method and is very simple, it will look for all files with a .php extension and will include it. Doctrine can not satisfy any inheritance and if your models extend another model, it cannot include them in the correct order so it is up to you to make sure all dependencies are satisfied in each class.

With aggressive model loading you can have multiple classes per file and the file name is not required to be related to the name of the class inside of the file.

However I still think that loadModels() should return the same array for 2 same (subsequent) calls...

Regards

Comment by Guilliam X [ 15/Jun/10 ]

Attached a suggestion of patch that gives loadModels [different but] deterministic behaviors for both aggressive and non-aggressive loadings:

  • agressive: will always return only names of "valid" models
  • other: will always return all names of loaded models (see previous comment for getting only "valid" ones)




[DC-732] "charset" and "collation" column options cause seeking for a validator Created: 14/Jun/10  Updated: 15/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Validators
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Guilliam X Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Doctrine SVN 1.2 r.7676


Attachments: Text File DC-732.patch    

 Description   

If a record has a column defined with 'charset' and/or 'collation' in its options, calling $record->save() triggers exception
PHP Fatal error: Uncaught exception 'Doctrine_Exception' with message 'Validator named 'charset' not available.' in /[...]/lib/vendor/doctrine/Doctrine/Validator.php:56

Fix is trivial, see attached patch

Thank you



 Comments   
Comment by Guilliam X [ 14/Jun/10 ]

oops I had mis-clicked priority to max instead of minor...

Comment by Guilliam X [ 15/Jun/10 ]

Edited the patch with "branches/1.2" as root

I don't provide a test case but they all run without failure after patching





[DC-729] Doctrine_Parser_Xml numeric key in array Created: 12/Jun/10  Updated: 12/Jun/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Vitaliy Mayorov Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I convert array with numeric keys to xml and recived error message

Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: Element name is required in /home/vital/projects/hino/lib/vendor/symfony-1.4.3/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Parser/Xml.php on line 74

array

array
'id' => string '25' (length=2)
'count' => int 3
'cost' => float 68135.27
'user_id' => string '1' (length=1)
'profile_id' => string '1' (length=1)
'created_at' => string '2010-06-12 14:59:52' (length=19)
'OrderProductList' =>
array
0 =>
array
'id' => string '56' (length=2)
'count' => string '1' (length=1)
'cost' => string '9511.82' (length=7)
'user_id' => string '1' (length=1)
'code_1c' => string '2399' (length=4)
'catalog_number' => string '0446537150' (length=10)
'shot_name' => string 'PAD KIT, DISC BRAKE' (length=19)
'name' => string '' (length=0)
'vin' => string '' (length=0)
'engine_model' => string '' (length=0)
'status_id' => string '1' (length=1)
'transport_id' => string '1' (length=1)
'order_id' => string '25' (length=2)
'Order' => boolean false
1 =>
array
'id' => string '57' (length=2)
'count' => int 1
'cost' => float 55787.49
'user_id' => string '1' (length=1)
'code_1c' => string '2629' (length=4)
'catalog_number' => string '4405037040' (length=10)
'shot_name' => string 'ACTUATOR ASSY, BRAKE' (length=20)
'name' => string '' (length=0)
'vin' => string '' (length=0)
'engine_model' => string '' (length=0)
'status_id' => int 1
'transport_id' => int 1
'order_id' => string '25' (length=2)
'Order' => boolean false
2 =>
array
'id' => string '58' (length=2)
'count' => string '4' (length=1)
'cost' => float 2835.96
'user_id' => string '1' (length=1)
'code_1c' => string '2224' (length=4)
'catalog_number' => string 'S156071562' (length=10)
'shot_name' => string 'ELEMENT SET' (length=11)
'name' => string '' (length=0)
'vin' => string '' (length=0)
'engine_model' => string '' (length=0)
'status_id' => int 1
'transport_id' => int 1
'order_id' => string '25' (length=2)
'Order' => boolean false

in doctrine/Doctrine/Parser/Xml.php on line 74

$key = preg_replace('/[^a-z]/i', '', $key);

if (is_array($value) && ! empty($value)) {
$node = $xml->addChild($key);

$key = preg_replace('/[^a-z]/i', '', $key); from 69 line conver numeric key into empty string






[DC-710] doctrine:build-model does not create phpdoc for doctrine builtin attributes (sluggable, timestampable, id) Created: 29/May/10  Updated: 08/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Attributes
Affects Version/s: 1.2.0
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Kevin Hatry Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

When defining a table with actAs attributes (Timestampable, Sluggable, ...) doctrine creates columns in the database and corresponding attributes in the model classes, but the PHPDOC in the model classes does not include getters and setters for these "automatic" attributes.
This is unconvenient when using an IDE as the getter are not present in the auto completion.

The enhancement would be to add the appropriate phpdoc @property tags so that symfony can generate all the @method tags.

see http://trac.symfony-project.org/ticket/8711

Thank you

Kevin Hatry



 Comments   
Comment by Jonathan H. Wage [ 08/Jun/10 ]

I don't think this is a problem that can be patched easily, unfortunately.





[DC-686] postHydrate listener isn't called for related records Created: 17/May/10  Updated: 05/Sep/10

Status: Open
Project: Doctrine 1
Component/s: Record
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Cameron Ross Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Debian


Attachments: File NewTestCase.php    

 Description   

I have model A which has a one-to-one relationship with model B. They both have a listener on them which does an action on postHydrate. When I load model A, the postHydrate is called successfully. However when I then load the related model B (via $oMyModelA->B; or whatever), the listener is not called. This is the same when using the hook on the model - A::postHydrate() is called but B::postHydrate() is not.

Unit test demonstrating this bug is attached.



 Comments   
Comment by Ben Davies [ 05/Sep/10 ]

This is invalid.
In the test case:

$r->Related->save();

doesn't create a blank record, thus there is never a relation to postHydrate





[DC-642] import/export Array Created: 22/Apr/10  Updated: 22/Apr/10

Status: Open
Project: Doctrine 1
Component/s: Record
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Thomas Tourlourat - Armetiz Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Retreive an object "A" and some related object from the database.
Export it into an array.
Create an other instance of "A" and import array from the previous exported array.
Just save the new instance.

Doctrine re-create the object into DB. If you have some integrity constraint like primary key, you will see an SQL error.

In the following example with "video" and "tags", Doctrine want to re-create the video and tag objects.
The reason is that the exported array doesn't include the "_identifier" key.

In my mind, the problem show and other problem, that we are force to use the "identifier" or assignIdentifier on the Model domain object to work with an existing object.
Doctrine know the Primary key of all the model domain objects. Why Doctrine doesn't use the assignIdentifier when the user change the PK of the Model domain object... In this case, assignIdentifier could be into a private scope.

$oVideo = Doctrine_Query::create ()
->select ("video., tags.")
->from ("Model_Video video")
->leftJoin ("video.tags tags")
->where ("video.id_show = 500")
->fetchOne ();
$oVideoArray = $oVideo->toArray();
$oVideo->save ();

$oVideoBis = new Model_Video ();
$oVideoBis->fromArray($oVideoArray, true);
$oVideoArrayBis = $oVideo->toArray();
$oVideoBis->save ();






[DC-607] Doctrine concrete inheritance link between tables Created: 30/Mar/10  Updated: 21/Jul/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Julien Chiron Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 1
Labels: None
Environment:

Symfony 1.4.3, php5.3.0 (snow leopard version)



 Description   

Hi,

I pointed out a strange problem:
I have two tables that are linked with a one to many relation ship.
Each table has some concrete inherited tables.
Here is the schema:

Batch:
  columns:
    code: string
    is_pure: boolean

Flask:
  columns:
    batch_id: integer
    code: string
    quantity: integer
  relations:
    Batch:
      local: batch_id
      foreign: id
      foreignType: many
    
ProducedBatch:
  inheritance:
    type: concrete
    extends: Batch
  columns:
    production_date: date
    
BoughtBatch:
  inheritance:
    type: concrete
    extends: Batch
  columns:
    supplier: string
    
ProducedFlask:
  inheritance:
    type: concrete
    extends: Flask
  columns:
    weight: integer
    
BoughtFlask:
  inheritance:
    type: concrete
    extends: Flask
  columns:
    price: integer

The problem occurs when I try to populate the database.
Here is the data:

ProducedBatch:
  B1:
    code: Batch1

ProducedFlask:
  F1:
    Batch: B1
    code: Flask1

When loading fixtures, I get a

Invalid row key specified: (batch) B1, referred to in (produced_flask) F1

In fact, Doctrine doesn't take into account the primary key inherited from Flask table.
The mapping should be done between parent and child tables.

The only solution to solve this is to set a relationship between each couple of sub-table (ProducedFlask -> ProducedBatch and BoughtFlask -> BoughtFlask).



 Comments   
Comment by TD [ 21/Jul/10 ]

It is very strange that the doctrine inheritance system don't inherite all the relationship of the mother-table on all sub-table. I think that it will be a very good improvement to fix this problem.

For example if you are this model :

Unable to find source-code formatter for language: yml. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
 
motherTable:
  columns:
     code: string
     relationTable_id: integer
  relation:
     relationTableRelation:
            local: relationTable_id
            foreign: id
            type: one     

subTable:
    inheritance:
        type: concrete
    colums:
        name: string

relationTable:
    columns:
        code: integer
    relations:
        motherTableRelation:
            local: id
            foreign: relationTable_id
            type: many

In this example, the relationTableRelation will be inherited, it is good but the other side of the relation in relation table will always go on motherTable and not on subTable, but motherTable is always empty, moreover subTable don't share its ID with motherTable, so this side of the relationship is unusefull because we can find subTable element in relation with a relationTable element.

It will be good to find a solution to this issue





[DC-597] symfony doctrine:generate-migrations-diff task doesn't take attributes into account Created: 23/Mar/10  Updated: 08/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Migrations
Affects Version/s: 1.2.0
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Bob Stremel Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Windows 7, Apache 2.2.14, PHP 5.2.11, MySQL 5.0.86



 Description   

I provided the following bug report on the symfony website and was redirected here. The response I received was:

Ticket #8438 (closed defect: invalid)
03/20/10 12:55:04 changed by Kris.Wallsmith

  • status changed from new to closed.
  • resolution set to invalid.

The symfony task is a wrapper for the Doctrine task. Please post issues to their Jira. http://www.doctrine-project.org/jira

------------------
Bug details:
------------------

When running doctrine:generate-migrations-diff, I am receiving foreign key files. However, my schema.yml is defined as such:

attributes:
export: tables
TableOne:
columns:
...
TableTwo:
columns:
...

It would appear that when running doctrine:build it properly ignores the foreign key generation, but that it does not when running doctrine:generate-migrations-diff. This task should be corrected to take this attribute into account. Keep in mind that this may be relevant to the other migration tasks, and they should be updated as well if this is a valid bug.






[DC-560] Object1->Unlink(Relation, Id2) doesn't work, if primary key order in table of m2m reference isnt 1:Object 2: Id to unlink, when relation set to EQUAL= TRUE Created: 10/Mar/10  Updated: 27/Jan/11

Status: Reopened
Project: Doctrine 1
Component/s: Relations
Affects Version/s: 1.2.0
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Mariano Ramon Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None
Environment:

Windows XP, Apache 2.2, PHP 5, Doctrine 1.2 on Symfony 1.4



 Description   

Object1->Unlink(Relation, Id2) doesn't work, if primary key order in table of m2m reference isnt 1:Object 2: Id to unlink, when relation set to EQUAL= TRUE

User:
  actAs: 
    Timestampable: ~
  columns:    
    name:         { type: string(255), notnull: false }
    last_name:    { type: string(255), notnull: false }
    picture:      { type: string(255), notnull: false }
    birthday:     { type: timestamp, notnull: false }
    gender:       { type: string(255) }
    rating:       { type: integer, default:0} 
    num_comments: { type: integer, default:0} 
    num_groups:   { type: integer, default:0} 
  inheritance:
    extends: Member
    type: column_aggregation
    keyField: type
    keyValue: 1                    
  relations:
    Friends:    { onDelete: CASCADE, class: User, foreignAlias: Friends, refClass: FriendReference, local: user1, foreign: user2, equal: true }
    Request:    { onDelete: CASCADE, class: User, foreignAlias: Pending, refClass: PendingReference, local: user1, foreign: user2 }
    Blocker:    { onDelete: CASCADE, class: User, foreignAlias: Blocked, refClass: BlockedReference, local: user1, foreign: user2 }

 
			if(isset($refToRemove))
			{
				switch ($refToRemove)
				{
					case 'FriendReference': $references = $currentUser->Friends; $relation = 'Friends';	break;
					case 'PendingReference': $references = $currentUser->Pending; $relation = 'Pending'; break;
					case 'BlockerReference': $references = $currentUser->Blocker; $relation = 'Blocker'; break;
					case 'RequestReference': $references = $currentUser->Request; $relation = 'Request'; break;
				}
				 
				foreach($references as $reference)
				{

					if ($reference->id == $user2->id)
                        $currentUser->unlink($relation, array($user2->id), $now = true);
				}
                
			}

when you count relations from one side and the other it show that when set to EQUAL = TRUE relations are reciprocal, but unlink still minds primary keys order in order to function



 Comments   
Comment by Jonathan H. Wage [ 15/Mar/10 ]

I am unable to reproduce the issue. When I test everything works as expected. We really need some more information and a test case in order to be sure of any issue.

Comment by Ian Ricketson [ 30/Mar/10 ]

I was able to reproduce this issue in Doctrine 1.2. The issue is a two part scenerio, which makes it kind of hard to debug. But here is how to reproduce it.

1.) Lets assume you have a Product model with ID 14.
2.) Lets assume you have an "equal" M:M table that links to itself, (product_product_group). "product_id_1" and "product_id_2" are a compound primary key which link back to the Product model.
3.) Lets assume you that Product 14 is currently linked to products with IDs 2, 5, and 13.
4.) Assuming $object is an instance of Product id 14, call $object->unlink(array(2));

  1. SQL QUERY LOG for Step 4.)
    482 Query START TRANSACTION
    482 Query DELETE FROM product_product_group WHERE (product_id_1 = '14' AND product_id_2 IN ('2'))
    482 Query UPDATE product_product_group SET product_id_1 = '5' WHERE product_id_1 = '14' AND product_id_2 = '5'
    482 Query UPDATE product_product_group SET product_id_1 = '13' WHERE product_id_1 = '14' AND product_id_2 = '13'
    482 Query DELETE FROM product_product_group WHERE product_id_2 = '2' AND product_id_1 = '14'
    482 Query COMMIT

The result is as follows:
a.) Doctrine properly unlinks ID 2
b.) Doctrine updates the M:M table and sets the remaining two IDs (5 and 13) and links them to themselves (it shouldn't run these updates). Now, all we have in our database are two links (5-5 and 13-13).

5.) Now, Product ID 14 has no links anymore in the M:M table. So we call $object->link(array(2, 5, 13));

  1. SQL QUERY LOG for Step 5.)
    512 Query START TRANSACTION
    512 Query SELECT ... FROM to_product_id t WHERE (t.id IN ('13', '2', '5'))
    512 Query INSERT INTO to_product_id_to_product_id_group (product_id_2, product_id_1) VALUES ('2', '14')
    512 Query INSERT INTO to_product_id_to_product_id_group (product_id_2, product_id_1) VALUES ('5', '14')
    512 Query INSERT INTO to_product_id_to_product_id_group (product_id_2, product_id_1) VALUES ('13', '14')
    512 Query COMMIT

This works as expected.

6.) Now, in our database, Product ID 14 properly links to Ids 2, 5, and 13. BUT IDs 5 and 13 also have a link to themselves as a byproduct of the UPDATE queries called in step 4.).
7.) Now, we call $object->unlink(array(2)) again.

  1. SQL QUERY LOG for Step 7.)
    432 Query START TRANSACTION
    432 Query DELETE FROM product_product_group WHERE (product_id_1 = '14' AND product_id_2 IN ('2'))
    432 Query UPDATE product_product_group SET product_id_1 = '5' WHERE product_id_1 = '2' AND product_id_2 = '5'
    432 Query UPDATE product_product_group SET product_id_1 = '5' WHERE product_id_1 = '14' AND product_id_2 = '5'
    432 Query ROLLBACK

The following error occurs:

  1. Mar 30 20:40:41 symfony [err] exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5-5' for key 1' in /path/to/symfony/1.4/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php:1082

So basically, it repeated the same queries from step 4.), however this time around, when attempting to set ID 5 to itself, it fails because there is already an entry this pair in the database. Since we have a compound primary key, this non-unique combination is not allowed. I don't know why its trying to run these UPDATE queries, but its definitely something to do with thre relationship being "equal".

Comment by Jonathan H. Wage [ 08/Jun/10 ]

It is hard to decipher the problem. It is best and most clear to provide a test case.

Comment by Ian Ricketson [ 27/Jan/11 ]

I know this is old, and is likely to never be resolved, but the problem does still exist.

Basically, "unlinking" an equal relation only unlinks one side of the relationship:

DELETE FROM user_user_group WHERE (user_id_1 = '20' AND user_id_2 IN ('9'))

However, if the relationship was created from the other side (i.e. user_id_1 = 9 and user_id_2 = 20), then it doesn't properly get rid of the relationship. Again, this only applies when a relationship is marked as "equal".

Here is another post about the same issue, with their work-around:
http://stackoverflow.com/questions/1385281/how-do-i-remove-a-self-referencing-nn-relation-in-doctrine





[DC-497] A new task to set migration to a certain version Created: 12/Feb/10  Updated: 13/Feb/10

Status: Open
Project: Doctrine 1
Component/s: Migrations
Affects Version/s: 1.2.1
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Stephen Ostrow Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

All



 Description   

It would be nice to have a task which you could tell to set to the proper version. If the migrations_version table did not exist yet, it would create the table and set the version.

Explanation:
Most times migrations come as an after thought after the code db is already pushed live. Therefore you have to manually create the migrations table and set it to a version just before the newest migration.

It might also be better to just update the migrate task to check if a migration_version table exists, if not to just run the single migration which is specified.






[DC-464] [Inheritance] Couldn't save record with inheritance by a relationship if the record has no column modified (solution proposed) Created: 29/Jan/10  Updated: 09/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Colin Darie Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File DC464TestCase.php     Text File Record.php.patch    

 Description   

Please consider the following TestCase

Inheritance with no property setted, saved by relationship
class Doctrine_Ticket_DC464_TestCase extends Doctrine_UnitTestCase
{
    public function prepareTables()
    {
        $this->tables[] = 'Ticket_DC464_Entity';
        $this->tables[] = 'Ticket_DC464_Article';
        $this->tables[] = 'Ticket_DC464_User';
        $this->tables[] = 'Ticket_DC464_Group';
        parent::prepareTables();
    }

    public function testTest()
    {
        $User = new Ticket_DC464_User();

        $Article = new Ticket_DC464_Article();
        $Article->title = 'my first article';
        $Article->Author = $User;

        $Article->save();

        $UserFetched = Doctrine::getTable('Ticket_DC464_User')->find(1);
        $this->assertTrue($UserFetched instanceof Ticket_DC464_User);
       //$this->assertEqual($UserFetched->type, 1);


    }
}



class Ticket_DC464_Entity extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('id', 'integer', 11, array('autoincrement' => true, 'primary' => true));
        $this->hasColumn('facultative_field', 'string', 255);
        $this->hasColumn('type', 'string', 255);

        $this->setSubClasses(array(
             'Ticket_DC464_User' =>  array('type' => 1),
             'Ticket_DC464_Group' => array('type' => 2),
        ));

        $this->option('type', 'InnoDB');
    }

    public function setUp()
    {
    }
}

class Ticket_DC464_User extends Ticket_DC464_Entity { }
class Ticket_DC464_Group extends Ticket_DC464_Entity { }

class Ticket_DC464_Article extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('id', 'integer', 11, array('autoincrement' => true, 'primary' => true));
        $this->hasColumn('title', 'string', 30);
        $this->hasColumn('author_id', 'integer', 11);

        $this->option('type', 'InnoDB');
    }

    public function setUp()
    {
        $this->hasOne('Ticket_DC464_User as Author', array(
             'local' => 'author_id',
             'foreign' => 'id'));
    }
}

Notice that in the test, the $User instance has no property setted (in fact in this test, the "useless_field" in the model is... useless).

This test fails (the $User object is not saved) because the method UnitOfWork->saveRelatedLocalKeys() - called in saveGraph(), itself called by $Article->save() - returns false because no column has been modified (line 395).

To fix this, the Record->assignInheritanceValues() should be executed in top of isModified(), or for each related object in UnitOfWork->saveRelatedLocalKeys() (and probably UnitOfWork->saveRelatedForeignKeys() too).

I've attached the test.



 Comments   
Comment by Colin Darie [ 30/Jan/10 ]

Fix test with the right prefixes

Comment by Jonathan H. Wage [ 15/Mar/10 ]

Do you have a patch for the issue too?

Comment by Colin Darie [ 16/Mar/10 ]

Hi,

no I doesn't have a patch for this, because I was not sure what the best way to solve this.
However, patching the isModified() method is maybe the safest way, with a simple $this->assignInheritanceValues(); at top (around line 2100).

Comment by Jonathan H. Wage [ 08/Jun/10 ]

Can you provide a patch for that change then so I can see it and test it? Thanks, Jon

Comment by Colin Darie [ 09/Jun/10 ]

I've attached the patch.

Once again, this patch fix the issue but there is maybe a better way to fix it to avoid the assignInheritanceValues() at each time.

Thanks.





[DC-457] Generating YAML schema from DB breaks on certain table names Created: 26/Jan/10  Updated: 17/Mar/10

Status: Reopened
Project: Doctrine 1
Component/s: Import/Export
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Ari Pringle Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Linux, Symfony 1.4.1, Doctrine 1.2.1



 Description   

When attempting to reverse engineer databases using the generate-yaml-db task (via Symfony's doctrine:build-schema task), I've run into some issues due to table names not being compatible with PHP classnames. It creates the PHP classes in /tmp, setting the class name to the same as the table name, and then attempts to build the YAML files off of those.

I attempted to do this a few months ago and ran into issues because some of the table names began with numbers ("123MyTable" is not a valid PHP class name). My most recent attempt failed because of a table named "List", which is a reserved PHP keyword.

While I'm not sure if this is the ideal solution, I think allowing a way to pre-define a prefix for the generated PHP class names would be great.



 Comments   
Comment by Stefan [ 22/Feb/10 ]

I think there seems to be a general problem in usage of table names, when using the generating from database to yml.

I think there something changed with the naming stragegies in the last versions (I do not know in wich one), but it works with doctrine 1.0.10 (used in symfony 1.2.8).

theoretical stragegies:
1. Only the first letter is a capital (e.g. ProjectCategory --> Projectcategory)
2. When a _ is inside the name, the _ is removed an a capital will used (e.g. Project_Values --> ProjectValues)

But doctrine does not make use of this anymore. When I generate with doctrine 1.2.1 (used in symfony 1.3.2) my table ProjectCategory will be named as ProjectCategory in schema. And when the schema is wrong, all generated models are incompatible to older versions.

Comment by Jonathan H. Wage [ 01/Mar/10 ]

Hmm. I don't quite understand. I tested the things you described and it all works as I expected it to. You'll have to provide some more information.

Comment by Ari Pringle [ 17/Mar/10 ]

Sorry for the delay in response.

Here's how to reproduce my original issue (I should also mention that I'm running PHP 5.2.4):

mysql> create table List (id int not null auto_increment,primary key(id));
bash$ ./symfony doctrine:build-schema
>> doctrine  generating yaml schema from database

Parse error: syntax error, unexpected T_LIST, expecting T_STRING in /tmp/tmp_doctrine_models/List.php on line 17

bash$ sed -n '17p' /tmp/tmp_doctrine_models/List.php 
class List extends Doctrine_Record

The same thing happens if the table name begins with a number (ie 123MyTable).

Again, I'm not sure if this is the ideal solution, but being able to define a prefix to the generated class names would take care of this issue (so the generated class name above could be MyPrefix_List instead of List)





[DC-422] Using the ON_DEMAND hydrator a warning a thrown on the last iterator of a foreach Created: 13/Jan/10  Updated: 05/Dec/10

Status: Open
Project: Doctrine 1
Component/s: None
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Arnaud Limbourg Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

os x 10.6, php 5.3.1


Attachments: Text File Doctrine_Connection_Statement.patch    

 Description   

Used in a symfony project code similar to the following throws a warning on the last iteration of the foreach

$currentQuery = Doctrine_Query::create()
->from('article a');

$result = $currentQuery->execute(array(), Doctrine_Core::HYDRATE_ON_DEMAND);

foreach ($result as $article)

{ echo $article->getId(); }

The warnings are located in the connection profiler.

symfony-1.4/lib/plugins/sfDoctrinePlugin/lib/database/sfDoctrineConnectionProfiler.class.php on line 196

Warning: join(): Invalid arguments passed in symfony-1.4/lib/plugins/sfDoctrinePlugin/lib/database/sfDoctrineConnectionProfiler.class.php on line 141

I'm unsure how best to fix it. As far as I can tell there is an issue regarding the call to the iterator rewind at the end of the foreach.

Doctrine_Connection_Statement->execute(???) symfony-1.4/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/OnDemand.php:71



 Comments   
Comment by Jonathan H. Wage [ 01/Mar/10 ]

Sorry, we're gonna need some more information to be able to do anything for this ticket.

Comment by Jonathan H. Wage [ 08/Jun/10 ]

Is this issue a symfony one and not a Doctrine problem? It is hard to tell.

Comment by Marek Snopkowski [ 05/Dec/10 ]

Hi,

It's partially both - symfony doesn't protect itself from NULL params (default value), however when use Doctrine_Core::PORTABILITY_EMPTY_TO_NULL then Doctrine will also generate the same warning.

Btw - symfony does throw this issue only when logging is enabled.

This is a trace tail when when using OnDemand hydrator with foreach.

21 1.1271 26883400 LessonTable->copyTeacherData( ) ../actions.class.php:54
22 1.1604 27817624 Doctrine_Collection_OnDemand->rewind( ) ../OnDemand.php:0
23 1.1604 27784376 Doctrine_Connection_Statement->execute( ) ../OnDemand.php:71
24 1.1605 27785616 Doctrine_EventListener_Chain->preStmtExecute( ) ../Statement.php:231
25 1.1605 27785616 sfDoctrineConnectionProfiler->preStmtExecute( ) ../Chain.php:494
26 1.1606 27788152 sfDoctrineConnectionProfiler::fixParams( ) ../sfDoctrineConnectionProfiler.class.php:146

Suggested patch attached.
We're always expecting $params parameter to be an array, hence array() as default value.





[DC-418] Inherited models creating NOT NULL restrictions on their parents Created: 11/Jan/10  Updated: 11/Jan/10

Status: Open
Project: Doctrine 1
Component/s: Attributes, Inheritance, Record, Schema Files
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: luke scott Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Linux skywalker-9 2.6.31-17-generic #54-Ubuntu SMP Thu Dec 10 17:01:44 UTC 2009 x86_64 GNU/Linux


Attachments: File sample.yaml    

 Description   

to reproduce, create the yaml included in sample.yaml (Note the not-null columns in each subclass)

if you try to save an OnlineProduct without setting copyright_year, or if you create a print_product without setting website_branding_id, then you will get a not null error.
Inherited tables should be able to set their own NOT NULL columns without affecting other tables in the inheritance tree (should be handled in the preSave() method? or is there another mechanism?)



 Comments   
Comment by luke scott [ 11/Jan/10 ]

YAML format was destroyed during copy & paste!
I'm attaching the sample yaml, instead of including it in the description





[DC-354] Using BETWEEN operator with MySQL fails Created: 11/Dec/09  Updated: 08/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: 1.1.4
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Matt McKeon Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None
Environment:

PHP 5.2.10
MySQL 5.1.37



 Description   

When running this bit of code the query fails with the error "Unknown aggregate alias: interval", and calling $q->getSql() doesn't return anything.

{{$q = Doctrine_Query::create()
...
->where('u.birthday BETWEEN date_sub(now(), interval 7 day) AND NOW()');}}

I've tried different variations in the where() clause with no luck. I am using all the other MySQL functions in another query here:
$q->where('date(birthday) = date_sub(curdate(), interval 1 day)')
so I don't believe that they are the problem.

I would expect the BETWEEN operator to be recognized and work appropriately.



 Comments   
Comment by Jonathan H. Wage [ 08/Jun/10 ]

BETWEEN is mysql specific, no?





Generated at Wed Aug 27 17:02:46 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.