[DC-1058] Warning: Invalid argument supplied for foreach() in SqlWalker.php line 899 Created: 29/Jul/12 Updated: 29/Jul/12 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Alexander Cucer | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | paginator | ||
| Environment: |
Linux, Ubuntu 12, php 5.4 |
||
| Description |
|
Hallo, i get the error Here is the line Here are the relations and the query Here is the dump of $assoc before warning array(16) { ["orphanRemoval"]=> |
[DC-1053] Renaming a doctrine 'string' field may result in loss of data as the field's type changes. (MySQL) Created: 26/Mar/12 Updated: 26/Mar/12 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Migrations |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Ben Lancaster | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3.5-1ubuntu7.2ppa1~lucid with Suhosin-Patch (cli) (built: May 7 2011 03:12:27) |
||
| Description |
|
Consider the following schema: schema.yml MyTable:
columns:
some_text: string
Doctrine creates the table with: CREATE TABLE `my_table` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `some_text` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Now, the following migration should rename the field from some_text to just_text: <?php class Version1 extends Doctrine_Migration_Base { public function up() { $this->renameColumn('my_table', 'some_text', 'just_text'); } public function down() { $this->renameColumn('my_table', 'just_text', 'some_text'); } } ...however the field gets renamed and the type becomes VARCHAR(255), as the resulting SHOW CREATE TABLE my_table shows: CREATE TABLE `my_table` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `a_varchar` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Causes data in the column greater than 255 bytes to get truncated |
[DC-1052] limit() get lost on multiple joins Created: 20/Mar/12 Updated: 20/Mar/12 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Michael Kempf | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
$strSql = UserFeedTable::getInstance() string(1075) "SELECT u.id AS u_id, u.name AS uname, u.image AS uimage, u.lead AS ulead, u.headline AS uheadline, u.sort AS usort, u.is_active AS uis_active, u.is_favorite AS uis_favorite, u.feed_id AS ufeed_id, u.profile_id AS uprofile_id, u.category_id AS ucategory_id, u.created_at AS ucreated_at, u.updated_at AS uupdated_at, f.id AS fid, f.url AS furl, f.name AS fname, f.created_at AS fcreated_at, f.updated_at AS fupdated_at, f2.id AS f2id, f2.lead AS f2lead, f2.description AS f2description, f2.image AS f2image, f2.pub_date AS f2pub_date, f2.link AS f2link, f2.feed_id AS f2feed_id, f2.created_at AS f2created_at, f2.updated_at AS f2updated_at, f3.id AS f3id, f3.profile_id AS f3profile_id, f3.feed_item_id AS f3feed_item_id, f3.created_at AS f3created_at, f3.updated_at AS f3_updated_at FROM user_feed u LEFT JOIN feed f ON u.feed_id = f.id LEFT JOIN feed_item f2 ON f.id = f2.feed_id LEFT JOIN favorite f3 ON f2.id = f3.feed_item_id WHERE u.id IN ('7', '8', '9', '10', '11') AND (u.profile_id = ? AND u.is_active = ?)" As you can see, the limit is missing. |
[DC-1050] Doctrine_Relation_ForeignKey ignores ATTR_COLL_KEY attribute Created: 06/Mar/12 Updated: 07/Mar/12 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Attributes, Relations |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | 1.2.4 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Uli Hecht | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 7 64Bit |
||
| Attachments: |
|
| Description |
|
Doctrine_Relation_ForeignKey::fetchRelatedFor() executes the following code at line 70: $coll = $this->getTable() As you can see it accesses the first element by using index "0" in $coll and hence ignores a modified ATTR_COLL_KEY-setting, for instance: $this->setAttribute(Doctrine_Core::ATTR_COLL_KEY, 'id'); Fortunately I had two models (ForeignA and ForeignB) in my project which both have an one-to-one relation to a third model (Main). That helped me finding this bug which causes the following strange behavior: // program 1: $m = new Main(); // program 2: $m = Doctrine_Core::getTable('M1')->findOneBy('name', 'M1'); ------------------------- The big problem about this issue is that behavior is inconsistent. If you don't split the example above into two separate programs/processes you won't have problems, since Doctrine accesses the reference which was stored when calling save(). You will get into trouble using functional tests in Symfony. Since there is only a single process for all requests I wasn't able to reproduce a problem caused by this bug which appeared in the production environment. ------------------------- Edit: Doctrine_Connection::queryOne() is affected as well! A solution is to replace $coll = $this->getTable() by $related = $this->getTable() |
| Comments |
| Comment by Uli Hecht [ 07/Mar/12 ] |
|
Suggested patch |
[DC-1009] save() also updates fields which should not be Created: 08/Jun/11 Updated: 08/Jun/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Yan Urquiza | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows server 2003 PHP 5.2.17 / XP PRO 32bits XAMPP PHP 5.3.5 |
||
| Attachments: |
|
| Description |
|
When I want to do a simple update like this : $batches = ExamResultsBatchTable::getInstance()->retrieveByExamBatchStatus(ExamResultsBatch::valid_status_code); If I run this: here is the simpliest case. The same problems are signaled on other tables in the database, but different tables can be impacted by one save() (the execute() query still works fine). Example : 2 foreign tables will be updated , even if the save() action should only concern the main table, and one field (which is not a foreign key). Because save() is used in a lot of different places in our app, I need to find a solution to fix save(), or if not possible to override it to run a execute()like query. Thanks for your help. Yan |
[DC-1007] Cannot update a field to NULL with MSSQL connection Created: 25/May/11 Updated: 25/May/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Connection |
| Affects Version/s: | None |
| Fix Version/s: | 1.2.4 |
| Type: | Bug | Priority: | Critical |
| Reporter: | guitio2002 | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 7 32 bits with Apache 2.2.x, PHP 5.2.17, Sql Server 2008, Symfony 1.4.11 and Doctrine 1.2.4 |
||
| Description |
|
When trying to update a field to NULL in a MSSQL database, Doctrine generates the following request: UPDATE table SET fieldThatMustBeNull = , anotherField = 'blabla'; therefore generating a syntax error. A fix would be to override the update method in the Doctrine_Connection_Mssql and add the following behavior: Doctrine_Connection_Mssql public function update(Doctrine_Table $table, array $fields, array $identifier) { if (empty($fields)) { return false; } $set = array(); foreach ($fields as $fieldName => $value) { if ($value instanceof Doctrine_Expression) { $set[] = $this->quoteIdentifier($table->getColumnName($fieldName)) . ' = ' . $value->getSql(); unset($fields[$fieldName]); } else if (is_null($value)) { $set[] = $this->quoteIdentifier($table->getColumnName($fieldName)) . ' = NULL'; unset($fields[$fieldName]); } else { $set[] = $this->quoteIdentifier($table->getColumnName($fieldName)) . ' = ?'; } } $params = array_merge(array_values($fields), array_values($identifier)); $sql = 'UPDATE ' . $this->quoteIdentifier($table->getTableName()) . ' SET ' . implode(', ', $set) . ' WHERE ' . implode(' = ? AND ', $this->quoteMultipleIdentifier($table->getIdentifierColumnNames())) . ' = ?'; return $this->exec($sql, $params); } |
[DC-980] Moving all ALTERS queries to the end of generated sql file (task build-sql) Created: 04/Mar/11 Updated: 04/Mar/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Cli, Schema Files |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Sergey Eremenko | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Actual in case of using multi database configuration and foreign keys between them. Now build-sql task generates SQL query for database by database in alphabetical order. It's ugly when we have multidatabase configuration and foreign keys between their tables. It's impossible to do 'import-sql' without errors beucase foreign keys constrains to nonexisting tables are in next database in order. I have added some code to strings 1176-... |
[DC-978] Doctrine_Connection_Mssql dies on modifyLimitSubquery every time Created: 27/Feb/11 Updated: 27/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Connection |
| Affects Version/s: | 1.2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Andrej Pavlovic | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
windows |
||
| Description |
|
Looking at the latest version of Doctrine_Connection_Mssql in git repo: In Doctrine_Query:getLimitSubquery() there is a call to Doctrine_Connection_Mssql::modifyLimitSubquery(). public function modifyLimitSubquery(Doctrine_Table $rootTable, $query, $limit = false, $offset = false, $isManip = false) { return $this->modifyLimitQuery($query, $limit, $offset, $isManip, true); } This in turn calls Doctrine_Connection_Mssql::modifyLimitQuery() wihtout passing the $queryOrigin parameter: public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false, $isSubQuery = false, Doctrine_Query $queryOrigin = null) { if ($limit === false || !($limit > 0)) { return $query; } $orderby = stristr($query, 'ORDER BY'); if ($offset !== false && $orderby === false) { throw new Doctrine_Connection_Exception("OFFSET cannot be used in MSSQL without ORDER BY due to emulation reasons."); } $count = intval($limit); $offset = intval($offset); if ($offset < 0) { throw new Doctrine_Connection_Exception("LIMIT argument offset=$offset is not valid"); } $orderbySql = $queryOrigin->getSqlQueryPart('orderby'); $orderbyDql = $queryOrigin->getDqlPart('orderby'); if ($orderby !== false) { $orders = $this->parseOrderBy(implode(', ', $queryOrigin->getDqlPart('orderby'))); for ($i = 0; $i < count($orders); $i++) { ... From just looking at the above code, the query chokes on the first call to a $queryOrigin method. It seems like there is a lot of missing code here which should work with the $query directly when $queryOrigin is not available... What is the point of $orderbySql and $orderbyDql variables when they are not used anywhere? This code looks like it's half way done and untested. |
[DC-963] Doctrine cache - Salt dissociation Created: 03/Feb/11 Updated: 18/Apr/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Caching |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Thomas Tourlourat - Armetiz | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Doctrine Cache store data into a persistence storage. Regarding APC, Doctrine use a share storage. I'm using a server to host two Doctrine project, a preproduction & production Website. In some case, DQL is the same on both project, but the data model definition isn't. Preproduction convert DQL to SQL using data model definition, and store the SQL result into APC cache refer to the DQL hash. I'm not sure about the quality of this explanation... But I can add some information is needed. The solution of this problem is easy. Just add a SALT to any cache id's. It's a Doctrine_Cache problem, not only a Doctrine_Cache_APC problem.. $cacheDriver = new doctrine_Cache_Apc (); |
| Comments |
| Comment by Thomas Tourlourat - Armetiz [ 03/Feb/11 ] |
|
to complete this bug, I think it's also a problem on DC 2.. |
| Comment by Jaik Dean [ 18/Apr/11 ] |
|
There is already an (undocumented?) option "prefix" that allows this. $cacheDriver = new Doctrine_Cache_Apc(array('prefix' => 'MY UNIQUE SALT')); |
[DC-932] Queries fail when a model contains underscore and we try to apply a limit Created: 19/Nov/10 Updated: 19/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Noel GUILBERT | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Doctrine 1.2, Symfony 1.4.6, MySQL, Postgresql |
||
| Description |
|
Actually, I've a dead simple schema.yml, with two tables: T_Media: name: string(25) J_Acl: I have some fixtures: J_Acl: And then, the DQL query I want to execute: "From T_Media m INNER JOIN m.J_Acl order by m.created_at limit 1" But if I run this query, for instance in CLI, I got an error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test_noel.t2__media' doesn't exist. Notes:
|
[DC-922] master-slave replication with i18n behavior Created: 10/Nov/10 Updated: 10/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Behaviors |
| Affects Version/s: | 1.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | husen mankada | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
php 5.3, doctrine 1.2, Symfony 1.4, mysql |
||
| Description |
|
I'm trying to use sfDoctrineMasterSlavePlugin for database replication with Symfony 1.4 and PHP 5.3. But facing problem while selecting I18n records and receiving "Unknown relation alias Translation" error. I've also tried same with implementation solution given in master-slave chapter of doctrine cookbook but no success. Is anyone facing same problem with sfDoctrineMasterSlavePlugin and i18n behavio? Is there any solution of the problem? |
[DC-857] postHydrate not called for One to One relations, when ATTR_HYDRATE_OVERWRITE == false, and the record is cached in the table's identityMap Created: 03/Sep/10 Updated: 05/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Record |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Ben Davies | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
All |
||
| Attachments: |
|
| Description |
|
When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called. This is due to this line. } else if ( ! isset($prev[$parent][$relationAlias])) { ...which will always evaluate to false, and postHydrate will ever be called, as the record has been pulled from the table cache here |
| Comments |
| Comment by Ben Davies [ 03/Sep/10 ] |
|
Test case attached. |
| Comment by Ben Davies [ 03/Sep/10 ] |
|
There needs to be some kind of caching on the pre/postHydrate calls, which is done throughout the Doctrine_Hydrator_Graph, except for when the relation is one-to-one. Unfortunately, I couldn't work out how to implement it for one-to-one. |
| Comment by Ben Davies [ 03/Sep/10 ] |
|
Correct Test Case |
| Comment by Ben Davies [ 03/Sep/10 ] |
|
Correct Test Case |
| Comment by Ben Davies [ 05/Sep/10 ] |
|
I was probably a little too tired to think this through clearly on a Friday after a long weeks work! |
[DC-815] Model's default sorting breaks subqueries Created: 11/Aug/10 Updated: 14/Mar/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query, Record |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Jacek Jędrzejewski | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
It works except subqueries. Main table's order is added to subquery and vice versa. SQL query looks like this: {{ Query fails because there is >>no such column "t.id"<<. I include a testcase when it is all visible. BTW. there is nothing about that feature (and relation orderBy) in docs. It is only in UPGRADE file. |
| Comments |
| Comment by Jacek Jędrzejewski [ 25/Aug/10 ] |
|
Anyone? |
| Comment by Alan Betteridge [ 10/Mar/11 ] |
|
Am having the same issue! Eventually found the orderBy option on both the model and on relationships and was over joyed as I'd been trying to find a way of doing this, but it didn't work!! Found the patch http://www.doctrine-project.org/jira/browse/DC-651 which solved the first problem I encountered but now I'm getting this. |
| Comment by Alan Betteridge [ 14/Mar/11 ] |
|
Had a look at the code and tried only setting the orderBy if the current component is actually referenced in the from sql part of the query. Looking at what is selected from, $this->_sqlParts['from'], it appears that the main table ($map['table']->getTableName()) and $sqlAlias is include with a zero index and joined tables are keyed by their $alias (or at least the content of these variables within the loop). From this I believe I could detect if the current entry in the loop was from a table that was in the current "FROM" part of the query by looking for the table name and alias as an entry or the current alias as a key in the "FROM" array. Within my sub query the orderBy valeus would still get applied but only in the subquery and not in the main query where they were included before, out of scope. With patch DC-651 applied my code in Query.php at line 1315 noew looks as follows:
// Note: Only include orderBy values for tables we're actually selecting from (both the root table or
// tables referenced from it)
if (in_array("{$map['table']->getTableName()} {$sqlAlias}", $this->_sqlParts['from']) || array_key_exists($alias, $this->_sqlParts['from'])) {
if (isset($map['relation'])) {
if (isset($map['ref'])) {
$orderBy = $map['relation']['refTable']->processOrderBy($sqlAlias, $map['relation']['orderBy'], true);
if ($map['relation']['orderBy'] && $orderBy == $map['relation']['orderBy']) {
$orderBy = $map['relation']->getOrderByStatement($sqlAlias, true);
}
} else {
$orderBy = $map['relation']->getOrderByStatement($sqlAlias, true);
if ($orderBy == $map['relation']['orderBy']) {
$orderBy = null;
}
}
} else {
$orderBy = $map['table']->getOrderByStatement($sqlAlias, true);
}
} else {
$orderBy = null;
}
Am I correct in my assumptions? |
[DC-802] Alias in select and having Created: 28/Jul/10 Updated: 07/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Vasiliy Altunin | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows XP sp3 |
||
| Description |
|
i have query $q = Doctrine_Query::create() When it runs i have error: <b>Fatal error</b>: Uncaught exception SQL for it looks like: SELECT g.grid AS g_grid, g.fam AS gfam, g.nam AS g_nam, g.otc AS But i need Query looks like: SELECT g.grid AS g_grid, g.fam AS gfam, g.nam AS g_nam, g.otc AS This query run fine and give me what i need. Doctrine dont use 'md' alias instead it convert it to 'p__0' |
[DC-755] CLONE [DC-558] incorrect handling of MODEL_CLASS_PREFIX causes Doctrine_Migration_Diff to drop the whole database when working from YAML (Regression) Created: 20/Jun/10 Updated: 10/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Migrations |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Andrew Coulton | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Current HEAD of Doctrine 1.2 |
||
| Attachments: |
|
| Description |
|
Replicating the bug: Expected (previous) behaviour: Real behaviour: |
| Comments |
| Comment by Andrew Coulton [ 20/Jun/10 ] |
|
This seems to be a regression caused by the fix for While this fixed the issue when generating diff from models to YAML, it has now created the reverse issue for generating diffs from YAML to YAML - as the models generated for the "from" schema do not get MODEL_CLASS_PREFIX prepended and so now this command will drop all existing tables and recreate. I believe the fix may be to amend as: Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml $from = $this->_generateModels( Doctrine_Manager::getInstance()->getAttribute(Doctrine_Core::ATTR_MODEL_CLASS_PREFIX) . self::$_fromPrefix, $this->_from); $to = $this->_generateModels( Doctrine_Manager::getInstance()->getAttribute(Doctrine_Core::ATTR_MODEL_CLASS_PREFIX) . self::$_toPrefix, $this->_to ); Since it seems that when presented with a folder of models _generateModels ignores the prefix anyway. However, I'm not sure of other impacts possible as a result? |
| Comment by Andrew Coulton [ 29/Aug/10 ] |
|
I've been using and testing the modified version above locally for some time and it seems to work as expected. Any chance of this making it into core? Otherwise, the migrations feature is completely unusable when working YAML-YAML and using model prefixes on the newly released 1.2.3 |
| Comment by Jonathan H. Wage [ 29/Aug/10 ] |
|
Has anyone been able to produce this in a test case? |
| Comment by Andrew Coulton [ 30/Aug/10 ] |
|
I've attached a diff file with the DC755TestCase and the required from and to YAML schema files to reproduce this bug. I wasn't sure whether you prefer like this or as a git commit? |
| Comment by Andrew Coulton [ 30/Aug/10 ] |
|
Also attached a diff file of my proposed change to Doctrine_Migration_Diff to resolve this, but as I say unsure if it has implications on other migration types. |
| Comment by Andrew Coulton [ 10/Oct/10 ] |
[DC-747] Sequence name of build process is different to the one used in UnitOfWorks (based on DC521 with updated TestCase) Created: 17/Jun/10 Updated: 17/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | 1.2.3, 1.2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Enrico Stahn | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
doctrine 1.2.4, symfony 1.4, snow leopard, php 5.3.1, postgresql 8.3 |
||
| Attachments: |
|
| Description |
|
I moved our project from doctrine 1.2.1 to 1.2.4. The build process stops because of this patch. We are using primary keys with an alias. It seems that the generation of the sequence name in the build-process is different to the one used in UnitOfWorks. Example: Authority: name: { type: string }This will generate a sequence called "authority_a_id", but it will try no "currval" the sequence "authority_id". I'll try to provide a UnitTest. The current seems broken. php -l Ticket/DC521TestCase.php Parse error: syntax error, unexpected $end, expecting T_FUNCTION in Ticket/DC521TestCase.php on line 143 |
| Comments |
| Comment by Enrico Stahn [ 17/Jun/10 ] |
|
Here is the test updated with the current ticket number. |
| Comment by Enrico Stahn [ 17/Jun/10 ] |
|
Updated. Now it should work/not work as expected. |
| Comment by Enrico Stahn [ 17/Jun/10 ] |
|
This isn't a blocker anymore because of the workaround i've found.
Example: Authority: name: { type: string } |
[DC-743] Incompatibilty between fixture import and accessors extends Created: 16/Jun/10 Updated: 22/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Data Fixtures, Import/Export |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Brice Favre | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
Window, PHP5, Symfony |
||
| Description |
|
Hello, I had a problem when i try to import data with an extended accessors when i try to insert a content with a relation. I discovered this problem in symfony. For example, here is my table :
News:
tableName: ne_news
columns:
id: { type: integer(4), primary: true, autoincrement: true }
author_id: { type: integer(4), notnull: true }
name: { type: string(255) }
description: { type: text }
relations:
author: { class: sfGuardUser, onDelete: NULL, local: author_id, foreign: id, foreignAlias: sfGuardUser }
And the fixture :
SfGuardUser:
sadmin:
username: admin
password: admin
is_super_admin: true
author1:
username: myname
News:
News1:
name: Test 1
description: Description of news 1
author: author1
I import it with symfony doctrine:data-load and it works. If i add a news.class.php and extends the autogenerated class it fails.
public function setAuthor($v)
{
//__log('extending setter');
return $this->_set('author', $v);
}
WhenDoctrine_Data_Import finds the setAuthor function, it wont transform author1 in object so $v will be a string, not an sfGuardUser object. What do you think? Is a common behavior, how can i extends my accessor? |
| Comments |
| Comment by ryan [ 22/Jul/11 ] |
|
this is the same issue as DC-735 |
[DC-735] Imported objects not converted to objects and parsed as string when a setter method exists Created: 14/Jun/10 Updated: 22/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Import/Export |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Kevin Dew | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Mac OS X 10.6 |
||
| Description |
|
If you set a setter method for a model which is for a relation the data import no longer works. This seems to be because in the _processRow method it checks if a method exists and then passes the default value rather than checking whether a relation exists first and passing the imported object. This effectively means you can't overload a setter method and still use the data import. |
| Comments |
| Comment by ryan [ 22/Jul/11 ] |
|
added testcase here |
[DC-725] Call record->get('RelationManyToManyName', FALSE) corrupt the record and generate a exception when calling record->save() Created: 09/Jun/10 Updated: 09/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Record |
| Affects Version/s: | 1.2.1, 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | David Jeanmonod | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
PHP 5.3.1 (cli) (built: Feb 11 2010 02:32:22) |
||
| Attachments: |
|
| Description |
|
Imagine a simple case. Contact can have many categories. $c = Doctrine::getTable('Contact')->findOneById($id);
$c->get('Categories', false);
$c->save();
Generate the following error PHP Fatal error: Call to a member function save() on a non-object in /lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php on line 443
PHP Stack trace:
PHP 1. {main}() /test/doctrine/get_with_no_load_corrupt_many_to_many_assoc_.php:0
PHP 2. Doctrine_Record->save() /test/doctrine/get_with_no_load_corrupt_many_to_many_assoc_.php:51
PHP 3. Doctrine_Connection_UnitOfWork->saveGraph() /lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php:1705
PHP 4. Doctrine_Connection_UnitOfWork->saveAssociations() /lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php:137
|
| Comments |
| Comment by David Jeanmonod [ 09/Jun/10 ] |
|
Test case for the bug |
[DC-690] Wrong data type for oracle integer Created: 18/May/10 Updated: 08/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Arian Maykon de Araújo Diógenes | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Trying to migrate from doctrine 1 to 1.2 and this problem came up to me, i cant map a column to integer(7) (which should create a number(7) column) using Oracle, he always create a NUMBER(20) field. Taking a look at Doctrine_DataDict_Oracle i realize the problem is here. |
| Comments |
| Comment by Jonathan H. Wage [ 08/Jun/10 ] |
|
We made a bunch of changes/fixes related to oracle. This was to fix another bug I believe. I can't remember the user that is responsible for these changes. Does anyone else remember or know anything? |
[DC-674] NULL Dates are translated to '0000-00-00' after upgrading to 1.2.2 Created: 10/May/10 Updated: 06/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Behaviors |
| Affects Version/s: | 1.2.1, 1.2.2 |
| Fix Version/s: | 1.2.1, 1.2.2 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Ville Itämaa | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Zend Framework, Ubuntu 9.10, MySQL |
||
| Description |
|
Once the upgrade was done from Doctrine 1.2.1 to 1.2.2 we discovered that date related issues started to appear. |
| Comments |
| Comment by Jonathan H. Wage [ 10/May/10 ] |
|
Are you able to reproduce this in a test case? |
| Comment by Ville Itämaa [ 11/May/10 ] |
|
We reverted to Doctrine 1.2.1 after realising the bug to confirm it was Doctrine 1.2.2 that was the cause for the problem. And as a result the records with NULL dates in the DB became NULL in the Models. |
| Comment by Jonathan H. Wage [ 11/May/10 ] |
|
Were you able to identity which changeset it was? You can read about creating test cases here http://www.doctrine-project.org/documentation/manual/1_2/en/unit-testing So far I am not able to reproduce the error you described. |
| Comment by Jonathan H. Wage [ 08/Jun/10 ] |
|
I'd like to fix this. Did you ever figure out which changeset introduced the issue? I've been trying to figure it out myself. |
| Comment by Roland Huszti [ 06/Oct/10 ] |
|
With 1.2.3 this works for me fine with both TIMESTAMP and DATE fields. YAML
date_of_birth:
type: date
BASE MODEL
$this->hasColumn('date_of_birth', 'date', null, array(
'type' => 'date',
// try these two
// 'notnull' => false,
// 'default' => null
));
YAML
exported_at:
type: timestamp(25)
notnull: false
default: null
# in this model I have everything to make sure it accepts and defaults to NULL
BASE MODEL
$this->hasColumn('exported_at', 'timestamp', 25, array(
'type' => 'timestamp',
'notnull' => false,
'length' => '25',
));
You may try adding these to your YAML and (base) models
YAML
fieldname:
. . .
notnull: false
default: null
BASE MODEL
$this->hasColumn('fieldname', . . .
. . .
'notnull' => false, // <<<<<<<
// 'default' => null, // <<< maybe, probably not needed
));
I hope it helps. |
[DC-659] Sluggable behavior does not check uniqueness on insert if a slug is manually set, causing SQL error/crash Created: 01/May/10 Updated: 05/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Behaviors |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Christian Seaman | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
symfony-1.3.4 and doctrine-1.2.2 |
||
| Description |
|
The Sluggable behavior has the following code:
Sluggable.php /**
* Set the slug value automatically when a record is inserted
*
* @param Doctrine_Event $event
* @return void
*/
public function preInsert(Doctrine_Event $event)
{
$record = $event->getInvoker();
$name = $record->getTable()->getFieldName($this->_options['name']);
if ( ! $record->$name) {
$record->$name = $this->buildSlugFromFields($record);
}
}
However, this can lead to problems... If the user incorrectly assigns a duplicate slug to the record then there is no uniqueness checking in doctrine and you get an uncaught SQL error looking something like this: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'my-slug-en_GB' for key 'foo_i18n_sluggable_idx' If this kind of "don't do a preInsert check if I manunally set the slug" behavior is a FEATURE then it would be best to have an option to allow it to be disabled. If it is a BUG then I would suggest that the preInsert method should be changed to: Sluggable.php /**
* Set the slug value automatically when a record is inserted
*
* @param Doctrine_Event $event
* @return void
*/
public function preInsert(Doctrine_Event $event)
{
$record = $event->getInvoker();
$name = $record->getTable()->getFieldName($this->_options['name']);
if ( ! $record->$name) {
$record->$name = $this->buildSlugFromFields($record);
} else { // Still check for slug uniqueness when you insert
$record->$name = $this->buildSlugFromSlugField($record);
}
}
C |
| Comments |
| Comment by Jonathan H. Wage [ 08/Jun/10 ] |
|
Can you provide your changes as a patch/diff with a test case? |
| Comment by Christian Seaman [ 05/Oct/10 ] |
|
Hi Jonathan, I'm not so hot at making patches or test cases, but it should be fairly easy if you know what you're doing... Just try to create and save two records with the same hard-coded slug and the second one will fail with an ugly MySQL crash. If you add the lines } else { // Still check for slug uniqueness when you insert
$record->$name = $this->buildSlugFromSlugField($record);
to the Sluggable::preInsert() method then this problem is averted and the test cases will pass. I have been running with this modification in our production version of Doctrine since I first reported this in May and it all seems to work well. If you really need me to figure out how to make a patch and test case please re-comment on this ticket and I'll see what I can do when I have some free time. C |
[DC-644] _getCacheKeys() exhausts memory Created: 22/Apr/10 Updated: 06/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Caching |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Amir W | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Doctrine is installed as a Symfony plugin. Using the latest Symfony from SVN. |
||
| Description |
|
My scripts have excessive memory consumption and I've often saw in my logs: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 2097152 bytes) in /proj/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Apc.php on line 111 Looking into the code I've found which function to blame:
My server extensively uses APC caching and it's normal to have many cache keys. Is there another way to avoid this pitfall? |
| Comments |
| Comment by Amir W [ 26/Apr/10 ] |
|
Is there any patch that could be provided meanwhile? This is quite a problem on a live website. |
| Comment by Amir W [ 10/May/10 ] |
|
Is this not a critical issue for Doctrine's cache? It's been up for 2 weeks with not even a comment... |
| Comment by Jonathan H. Wage [ 10/May/10 ] |
|
Hi, what are you calling that is invoking _getCacheKeys()? The only methods that call it are the deleteBy*() methods. It is expected that these methods have to get the entire list of cache keys from the driver in order to perform the delete by operation. These cache clearing operations should probably be done in the CLI environment where the memory limits are higher. If you want to avoid _getCacheKeys() being invoked, then you must not use the deleteBy*() methods. |
| Comment by Amir W [ 10/May/10 ] |
|
Thank you for commenting. Yes, I am using deleteByRegex() since I need to expire some result cache entries upon an update operation. What other choice do I have if I wish to keep using the result cache offered by Doctrine? Is there any other mechanism? Can't _getCacheKeys() be optimized some way? |
| Comment by Jonathan H. Wage [ 10/May/10 ] |
|
No, it is not able to be optimized anymore. It has to load all the keys into a php array in memory in order to loop over them to compare against the regex. You should probably not be doing cache clearing operations in the browser under apache. If you do, you'll need to raise your memory limit. |
| Comment by Amir W [ 10/May/10 ] |
|
My code actually had a few of these calls and I've now removed use of the result cache with Doctrine. What you're writing means the result cache is not usable for dynamic websites. IMHO, it's a good practice to cache results and remove them once an update is made to the data (which naturally can happen due to an update from a user). However, if that by itself creates an overload on the server (and as you know even a temporary memory abuse leads to an overload), I cannot see how it can be useful. Thanks |
| Comment by Jonathan H. Wage [ 10/May/10 ] |
|
This is the only way to allow more complex delete functionality. How you use it, is not up to us. We intended that cache clearing is done from the command line or in an environment where the memory limit is high enough to be able to load all those keys. It may not be able to be used by everyone, if it is not working for how you are using it then you will need to think of another solution I suppose. |
| Comment by Amir W [ 10/May/10 ] |
|
Thank you for your response and I'll think of another solution for my application. I did dive into the code and there's a relevant optimization that could be made. _getCacheKeys() is actually creating another array for all the cache keys which needlessly increases the memory used. There could be a way around the problem which also implements another feature I miss with the results cache. By allowing some sort of cache tagging to mark the items that may need to be deleted we could easily delete relevant entries. I'll describe the interface here. Instead of There should be We can then easily implement deletion of relevant result cache entries with deleteByTag('SomeTag') which would read 'Doctrine_Result_Cache_Tag_SomeTag' to figure out which entries should be removed from the cache. I'm pretty sure my usage scenario is not marginal but let me know what you think. |
| Comment by Jonathan H. Wage [ 10/May/10 ] |
|
This is already possible if I understand what you describe. $q->useResultCache(true, 3600, 'key_to_store_cache_under');
Now you can do: $cacheDriver->delete('key_to_store_cache_under');
Also what you describe useTagResultCache() and keeping up with our own list of cache keys is the way it used to be and was changed to this after worse performance problems were discovered with that approach. |
| Comment by Amir W [ 10/May/10 ] |
|
Perhaps I've been misunderstood so I'll try explain from the start. In my system a few queries do relate to the same pieces of information. That information can be updated by a user and thus I would need to remove anywhere between 0 and 50 related result cache variables. I cannot easily name each and every one of my queries thus giving a specific key name doesn't help. So what I did was to prefix the name of each of the queries to indicate that I'll know how to remove them. I may have thousands of results cached and would need to clear just a few. That's why I use the deleteBy*() which proves to be extremely inefficient as it retrieves ALL the keys in my cache driver and not only the Doctrine related ones. I really don't know how it has been implemented before but what I suggest wouldn't hurt performance as tagging would be an optional addition managed with another variable. If you think that won't b useful to other Doctrine users, I'll simply implement it for my system. Thanks |
| Comment by Jonathan H. Wage [ 10/May/10 ] |
|
I think the best solution is the one you suggested earlier. That each cache driver should directly implement this functionality and bypass the creation of the array. What do you think? It is backwards compatible so that way we can commit it in 1.2. |
| Comment by Amir W [ 10/May/10 ] |
|
Bypassing the array is a required optimization which is easy to implement but it's not really a solution to the problem I'm facing and I believe is common enough (Zend_Cache for example implements tagging) and need to be offered. As it'll be 2 new functions that will implement tagging only when specifically requested, it'll also be backward compatible. The only thing I'm not sure about is if an implementation of some locking mechanism would be needed for the cached variable which would hold the list of cache keys for a specific tag. |
| Comment by Jonathan H. Wage [ 10/May/10 ] |
|
Let me know what you come up with and we'll have a look at including it in the next 1.2.x release. |
| Comment by Amir W [ 16/May/10 ] |
|
Bypassing the extra array is still not good enough and IMHO the whole idea of deleteBy() should NOT be used if many such requests could be made, as is my case. What I've done now is what I mentioned before with a patch that is quite ugly. In Doctrine/Query/Abstract.php right after the line $cacheDriver->save($hash, $cached, $this->getResultCacheLifeSpan());
I've added if (!empty($GLOBALS['rcache_users_in_query'])) {
MyCache::keepRelatedCacheKey($GLOBALS['rcache_users_in_query'], $hash);
}
Which saves another cache key which holds the hash tags that would have to be deleted on an update. When a user on my system does the update, I then delete all relevant Doctrine keys with something like if (is_null($cacheDriver)) $cacheDriver = Doctrine_Manager::getInstance()->getAttribute(Doctrine_Core::ATTR_RESULT_CACHE);
foreach($arKeys as $key) {
$cacheDriver->delete($key);
}
and then delete my other cache key. This solution works well for me. Sorry I cannot make a nice Doctrine patch for it as I'm not well versed with your code. I still believe it should be supported by Doctrine with an optional extra parameter for $q->useResultCache() Thanks |
| Comment by David Abdemoulaie [ 08/Jun/10 ] |
|
Hi Amir, Zend_Cache does not implement tagging for either APC or Memcached backends, see the documentation. It also likely never will, all requests for this functionality have been closed with Wont Fix. I don't think the deleteBy methods should have ever been implemented. When initially implemented they cached a "doctrine_cache_keys" variable to store the keys known to Doctrine. This however led to a crippling bug that would crash my production servers after a few hours. Not even a friendly "out of memory" limit, but a slowdown and eventual crash. Please see DDC-460 for details. Note that I don't use the magic delete methods, just simple saves with timeouts and this was affecting me. I fixed the solution as you've seen using the _getCacheKeys() method. I don't believe this functionality should have ever been added to Doctrine to begin with, but this is what we have to work with. It should be the responsibility of the cache store to handle tagging and such, not poorly hacked on with application code. As it stands, the current implementation doesn't affect people who aren't even using this functionality, as it should be. As Jon suggested, you shouldn't be using this in the context of a page request. Use a CLI script or work on another solution. Your idea of tracking your keys in application code is a good idea, but it doesn't belong in Doctrine imo. |
| Comment by Amir W [ 10/Jun/10 ] |
|
Thanks David for your comment. I agree with you that my implementation should not belong in Doctrine and that tagging should have been a part of the cache backends. Continuing with the same logic you've presented, deleteBy...() functionality **should be removed** from Doctrine if it causes the system to crash as it does so in an obnoxious way so that it would take too long for most developers to notice this is where the problem lies. It has certainly taken too much of my time and efforts and I'd rather save the pain from others. |
| Comment by Carsten Henkelmann [ 06/Jul/11 ] |
|
We had the exact same problem. We used a "deleteAll()" of a ApcCache object and ran into the "allowed memory size exhausted" pitfall. We helped ourselves with a new class that extends ApcCache and uses the simpler apc_clear_cache function.
namespace Foo\Cache;
class ApcCache extends \Doctrine\Common\Cache\ApcCache
{
/**
* Delete all cache entries. Memory saving version...
*
* @return bool
*/
public function deleteAll()
{
return apc_clear_cache('user');
}
}
use Foo\Cache\ApcCache as Apc; ... $this->_apc = new Apc(); $this->_apc->deleteAll(); This doesn't return the ids of the deleted entries like the original function but we don't need that. So this works fine for us. |
[DC-586] Doctrine outputs invalid SQL when using Limit and Order By conditions in MSSQL Created: 18/Mar/10 Updated: 18/Mar/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Connection |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Jose Prado | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows XP |
||
| Description |
|
I have a Doctrine model which connects to a MSSQL database. I was trying to run the following query: $q = Doctrine_Query::create()
->select('*')
->from('Comment c')
->innerJoin('c.RecordType')
->innerJoin('c.Department')
->limit(10)
->orderBy('c.Counter');
The code failed with a SQL Syntax exception so I took a look at the generated query and found the following (SELECT fields shortened for readabilty): SELECT * FROM ( SELECT TOP 10 * FROM ( SELECT TOP 10 [c].[counter] AS [c__counter], [c].[loanid] AS [c__loanid]... ... ... FROM comments c INNER JOIN [SystemTypes] [s] ON [c].[recordtype] = [s].[code] AND [s].[fieldname] = 'RecordType' INNER JOIN [SystemTypes] [s2] ON [c].[department] = [s2].[code] AND [s2].[fieldname] = 'Department' ORDER BY [c].[counter] ) AS [inner_tbl] ORDER BY [inner_tbl].[counter] AS [c__counter] DESC ) AS [outer_tbl] ORDER BY [outer_tbl].[counter] AS [c__counter] ASC As you can see, the ORDER BY clauses on the inner_tbl and outer_tbl segments have AS clauses which do not belong there. If you fix the ORDER BY statements the query runs just fine. So I decided to prod around the Mssql.php connection class and found the following: 140 public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false, $isSubQuery = false) 141 { ... 169 $field_array = explode(',', $fields_string); 170 $field_array = array_shift($field_array); 171 $aux2 = preg_split('/ as /', $field_array); 172 $aux2 = explode('.', end($aux2)); 173 174 $aliases[$i] = trim(end($aux2)); ... 232 } Line 171 seems to be in charge of setting up the orderBy aliases but it is looking for a lower case ' as ' string which doesn't exist in this SQL expression. Changing that to a case insensitive regular expression search seems to fix the problem: 171 $aux2 = preg_split('/ as /i', $field_array);
Here is the resulting SQL with the change: SELECT * FROM ( SELECT TOP 10 * FROM ( SELECT TOP 10 [c].[counter] AS [c__counter], [c].[loanid] AS [c__loanid]... ... ... FROM comments c INNER JOIN [SystemTypes] [s] ON [c].[recordtype] = [s].[code] AND [s].[fieldname] = 'RecordType' INNER JOIN [SystemTypes] [s2] ON [c].[department] = [s2].[code] AND [s2].[fieldname] = 'Department' ORDER BY [c].[counter] ) AS [inner_tbl] ORDER BY [inner_tbl].[c__counter] DESC ) AS [outer_tbl] ORDER BY [outer_tbl].[c__counter] ASC] This seems to fix the problem but I don't know if it'll create a regression. It's a start though. Anyone have any thoughts on this? |
[DC-515] HYDRATE_RECORD_HIERARCHY broken with many roots Created: 22/Feb/10 Updated: 09/Jun/10 |
|
| Status: | Reopened |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | 1.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Kamil Rojewski | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
DB schema: Category: Sample data: id: '1'
When using HYDRATE_RECORD_HIERARCHY, the first top-level category is empty. Everything is assigned to the other one. Only single-root trees work properly. |
| Comments |
| Comment by Kamil Rojewski [ 17/Mar/10 ] |
|
If you look at Doctrine_Collection::toHierarchy() you'll notice that there is NO reference to root_id, therefore it treats the entire collection as 1 tree (which is false). The bug is 100% repeatable. I've made a fast walkaround ba adding a multi-tree hydrator: class MultiRootHydrator extends Doctrine_Hydrator_RecordDriver { public function hydrateResultSet($stmt) { $result = parent::hydrateResultSet($stmt); $collection = array(); foreach ($result as $item) { if (!isset($collection[$item->root_id])) $collection[$item->root_id] = new Doctrine_Collection($result->getTable()); $collection[$item->root_id]->add($item); } $result = new Doctrine_Collection($result->getTable()); foreach ($collection as $tree) { $tree = $tree->toHierarchy(); $record = $tree->getFirst(); $result->add($record, $record->root_id); } return $result; } } It should clarify the problem. |
| Comment by Jonathan H. Wage [ 08/Jun/10 ] |
|
I think it was intended that you would only convert a single tree to a hierarchy. What would the structure of the returned data be like? |
| Comment by Kamil Rojewski [ 09/Jun/10 ] |
|
A Doctrine_Collection with root nodes seems to work fine. It allows to traverse the tree for each root. |
[DC-489] Doctrine_Record seems to have a bug with default values when updating Created: 10/Feb/10 Updated: 20/Jan/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Record |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Silver | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
PHP 5.2.11 |
||
| Description |
|
So lets see the table: User:
So lets say we have a user with `role` = 'support' and want to set em $user = new App_Model_User(); in debugger we see SQL query been made:
array(6) { ["id"]=> int(1) ["display_name"]=> string(13) "Administrator" ["username"]=> string(4) "root" ["password"]=> string(40) "45bb0f589525a2f0f2a48620bb59b1b8baef0c1d" ["role"]=> string(5) "admin" ["is_active"]=> bool(true) }Superb! Works as it should! So lets now set role of this user back to $user = new App_Model_User(); in debugger we didnot see any UPDATE queries! However object is been array(6) { ["id"]=> int(1) ["display_name"]=> string(13) "Administrator" ["username"]=> string(4) "root" ["password"]=> string(40) "45bb0f589525a2f0f2a48620bb59b1b8baef0c1d" ["role"]=> string(7) "support" ["is_active"]=> bool(true) }I cant overcome this problem right now, unfortunatelly (well I can However if I use Doctrine_Query of even $user = Doctrine_Core::getTable('App_Model_User')->find(1); instead of $user = new App_Model_User(); updates works well... |
| Comments |
| Comment by Petr Peller [ 20/Jan/11 ] |
|
I second this. When you UPDATE row with save() method of Record after setting identifier by assignIdentifier() doctrine removes columns updates from SQL which are set to default values same as it would do with INSERT. Other columns are updated correctly. This is sure a bug. You can workaround this by setting the value as NULL instead of the actual default value. (Which I wouldn't recommend). |
[DC-371] Lazy loading - doctrine makes extra queries into db Created: 19/Dec/09 Updated: 23/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Behaviors, Documentation, Query, Record |
| Affects Version/s: | 1.2.0-BETA3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Roman Drapeko | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Symfony 1.4, Doctrine Version: 1.2.0-BETA3 |
||
| Description |
|
Just downloaded symfony 1.4 First of all I have a query: $q = \Doctrine_Query::create() After that I'm accessing the fields of this object: $userArray = array( This is the actual queries into DB: NR1: NR2: As you can see there are TWO queries however there should be only one query. The problem is that u.user_real_id is NULL in database and when I do 'real_user_details_id' => $this->getUser()->getRealUserDetailsId() doctrine does not have enough intelligence to understand that these fields have been already requested in NR1. If I comment this field, everything works well. SURPRISE! As you understand this a very critical bug and of course our system won't go to production with this bug. P.S. Is it possible to turn off the lazy loading in doctrine? |
| Comments |
| Comment by Roman Drapeko [ 17/Jan/10 ] |
|
Any comments? Will it be fixed?? |
| Comment by Jonathan H. Wage [ 01/Mar/10 ] |
|
Hi, I'd like to take a look but can you make a failing test case that I can run so that I can see if I can come up with a patch that fixes your case and doesn't break anything else. |
| Comment by Luke Winiarski [ 01/Jun/10 ] |
|
Hi I had similar problem but after several hours i did work it out Try to make get method in your model for getting field which has NULL value in database public function getUserRealId() { return $this->_get("user_real_id", false); }by making second argument false u force doctrine not to lazy load value and extra sql query is not created regards |
| Comment by Jonathan H. Wage [ 08/Jun/10 ] |
|
Has anyone been able to reproduce this in a test case? I am not having much luck so far. |
| Comment by Gennady Feldman [ 23/Dec/10 ] |
|
I've seen this a ton of times. Basically when it loads related records through the Hydrator using leftJoin() and gets NULLs back. BUT it doesn't save the fact that the related records are NULL. So when you actually do call to getRelated objects it sees that it doesn't have the value cached and runs the query again. Let me know if I should show you the problem in the Doctrine code base. |
[DC-347] AddPendingJoinConditions doesn't work if alias equals model name Created: 09/Dec/09 Updated: 29/Jan/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Christian Jaentsch | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
If the alias in a from-query is equal to the model name, I get an exception when executing the query after adding a "pendingJoinCondition". See attached testCase. |
| Comments |
| Comment by David Abdemoulaie [ 29/Jan/10 ] |
|
I fail to see why you would use an alias that is equal to the model name. |
| Comment by Christian Jaentsch [ 29/Jan/10 ] |
|
To clarify again: Using an alias equal to the model name is the same as not using an alias at all. The built sql is the same afterwards (and the addPendingJoinCondition behaviour is the same as well). I would not use an alias equal to the model name myself, but sometimes this is used in Doctrine core, e.g. in Doctrine_Relation_ForeignKey around line 60. So to solve the problem either all the core queries, where no alias or an alias equal to the model name is used, have to be rewritten or the behaviour of a respective query has to be changed somehow so that applying an addPendingJoinCondition is possible even in the given case. |