[DC-1024] i am executing Created: 22/Jul/11 Updated: 26/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | cherukuri | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
$query = new Doctrine_Query(); $query->andWhere("s.company_id=".$parentId) |
[DC-954] tinyint(1) with default value in schema.yml generates blank default value, gives SQLSTATE[42000] Created: 09/Jan/11 Updated: 09/Jan/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Colin Stuart | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Win7 64-bit |
||
| Description |
|
doing a Foo: results in a blank value generated for the default keyword, and 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 ' PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ENGINE = INNODB' at line 1. Failing Query: "CREATE TABLE foo (id BIGINT AUTO_INCREMENT, bar tinyint(1) DEFAULT , PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ENGINE = INNODB". Failing Query: CREATE TABLE foo (id BIGINT AUTO_INCREMENT, bar tinyint(1) DEFAULT , PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ENGINE = INNODB I've also tried combinations of tinyint, tinyint(4), single-quoting the default value, and different default values. Changing the type to int makes the issue disappear |
[DC-1023] i am executing doctrine type query i am geting error please gave me reply my query i am typed in descrition field Created: 24/Jul/11 Updated: 26/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | cherukuri | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
$query = new Doctrine_Query(); |
[DC-1054] SQLSTATE[42S22]: Column not found: 1054 Unknown column 'b.title' in 'field list' Created: 31/Mar/12 Updated: 31/Mar/12 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | suriyakala | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
window vista |
||
| Description |
|
this is the my table creation . CREATE TABLE billboard(id BIGINT AUTO_INCREMENT,title VARCHAR (255),country_id BIGINT,zone_id BIGINT,place VARCHAR(255),occassion VARCHAR(255),itinerary VARCHAR(255),created_at DATETIME NOT NULL,description TEXT NOT NULL,PRIMARY KEY(id)) ENGINE=INNODB; public static function getInstance() { return Doctrine_Core::getTable('Billboard'); }this is the my Doctrine Table // public function getBillboardsForAUser($userId, $limit, $offset=0) $query->orderBy('b.created_at DESC') } plz help me what is the problem. |
| Comments |
| Comment by Benjamin Eberlei [ 31/Mar/12 ] |
|
Doctrine 1, not 2 ticket. |
[DC-388] Conservative loading not working Created: 26/Dec/09 Updated: 27/Jan/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Attributes |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Karma Dordrak (Drak) | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Apache 2, MySQL 5.1, PHP 5.2.9, Debian 5 |
||
| Description |
|
Apparently, when setting Doctrine::MODEL_LOADING_CONSERVATIVE things like Doctrine_Core::createTablesFromModels() don't work. Have to enable aggressive model loading. This has been confirmed on the doctrine-user mailing list. I took a brief look at the code: I may be missing something but it appears there may be a logic difference in the conservative vs. aggressive model loading method. Aggressive loading uses require_once on all files in the model directory and tries to determine the name of the class inside the file (by doing a difference on the loaded classes). This logic makes sense since the class and file name do not have to match. However, conservative loading just tries to calculate the class name and store it in an array for later loading by the autoloader. This means there is a huge logic difference in behaviour between these two loading methods since the model class files actually must differ depending on case (specifically, the model class file name must follow a specific format to match the actual class name) otherwise the autoload array will never know the correct name of the class. I would also like to comment that overall, require_once is a poor choice for performance reasons, it's vastly slower than include_once, but overall the logic should better be adjusted to use plain include (if possible), for performance reasons. |
[DC-344] Trouble with auto including generate Base class with specifik name Created: 09/Dec/09 Updated: 21/Mar/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Havelka Ondrej | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Environment: |
Linux, Ubuntu 9.04 64b |
||
| Description |
|
I have found a problem during testing example model on page http://www.doctrine-project.org/documentation/cookbook/1_1/en/code-igniter-and-doctrine . A use YAML model with object name UserGroup and call method Doctrine_Core::createTablesFromModels('models'); process faling with error: Fatal error: Class 'BaseUserGroup' not found in /sourcepath/models/UserGroup.php on line 13 Generate model file included abstract class BaseUserGroup exist and is OK. If I include BaseUserGroup manuly or rename object "UserGroup" on "UserGroups" everithing work fine. I thing here is a problem with autoloding base class with specifik name. Here is my code example: Doctrine_Core::dropDatabases(); Trouble shotting YAML model is: |
| Comments |
| Comment by Gustavo [ 26/Dec/09 ] |
|
Same problem here following the same example of the 1.2 tutorial. |
| Comment by Michal Olszewski [ 08/Feb/10 ] |
|
Hi, I've stumbled upon the same problem and I think I know where the issue is. So Doctrine_Core::createTablesFromModels() calls Doctrine_Export::exportSchema() which in turn calls Doctrine_Core::loadModels(). Doctrine_Core::loadModels() uses RecursiveIteratorIterator and iterates over all found files. Now I think the order of files returned by RecursiveIteratorIterator is not always the same (depends on OS, filenames and cosmic radiation if (0 !== stripos($className, 'Doctrine_') || class_exists($className, false) || interface_exists($className, false)) as base class is not starting with 'Doctrine_' and is not yet loaded. To fix it properly the algorithm for loading modules must be changed to first include 'modules/generated' classes and then rest of classes. I am not sure but maybe Core::autoload() might be changed to include base classes properly. QUICK WORKAROUND: Doctrine_Core::createTablesFromModels(array('models/generated','models')); as createTablesFromModels() can accept array of directories. Hope this helps you, please let me know if you need any more information. Thanks! |
| Comment by Svetoslav Shterev [ 09/Feb/10 ] |
|
You are missing the model autoloader(http://www.doctrine-project.org/upgrade/1_2#Models%20Autoloading), which was added in 1.2 That should fix the problem with conservative autoloading. |
| Comment by Michal Olszewski [ 09/Feb/10 ] |
|
I've tried registering modelsAutoload() and it works superb in this case for both aggressive and conservative loading. It is a shame that it is not mentioned in 1.2 PDF I've got - it'd make life easier for some people Thanks for your help. |
| Comment by blt [ 21/Mar/10 ] |
|
i am a new user to doctrine and i hit this brick wall. this bug report was all that saved me, and it is a bit misleading. my test results are below. in the end i found a combination that worked, but this seems like a glaring bug especially since the pdf takes the user right down a path that fails completely in all cases (default aggressive loading, doesn't work for me at all). i am using a pear loaded version 1.2 on ubuntu here are my test results: in test.php: --------------------------------------------------------------------------------------------------- in test.php: --------------------------------------------------------------------------------------------------- spl_autoload_register(array('Doctrine_Core', 'modelsAutoload')); in test.php: --------------------------------------------------------------------------------------------------- $manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE); in test.php: |
[DC-907] when I delete fields from a table in oracle 10g and I execute build schema keeps bringing me those same fields that no longer exist. Created: 28/Jul/10 Updated: 31/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | fernando guerrero | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I have a table in oracle that i was using but I had to change it so i remove some fields and add others when i run the task buils schema it generates the file schema.yml it created the new fields added but continued to bringing those field who had been eliminated and no longer existed in the database, it generates an error because the file schema.yml are those field but the database does not ... |
| Comments |
| Comment by Benjamin Eberlei [ 15/Sep/10 ] |
|
Is this a Doctrine 1 or 2 bug? Is this a caching issue maybe? |
[DC-926] Doctrine ignored PORTABILITY_FIX_CASE and ATTR_FIELD_CASE settings when building query Created: 12/Nov/10 Updated: 12/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Dziamid Zayankouski | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Tested on CentOS 5, Ubuntu 10.4, MYSQL and MSSQL databases |
||
| Description |
|
Setting: I expect column names in built queries to be uppercase, but they remain to be lowercase. |
[DC-972] MySQL field aliases with triple ticks Created: 16/Feb/11 Updated: 16/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Roland Huszti | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
MySQL 5, PHP 5 |
||
| Attachments: |
|
| Description |
|
In revision 7691 something has happened. Ever since I updated my Doctrine to that revision all my queries having " ... fieldname AS aliasname ... " go crazy and make the PHP to throw an exception, like this: 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.`id`' in 'field list'. Failing Query: The problem is that the DQL parser somewhere along the process encapsualtes aliases in ticks, but then it does it again in lib/Doctrine/Formatter.php : quoteIdentifier() , which is called in lib/Doctrine/Connection : quoteIdentifier() , which is called in lib/Doctrine/Query.php : processPendingFields() @ between lines 485 and 512. The problem is that by the time the alias name gets to line 507 it is already encapsualted in ticks, but it does it again. At the end we end up with ```alias``` , which is not good. It only happens to aliases. If I say select('*') or select("t.id, t.name") then it executes properly. Only the aliases couse problems. A test query: $vTerritories = Doctrine_Query::create() MY PROPOSED PATCH: If I change the Formatter::quoteIdentifier() to this: public function quoteIdentifier($str, $checkOption = true) { $tmp = $this->conn->identifier_quoting; // I move up this line to here because I need it if ( (substr($str, 0, 1) == $tmp['start']) && (substr($str, -1) == $tmp['end']) ) return $str; // new line; is it already quoted? if yes, then don't do it again // the rest is unchanged }then it works correctly. Please note I only tested that in MySQL, as we use MySQL in all our projects. |
[DC-665] Named parameters doesn't work on MSSQL anymore Created: 05/May/10 Updated: 22/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Dennis Pettersson | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows Server 2003. PHP 5.2.12. MS SQL Server 2008 |
||
| Description |
|
After upgrading to Doctrine 1.2.2 queries with named arguments doesn't work anymore. I get the error If changing the query to |
| Comments |
| Comment by Dennis Pettersson [ 06/May/10 ] |
|
Should mention I upgraded from 1.1.6 to 1.2.2, so the problem might be present in earlier 1.2.x versions as well. |
[DC-627] Work on link-table and leftJoin Created: 13/Apr/10 Updated: 13/Apr/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Thomas Tourlourat - Armetiz | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows Seven - WAMP 2.0i |
||
| Attachments: |
|
| Description |
|
Looking at the attachment to see the little schema. The link-table items_children is here to create a many-to-many relationships between Items and Children. So, after configure the YAML and generated Models.
The SQL Output of the query is :
All array are order by something, in this case it's a natural order which come from the items_children order into database. Now, I want to apply a condition, or a filter on the items_children table.
Or something crazy :
But how can I do that with DQL ? Because I have no access to the Link-table. Link-Table are use to create many-to-many, that could be OOP array. So we have to be allowed to add "index" to order the result. Also, we have to be allowed to add condition on this tables, like "datePromote" or simply "enabled". The solution should be on the following DQL Query :
But the SQL Output is :
To conclude, it's a blocker problem. Because I can't use a standard DB schema. Regards, |
[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-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. |
[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-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-930] Complex query with DISTINCT and LIMIT on pgsql causes a SQLSTATE exception - problem in doctrine_subquery_alias Created: 16/Nov/10 Updated: 16/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Jacek Dębowczyk | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
pgsql |
||
| Description |
|
There is a problem in the following code in Doctrine/Query.php (lines 1257-1279) inside the buildSqlQuery() method: $subquery = $this->getLimitSubquery(); // what about composite keys? $idColumnName = $table->getColumnName($table->getIdentifier()); switch (strtolower($this->_conn->getDriverName())) { case 'mysql': [...] case 'pgsql': $subqueryAlias = $this->_conn->quoteIdentifier('doctrine_subquery_alias'); // pgsql needs special nested LIMIT subquery $subquery = 'SELECT ' . $subqueryAlias . '.' . $this->_conn->quoteIdentifier($idColumnName) . ' FROM (' . $subquery . ') AS ' . $subqueryAlias; break; } The above code is executed when a query consist of DISTINCT and LIMIT clauses. The most common situation is using pager. SELECT doctrine_subquery_alias.id FROM ((SELECT DISTINCT d1.id, d2.id FROM ...)) AS doctrine_subquery_alias It, of course, causes the "ambiguous column name" pgsql exception. |
[DC-927] Query with left join and group clause returns only one row, even though there are multiple results Created: 14/Nov/10 Updated: 19/May/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Bart van den Burg | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 4 |
| Labels: | None | ||
| Environment: |
Windows 7-64 bit |
||
| Description |
|
under certain circumstances, Doctrine will only return one result out of a bunch of results, for example: $ symfony doctrine:dql "from Tafel t, t.Reservering r where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels, count(r.id) reserveringen group by date(t.tijd)" Expected outcome: The query works fine without the left join: |
| Comments |
| Comment by Bart van den Burg [ 14/Nov/10 ] |
|
As you can see, by the way, it does actually say "found 2 results", but then returns only one. |
| Comment by Willem van Duijn [ 08/Feb/11 ] |
|
There are multiple reports from people that are hurt by this bug: http://www.devcomments.com/doctrine-execute-only-returns-one-row-to286270.htm Setting the Hydration-mode to HYDRATE_NONE yields multiple result rows (but is not useful). |
| Comment by Victor Ruiz [ 18/Feb/11 ] |
|
Related in some way with multiple order by clauses. If I remove all of them but one it works, the problem appears when I put more than one order by criteria. |
| Comment by Mike Seth [ 19/May/11 ] |
|
This is a hydration problem that occurs because the ID columns of the joined tables are not SELECT'ed explicitly. The offending code is a loop in the graph base hydrator, but I don't understand it well enough to fix it with any certainty that I don't break anything. |
[DC-920] The ability to add sql in the query between the first word and body of the query (allowing "SELECT STRAIGHT_JOIN" etc) Created: 09/Nov/10 Updated: 09/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major |
| Reporter: | will ferrer | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
XP XAMP |
||
| Description |
|
I recently discovered that I could greatly optimize some of the queries that were being run through our system by adding a STRAIGHT_JOIN keyword to the front of the select I added a feature to doctrine which allows me to inject sql into the query in the right place to enable features such as "STRAIGHT_JOIN" but I can't post the patch because my patches are starting to run together – the syntax with in the generated patch would also contain parts of other patches I have posted to jira but have not yet been included in the doctrine svn. I still wanted to make this post because it will give me a ticket number to base my test cases around. Will Ferrer |
| Comments |
| Comment by will ferrer [ 09/Nov/10 ] |
|
In order to show what this patch fixes I am including my test case for the patch below: <?php /* * $Id$ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals * and is licensed under the LGPL. For more information, see * <http://www.doctrine-project.org>. */ /** * Doctrine_Ticket_DC920_TestCase * * @package Doctrine * @author Will Ferrer * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @category Object Relational Mapping * @link www.doctrine-project.org * @since 1.0 * @version $Revision$ */ class Doctrine_Ticket_DC920_TestCase extends Doctrine_UnitTestCase { public function testBeforeBodySelect() { $q = new Doctrine_Query(); $q->parseDqlQuery("SELECT DISTINCT STRAIGHT_JOIN u.name, p.id FROM User u LEFT JOIN u.Phonenumber p ON p.phonenumber = '123 123'"); $this->assertEqual($q->getSqlQuery(), "SELECT DISTINCT STRAIGHT_JOIN e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON (p.phonenumber = '123 123') WHERE (e.type = 0)"); $this->assertEqual($q->getDql(), "SELECT DISTINCT STRAIGHT_JOIN u.name, p.id FROM User u LEFT JOIN u.Phonenumber p ON p.phonenumber = '123 123'"); } public function testBeforeBodySelectNoneDQL() { $q = new Doctrine_Query(); $q->select("DISTINCT STRAIGHT_JOIN u.name, p.id"); $q->from('User u'); $q->leftJoin("u.Phonenumber p ON (p.phonenumber = '123 123')"); $this->assertEqual($q->getSqlQuery(), "SELECT DISTINCT STRAIGHT_JOIN e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON (p.phonenumber = '123 123') WHERE (e.type = 0)"); $this->assertEqual($q->getDql(), "SELECT DISTINCT STRAIGHT_JOIN u.name, p.id FROM User u LEFT JOIN u.Phonenumber p ON (p.phonenumber = '123 123')"); } public function testBeforeBodyDelete() { $q = new Doctrine_Query(); $q->parseDqlQuery('DELETE IGNORE FROM User'); $this->assertEqual($q->getSqlQuery(), 'DELETE IGNORE FROM entity WHERE (type = 0)'); $this->assertEqual($q->getDql(), "DELETE IGNORE FROM User"); } public function testBeforeBodyDeleteNoneDQL() { $q = new Doctrine_Query(); $q->delete('IGNORE'); $q->from('User'); $this->assertEqual($q->getSqlQuery(), 'DELETE IGNORE FROM entity WHERE (type = 0)'); $this->assertEqual($q->getDql(), "DELETE IGNORE FROM User"); } public function testBeforeBodyUpdate() { $q = new Doctrine_Query(); $q->parseDqlQuery("UPDATE IGNORE User u SET u.name = 'someone'"); $this->assertEqual($q->getSqlQuery(), "UPDATE IGNORE entity SET name = 'someone' WHERE (type = 0)"); $this->assertEqual($q->getDql(), "UPDATE IGNORE User u SET u.name = 'someone'"); } public function testBeforeBodyUpdateNonDql() { $q = new Doctrine_Query(); $q->update('IGNORE'); $q->from('User u'); $q->set('name', "'someone'"); $this->assertEqual($q->getSqlQuery(), "UPDATE IGNORE entity SET name = 'someone' WHERE (type = 0)"); $this->assertEqual($q->getDql(), "UPDATE IGNORE User u SET name = 'someone'"); } } |
[DC-916] fetchOne defect Created: 05/Nov/10 Updated: 24/Jan/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major |
| Reporter: | Roman | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Query fetchOne method now retrieves and hydrates all collection, which can be time consumable. I suggest to add limit 1 in fetchOne method. |
| Comments |
| Comment by Gennady Feldman [ 21/Jan/11 ] |
|
This is a defect. People assume there's an implied limit(1) in the query because of fetchOne(). Please fix this, this is pretty serious stuff. |
| Comment by Gennady Feldman [ 21/Jan/11 ] |
|
Doctrine_Table actually "works around" the issue but explicitly doing limit(1) before doing fetchOne(): public function findOneBy($fieldName, $value, $hydrationMode = null) { return $this->createQuery('dctrn_find') ->where($this->buildFindByWhere($fieldName), (array) $value) ->limit(1) ->fetchOne(array(), $hydrationMode); } |
| Comment by Jonathan H. Wage [ 23/Jan/11 ] |
|
Was this always like this or did it change recently? |
| Comment by Gennady Feldman [ 24/Jan/11 ] |
|
Frankly I have no idea. Also adding a limit(1) shouldn't break anything and is straight forward. We would also want to fix findOneBy not to do limit(1) since fetchOne() should take care of this after the fix is in place. |
[DC-914] Doctrine_Pager ignores custom COUNT query Created: 02/Nov/10 Updated: 07/Nov/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Pager |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Arnoldas Lukasevicius | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Zend Server CE |
||
| Description |
|
I found some problem when I tried to define custom query for results counting. Defined custom COUNT query is totally ignored and executed default one. I will give you full description of problem bellow. We have following source code: $q_select = Doctrine_Query::create () ->select ( 'DISTINCT p.product_name AS product_name' ) ->from ( 'Product p' ) ->where( 'p.product_name LIKE ?', '%motorola%'); $q_count = Doctrine_Query::create () ->select ( 'COUNT (DISTINCT p.product_name) num_results' ) ->from ( 'Product p' ) ->where( 'p.product_name LIKE ?', '%motorola%'); $pager = new Doctrine_Pager( $q_select, 1, 25 ); $pager->setCountQuery($q_count); Let's check custom query before calling $pager->execute() method: echo $pager->getCountQuery(); Output: SELECT COUNT (DISTINCT p.product_name) num_results FROM Product p WHERE p.product_name LIKE ? Looks like until now is everything is correct. Let's call $pager->execute() method: $products = $pager->execute(); Let's check executed queries using Symfony SQL queries log panel: SELECT COUNT(*) AS num_results FROM product p WHERE p.product_name LIKE '%motorola%' 7.27s, "doctrine" connection SELECT DISTINCT p.product_name AS p__0 FROM product p WHERE (p.product_name LIKE '%motorola%') LIMIT 25 3.25s, "doctrine" connection Executed COUNT query is not same we set using $pager->setCountQuery($q_count). Our defined custom COUNT query is totally ignored and executed default one: INSTEAD OF THIS CUSTOM COUNT QUERY: SELECT COUNT (DISTINCT p.product_name) num_results FROM Product p WHERE p.product_name LIKE '%motorola%' EXECUTED DEFAULT COUNT QUERY: SELECT COUNT(*) AS num_results FROM product p WHERE p.product_name LIKE '%motorola%' |
| Comments |
| Comment by Alex Cardoso [ 07/Nov/11 ] |
|
I found a possible solution to the problem. That occurs not because the Pager countQuery but in a method used inside the Query class. When you set the Query or CountQuery for Pager and execute it, it calls a Query method called count(). This method by yourself call another Query class method named Query::getCountSqlQuery(). This method rather than simply execute the query that you passed earlier, simply create a new query. Below is a possible solution to the problem: Query.php (Doctrine Stable 1.2.4)
--- Query.php 2011-11-07 20:52:48.000000000 -0200
+++ Query.php 2011-11-07 20:51:58.000000000 -0200
@@ -2049,40 +2049,7 @@
if (count($this->_queryComponents) == 1 && empty($having)) {
$q .= $from . $where . $groupby . $having;
} else {
-
- // Subselect fields will contain only the pk of root entity
- $ta = $this->_conn->quoteIdentifier($tableAlias);
-
- $map = $this->getRootDeclaration();
- $idColumnNames = $map['table']->getIdentifierColumnNames();
-
- $pkFields = $ta . '.' . implode(', ' . $ta . '.', $this->_conn->quoteMultipleIdentifier($idColumnNames));
-
- // We need to do some magic in select fields if the query contain anything in having clause
- $selectFields = $pkFields;
-
- if ( ! empty($having)) {
- // For each field defined in select clause
- foreach ($this->_sqlParts['select'] as $field) {
- // We only include aggregate expressions to count query
- // This is needed because HAVING clause will use field aliases
- if (strpos($field, '(') !== false) {
- $selectFields .= ', ' . $field;
- }
- }
- // Add having fields that got stripped out of select
- preg_match_all('/`[a-z0-9_]+`\.`[a-z0-9_]+`/i', $having, $matches, PREG_PATTERN_ORDER);
- if (count($matches[0]) > 0) {
- $selectFields .= ', ' . implode(', ', array_unique($matches[0]));
- }
- }
-
- // If we do not have a custom group by, apply the default one
- if (empty($groupby)) {
- $groupby = ' GROUP BY ' . $pkFields;
- }
-
- $q .= '(SELECT ' . $selectFields . ' FROM ' . $from . $where . $groupby . $having . ') '
+ $q .= '( '.$this->getSqlQuery().' ) '
. $this->_conn->quoteIdentifier('dctrn_count_query');
}
return $q;
|
[DC-910] Sub queries do not work properly in the on clause of a join Created: 01/Nov/10 Updated: 02/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | will ferrer | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
XP Xamp |
||
| Attachments: |
|
| Description |
|
When subqueries are used in the on part of a join clause the Doctrine_Query_JoinCondition class does not always create the proper sql. For instance when there are 2 subqueries used in a between doctrine tries to parse the statement as 1 subquery rather 2 subqueries with an "and". I will post my patch that fixes this issue after I make some test cases for it. I also fixed an issue where "(SQL:" syntax was breaking the join as well. Will |
| Comments |
| Comment by will ferrer [ 02/Nov/10 ] |
|
took out some commented code chunks |
[DC-897] Pager ignores default model hasMany ORDER BY statements, caused by getLimitSubquery ignoring same Created: 22/Oct/10 Updated: 10/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Pager |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Andrew Eross | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Our model configuration includes several hasMany statements, for example: $this->hasMany('Subcategory as Subcategories', array( We noticed that the ORDER BY directive worked just fine with a normal query, but the order by was being ignored when we fed it into the Pager. For example: $pager = new Doctrine_Pager($t, $currentPage, $resultsPerPage); var_dump($bb[4]); These two var_dumps would give different results because the ORDER BY is ignored by the limit subquery in the pager. |
| Comments |
| Comment by Andrew Eross [ 22/Oct/10 ] |
|
I've also found a fix for the issue (thanks to George over here for finding the location of the problem) ... we found that simply moving the ORDER BY generation code inside of buildSqlQuery() to be ABOVE the if block containing getLimitSubquery() resolves the issue. We're not super familiar with the Doctrine code-base, so everything looks to work fine after moving the code block, and it fixes the issue, but would love to hear if this is a real fix. diff from 1.2.3 via our SVN: Index: Query.php + } + // Add the default orderBy statements defined in the relationships and table classes else { + $orderBy = null; + }+ } + + } @@ -1307,47 +1346,8 @@ $q .= ' WHERE ' . $limitSubquerySql . $where;
Property changes on: Query.php
|
| Comment by Andrew Eross [ 22/Oct/10 ] |
|
Diff file |
| Comment by Andrew Eross [ 10/Nov/10 ] |
|
patch -p0 ./libs/doctrine/Doctrine/Query.php ./Doctrine_Query.php.ORDERBY.patch |
[DC-889] Using RANDOM() AS rand as last field WITHOUT a comma between them works, but not randomly Created: 14/Oct/10 Updated: 14/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Dennis Gearon | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
ubuntu 64 bit, using a task in symfony |
||
| Description |
|
The difference between the two code samples below is that there is a comma after 'lo.postal'_code in the second example: This code DOES NOT RANDOMIZE But also DOES NOT PRODUCE A PARSER ERROR This DOES |
[DC-877] Hydrator fatal error: Found non-unique key mapping named 'lang' Created: 30/Sep/10 Updated: 22/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Ilya Sabelnikov | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.2.13 |
||
| Attachments: |
|
| Description |
|
You could find the ticket's test case in the attachments. |
[DC-874] Allow parameters to be passed to Doctrine_Query::select() Created: 30/Sep/10 Updated: 23/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major |
| Reporter: | Gerry Vandermaesen | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Any |
||
| Description |
|
While I believe it's not so extraordinary to have parameters in a SELECT clause, Doctrine_Query::select() does not allow to pass parameters, next to the SELECT clause. You can still pass any parameters to execute(), but I do believe it would be nice to be able to pass the parameter values right away to select() as you can with where() etc. Example: Doctrine_Query::create() This principle would apply to any select-field that has a calculated value that comes from a parameter. |
| Comments |
| Comment by Piotr Leszczyński [ 23/Dec/10 ] |
|
I believe this should be major improvement for Doctrine. Without this feature, some queries can't be created. |
[DC-876] Basic Request return one element. Created: 30/Sep/10 Updated: 05/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | rudybruneau | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Windows XP Pro. Service Pack 3, Eclipe PDT, Doctrine 1.2.3, Php 5.2.11 |
||
| Attachments: |
|
| Description |
| Comments |
| Comment by Eirik Hoem [ 05/Oct/10 ] |
|
I have the same problem, and I think this is related to the select statement. It seems that a select statement where all fields are aliased will cause this behavior. A simple work-around is to select one field without aliasing it. Code for reproducing / work-around: $query = Doctrine_Query::create(); count($results) = 1 $query = Doctrine_Query::create(); count($results) = 250 |
[DC-873] Update Execute Params do not persist Created: 26/Sep/10 Updated: 26/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Kyle Clarke | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
LAMP php5.2.6 Symfony 1.4 |
||
| Description |
|
I have been trying to update numerous records with the one doctrine_query object (which could be my problem) and passing the query execute params to persist to the dbase. eg $q = Doctrine_Query::create() Then iterating over an array of values, passing the required values to the execute method eg I thought this the best way by creating only the one query instance and then assigning the vars as required. Trouble being, the data did not persist? I had no errors returned from Doctrine - eg I had the correct number of matched params - but the update would not update. To move on I ended up instantiating a new query object each time I iterated over my array of data values. eg foreach($foobars as $foobar) { $q = Doctrine_Query::create() $q->execute(); The values did then persist correctly to the dbase? Am I missing something really fundamental here? eg I would have thought the first code struct was a much better design to re-use the one query object. Or is it as silly as me not adding a hydration method to the execute method? Any all help appreciated. |
[DC-1010] When putting a subquery in the where clause which includes a join and a limit the limit subquery algorithm mistakenly modifies the subquery Created: 21/Jun/11 Updated: 21/Jun/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | will ferrer | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
XP Xamp |
||
| Description |
|
I have fixed this in my own version of doctrine but unfortunately I am to far diverged from the trunk to offer a patch. here is a test case: public function testSubqueryInWhereWithJoinAndLimit() { $q = new Doctrine_Query(); $q->select('u.id'); $q->from('User u'); $q->where('u.id NOT IN (SELECT a.id FROM User u2 LEFT JOIN u2.Album a LIMIT 1)'); $this->assertEqual($q->getSqlQuery(), 'SELECT e.id AS e__id FROM entity e WHERE (e.id NOT IN (SELECT a.id AS a__id FROM entity e2 LEFT JOIN album a ON e2.id = a.user_id WHERE (e2.type = 0) LIMIT 1) AND (e.type = 0))'); } To fix the issue I changed this line in Doctrine_Query as follows: if ( ( ! empty($this->_sqlParts['limit']) || ! empty($this->_sqlParts['offset'])) && $needsSubQuery && $limitSubquery) { = if ( ( ! empty($this->_sqlParts['limit']) || ! empty($this->_sqlParts['offset'])) && $needsSubQuery && $limitSubquery && !$this->isSubquery()) { Hope that helps. Sincerely Will Ferrer |
[DC-1008] missing oci_type in Doctrine_Adapter_Statement_Oracle->bindParam Created: 31/May/11 Updated: 31/May/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Tomasz Madeyski | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
in bindParam method there is: After adding SQLT_INT everything is ok |
[DC-1000] Wrong parsing on HAVING clause Created: 28/Apr/11 Updated: 28/Apr/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Pierrot Evrard | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
symfony 1.4.12-DEV / Windows XP / Apache 2.0 / MySQL 5.1.37 / PHP 5.3.0 |
||
| Attachments: |
|
| Description |
|
With Doctrine::ATTR_QUOTE_IDENTIFIER enabled, when you launch a query with a complex having clause, Doctrine_Query_Having class does not handle it correctly. By example, when you track the having clause interpretation: $query->addHaving( 'SUM( IF( s.id = ? , 1 , 0 ) ) = 0' , 7 ); At some point, Doctrine_Query_Having at line 70 return something like "`s10`.`id = ?`" instead of "`s10`.`id` = ?". I just fix it using: return $this->query->parseClause($func); instead of: return $this->_parseAliases($func); Now, the parseAliases function is not used anymore... See patch attached... Loops |
[DC-997] Doctrine collections are overwritten when created by inner join queries that agree on the WHERE Created: 13/Apr/11 Updated: 13/Apr/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Richard Forster | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
OS X 10.6.6 with PHP 5.3.3, Windows with PHP 5.3.1 |
||
| Attachments: |
|
| Description |
|
In brief: In detail: INSERT INTO `tblname` VALUES (1,1,'alpha'),(2,2,'beta'),(3,3,'gamma'),(4,4,'delta'),(5,5,'epsilon'),(6,1,'aleph'); Applying the query: $results1 = Doctrine_Query::create() and then producing output though print 'Results (1): '.count($results1)."\n"; produces the expected: Results (1): 1 Doing a similarly query to a new variable: $results2 = Doctrine_Query::create() and printing with print 'Results (2): '.count($results2)."\n"; produces the expected: Results (2): 1 but printing out the first result object again at this point gives: Results (1): 1 which is unexpected - "aleph" rather than "alpha". If, the second query was altered to ->where('ppa.id = ?', 2) then all three output results are as expected. test.zip contains corresponding test files. |
[DC-996] UPDATE query generate ambiguous statement Created: 13/Apr/11 Updated: 13/Apr/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | John | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
MAMP on MacBook Pro 10.6.7, with Symfony 1.4.9 |
||
| Description |
|
When creating an UPDATE query, the table names are not aliased like in a SELECT statement. This causes ambiguous column names when JOINING in an UPDATE. E.g. The generated SQL for this is : Clearly here "updated_at" and "id" are ambiguous columns. Why the tables are not automatically aliased with unique aliases like in a SELECT statement, and the aliases written before the column name ? Thanks. |
[DC-973] Statements with empty results are not correctly closed Created: 17/Feb/11 Updated: 17/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Miloslav "adrive" Kmet | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Statements that return no result are not correctly closed in Doctrine_Hydrator_Graph::hydrateResultSet(). Oracle has limited number of opened cursors, and this bug prevents unsing doctrine in batch task like indexing models with sfSolrPlugin. Oracle throws an error `ORA-01000: maximum open cursors exceeded : ` in my case after indexing only 100 records. I'll send a pull request via github for this issue. |
[DC-967] Problems with fetchArray() combined with leftJoin() by using aliases of columns Created: 13/Feb/11 Updated: 13/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Record |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Arnoldas Lukasevicius | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Symfony Framework v1.3.8, Windows 7 |
||
| Description |
|
They are some strange problems with hydration to array combined with aliases of columns and JOINS. Let's see this example: $q = Doctrine_Query::create ()
->select('c.id AS id, c.path AS path, c.name AS name, cbc.product_count')
->from('Category c')
->leftJoin('c.CategoryBrowserCache cbc');
$categories = $q->fetchArray();
This example will throw exception: "The root class of the query (alias lc) must have at least one field selected." OK. Let's change code a little bit. Let's add alias for cbc.product_count column too: $q = Doctrine_Query::create ()
->select('c.id AS id, c.path AS path, c.name AS name, cbc.product_count AS product_count')
->from('Category c')
->leftJoin('c.CategoryBrowserCache cbc');
$categories = $q->fetchArray();
print_r($categories);
Now code executed without exception, BUT $q->fetchArray() returned only ONE (first) record hydrated to array. Other results were ignored. Let's change code one more time: $q = Doctrine_Query::create ()
->select('c.id, c.path, c.name, cbc.product_count AS product_count')
->from('Category c')
->leftJoin('c.CategoryBrowserCache cbc');
$categories = $q->fetchArray();
print_r($categories);
Like you see I just removed all aliases for columns for Category. Now code will be executed without exceptions, All results will be hydrated into array as expected to be. Actually the same result can be reached by removing at least one alias for any Category column. |
[DC-944] Precedence problem in SQL generation allows bypass of pending joins Created: 03/Dec/10 Updated: 10/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | 1.2.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Walter Hop | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.2, 5.3 |
||
| Attachments: |
|
| Description |
|
'Pending join conditions' are used by listeners to inject extra SQL conditions into a query. They are often used to add basic constraints on every query. An example is the bundled SoftDelete template. Its listener adds extra constraints such as s.deleted_at IS NULL to a query, to make sure that deleted rows are never retrieved on a query. However, in the emitted SQL, Doctrine_Query does not use parentheses to group normal SQL conditions together. The pending join condition is simply added to the string without encapsulating existing expressions. This makes it possible to bypass the pending join conditions entirely by using the OR operator. Example For instance, the following query exhibits this problem:
This query emits the following SQL:
which returns also a deleted row. Expected behavior One would expect the pending join conditions always to hold, and to have precedence over regularly added SQL conditions. This could be accomplished in the most simple fashion by:
As the existing expressions are now encapsulated by parentheses, it is no longer possible to bypass the pending join conditions injected by the query listener. Full test case details: init.sql create database softdelete;
grant all privileges on softdelete.* to softdelete@localhost identified by 'uahwqeruwer';
use softdelete;
CREATE TABLE soft_delete_test (name VARCHAR(255),
deleted_at DATETIME DEFAULT NULL,
PRIMARY KEY(name)) ENGINE = INNODB;
insert into soft_delete_test values ('fine', null);
insert into soft_delete_test values ('faulty', now());
run.php <?php
require "./1.2.3/lib/Doctrine.php";
spl_autoload_register(array('Doctrine', 'autoload'));
require "SoftDeleteTest.php";
$conn = Doctrine_Manager::connection("mysql://softdelete:uahwqeruwer@localhost/softdelete");
$conn->setAttribute(Doctrine::ATTR_USE_DQL_CALLBACKS, true);
$query = Doctrine_Query::create()
->from("SoftDeleteTest")
->where("name=?", "faulty")
->orWhere("name=?", "faulty");
$found = $query->execute();
foreach ($found as $f) {
echo "ERROR! Found a deleted row: $f->name\n";
}
echo "Done.\n";
SoftDeleteTest.php (copied from Doctrine manual) <?php
class SoftDeleteTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null, array(
'primary' => true
)
);
}
public function setUp()
{
$this->actAs('SoftDelete');
}
}
|
| Comments |
| Comment by Walter Hop [ 03/Dec/10 ] |
|
Fixing quote formatting |
| Comment by Walter Hop [ 03/Dec/10 ] |
|
Final formatting fixes. |
[DC-937] Cross Schema stored procedures are not recognized Created: 22/Nov/10 Updated: 08/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | will ferrer | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
XP Xamp |
||
| Attachments: |
|
| Description |
|
When you call a stored procedure from a schema other than that of the current connection: [schema_name].[stored_procedure_name]([stored_procedure_arguments]) doctrine miss understands the string and throws a "Couldn't get short alias for" exception. I fixed this by adding some more regex to the getExpressionOwner method of the Query Class. I will post the patch shortly. Will Ferrer |
| Comments |
| Comment by will ferrer [ 08/Dec/10 ] |
|
Fixed an issue where the code wouldn't work with calls to stored procedure that were nestted in groups in selects. |
[DC-1041] Using ->limit() in conjunction with many-to-many with mysql generates wrong SQL Created: 30/Nov/11 Updated: 30/Nov/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Evgeniy Afonichev | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
mysql |
||
| Description |
|
Using ->limit() in conjunction with many-to-many relationships with mysql leads to strange SQL generated. The condition id IS NULL is added in such case which is not correct at all. Here's example schema User:
columns:
username: { type: string(255) }
relations:
Operators:
foreignAlias: Users
class: Operator
refClass: OperatorUser
Operator:
columns:
username: { type: string(255) }
type: { type: integer }
OperatorUser:
columns:
user_id: { type: integer }
operator_id: { type: integer }
relations:
Operator:
foreignAlias: OperatorUser
User:
foreignAlias: OperatorUser
And here's query which generates wrong SQL Doctrine_Core::getTable('User')
->createQuery('User')
->leftJoin('User.Operators Operator')
->addWhere('Operator.type = ?', 1)
->limit(10)
->offset(0)
->execute()
;
Expected SQL generated: SELECT u.id AS u__id, u.username AS u__username, o.id AS o__id, o.username AS o__username, o.type AS o__type FROM user u LEFT JOIN operator_user o2 ON (u.id = o2.user_id) LEFT JOIN operator o ON o.id = o2.operator_id WHERE (o.type = '1') LIMIT 10 Actual SQL generated: SELECT u.id AS u__id, u.username AS u__username, o.id AS o__id, o.username AS o__username, o.type AS o__type FROM user u LEFT JOIN operator_user o2 ON (u.id = o2.user_id) LEFT JOIN operator o ON o.id = o2.operator_id WHERE u.id IS NULL # is not expected AND (o.type = '1') # there's no LIMIT clause Seems like here's code which causes the bug https://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Query.php#L1307 |
[DC-1055] Bug in select query when executed against postgreSQL Created: 25/May/12 Updated: 25/May/12 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Damian Bergantinnos | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
symfony-1.4.17 php 5.3.5 apache 2.2.17 WIndows xp/7 PostgreSQL 9.1.2 |
||
| Attachments: |
|
| Description |
|
In the attached Squema run this query against postgreSQL. $lang = 'en'; SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "en" |
[DC-451] preDql events on connection & manager level Created: 25/Jan/10 Updated: 25/Jan/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major |
| Reporter: | Sune Kibsgaard Pedersen | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I think it would be very helpful if the preDql events also worked on connection and manager level. If it is anyway possible. attach a record listener to a connection object, and it should also call the preDql events when doing DQL queries. |
[DC-424] using boolean logic in select don't work Created: 14/Jan/10 Updated: 27/Jan/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.1.6, 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Ivo Võsa | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Continuing with same setup as in http://www.doctrine-project.org/jira/browse/DC-417 $result = Doctrine_Query::create()
->select('u.*, m.*, COUNT(m.id) > 0 AS match_check')
->from('User u')
->leftJoin('u.Matches m')
->groupBy('u.id')
->orderBy('match_check DESC, RAND()')
->execute(array(), Doctrine::HYDRATE_ARRAY);
match_check will actually be count of matches not 0 or 1 as i expected. |
| Comments |
| Comment by Guilherme Blanco [ 14/Jan/10 ] |
|
SelectExpressions cannot contain ComparisonExpressions. That's a limitation of Doctrine 1, which was resolved in Doctrine 2. Cheers, |
| Comment by Josh Boyd [ 27/Jan/10 ] |
|
Something like this will work: $result = Doctrine_Query::create()
->select('u.*, m.*)
->addSelect("QUOTE(IF(COUNT(m.id) > 0),1,0)) match_check')
->from('User u')
->leftJoin('u.Matches m')
->groupBy('u.id')
->orderBy('match_check DESC, RAND()')
->execute(array(), Doctrine::HYDRATE_ARRAY);
|
[DC-402] aliased fields from root class are not recognized als root class fields, if they're the only one Created: 06/Jan/10 Updated: 06/Jan/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Christian Michel | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
If all selected fields from the root class are aliased, In my real world example, this could only be fixed, using the primary key of the root class/table in select |
[DC-401] Doctrine_Query->load crashes with additional ending whitespace in JOIN Created: 06/Jan/10 Updated: 06/Jan/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Christian Michel | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
following will lead to an error: ->leftJoin('alias.RelatedTable alias2 WITH .....') The problem is the additional whitespace behind alias2. $tmp = explode(' ', $path); will create an array of 3 elements where the last one is empty but will be used as empty alias mapping after foreach from line 1698. |
[DC-386] Doctrine_Hydrator_ArrayDriver may segfault Php when loaded by Zend Framework Autoloader Created: 24/Dec/09 Updated: 24/Dec/09 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Michael Gatto | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 9.04 fully updated with Apache 2.2.11, Php 5.2.6, Zend Framework 1.9.6, Doctrine 1.2.1 |
||
| Attachments: |
|
| Description |
|
Apache and Php segfault with no error information in the logs and a white screen of death when I use Doctrine 1.2.1 in a Zend Framework controller. I've traced the problem to line 126 of Zend/Loader/Autoloader.php which only seemed to occur when it autoloaded Doctrine_Hydrator_ArrayDriver during a call to save() in the controller. I debugged with xdebug and have attached a simple test controller with no other code. The ZF page works fine when all Doctrine is commented out and a Doctrine test page with the same code but outside of ZF worked fine via Apache as did a CLI script. Workaround is to not push Doctrine to Zend Loader in the bootstrap. Here is the debug output just before a segfault, the stack and the variable values: Remote Launch (stepping) : lineno 26 = $class Doctrine_Hydrator_ArrayDriver |
[DC-387] mssql fails on find($key) Created: 25/Dec/09 Updated: 05/Jan/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | zerkms | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Doctrine_Core::getTable('Project')->find($id) |
| Comments |
| Comment by Michael Card [ 05/Jan/10 ] |
|
Close as duplicate of |
[DC-353] Doctrine_Query can't map a main query colum inside a subquery with join Created: 10/Dec/09 Updated: 10/Dec/09 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.0.12, 1.0.14 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Arian Maykon de Araújo Diógenes | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Apache 2.2.13, PHP 5.3, Fedora 11 or Ubuntu 9.04 (and Symfony 1.2.9/1.2.10 with Doctrine 1.0.12/1.0.14) |
||
| Description |
|
If i have the following schema: Medidor:
tableName: TBLMEDIDOR
columns:
CODIGO:
name: NRCODIGO as codigo
type: integer(10)
primary: true
sequence: SEQMEDCODIGO
DESCRICAO:
name: TXDESCRICAO as descricao
type: string(1000)
notnull: true
AnaliseMedidor:
tableName: TBLANALISE_MEDIDOR
columns:
CODIGO:
name: NRCODIGO as codigo
type: integer(10)
primary: true
sequence: SEQANMCODIGO
DATA:
name: DTDATA as dataAnalise
type: date
notnull: true
MEDIDOR:
name: FKMEDCODIGO as medidor_codigo
type: integer(10)
notnull: true
OBSERVACAO:
name: TXOBSERVACAO as observacao
type: string(1000)
relations:
Medidor: { local: medidor_codigo, foreign: codigo, foreignAlias: Analises }
and execute the following query: $query = Doctrine::getTable('Medidor')->createQuery()
->innerJoin('m.Analises a')
->where('a.dataAnalise = (SELECT MAX(a2.dataAnalise) FROM '
. 'AnaliseMedidor a2 WHERE a2.medidor_codigo = a.medidor_codigo)');
the "a.medidor_codigo" in the subquery don't get correctly mapped. So Doctrine tells me: {sfDoctrineLogger} executeQuery : SELECT t.nr80102codigo AS t__nr80102codigo, t.tx80102descricao AS t__tx80102descricao FROM TBL80102MEDIDOR t INNER JOIN TBL80103ANALISE_MEDIDOR t2 ON t.nr80102codigo = t2.fk80102codigo WHERE t2.dt80103data = (SELECT MAX(t3.dt80103data) AS t3__0 FROM TBL80103ANALISE_MEDIDOR t3 WHERE t3.fk80102codigo = t2.medidor_codigo)
{Doctrine_Connection_Oracle_Exception} SQLSTATE[HY000]: General error: 904 OCIStmtExecute: ORA-00904: "T2"."MEDIDOR_CODIGO": invalid identifier
(/root/PDO_OCI-1.0/oci_statement.c:142)
If i put the real name column it runs ok: $query = Doctrine::getTable('Medidor')->createQuery()
->innerJoin('m.Analises a')
->where('a.dataAnalise = (SELECT MAX(a2.dataAnalise) FROM '
. 'AnaliseMedidor a2 WHERE a2.medidor_codigo = a.FKMEDCODIGO)');
But, this should not be done, right? In Doctrine 1.2 it works fine. But in the related versions don't. |
| Comments |
| Comment by Arian Maykon de Araújo Diógenes [ 10/Dec/09 ] |
|
Haven't added a TestCase because Doctrine 1.0.14 don't have them yet! |
[DC-335] Oracle identifier too long in normal SELECT when using longer table name or column Created: 07/Dec/09 Updated: 13/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Miloslav "adrive" Kmet | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Oracle |
||
| Description |
|
Unfortunatelly oracle has max identifier length for 30 characters. When using longer model names eg. misCompanyContributor with column names the generated aliases for selected columns mix tableized modelname with colum name joined by two __, and sometimes the generated alias should exceed the allowed 30 characters long identifiers, and oracle complains with: {{ An example of large select with alias: |
| Comments |
| Comment by Michel D'HOOGE [ 13/Oct/10 ] |
|
A workaround is available in |
| Comment by Michel D'HOOGE [ 13/Oct/10 ] |
|
I have applied the following patch to use aliases of identifiers (what is after the "as" when defining field name). So far, it seems to work... But I am quite sure I didn't take all possible cases into consideration. --- lib/vendor/doctrine/Doctrine/Hydrator/Graph.php.orig 2010-10-07 19:09:10.000000000 +0200
+++ lib/vendor/doctrine/Doctrine/Hydrator/Graph.php 2010-10-14 00:08:05.000000000 +0200
@@ -298,10 +298,10 @@
}
$e = explode('__', $key);
- $last = strtolower(array_pop($e));
+ $fieldName = strtolower(array_pop($e));
$cache[$key]['dqlAlias'] = $this->_tableAliases[strtolower(implode('__', $e))];
$table = $this->_queryComponents[$cache[$key]['dqlAlias']]['table'];
- $fieldName = $table->getFieldName($last);
+ $last = $table->getColumnName($fieldName);
$cache[$key]['fieldName'] = $fieldName;
if ($table->isIdentifier($fieldName)) {
$cache[$key]['isIdentifier'] = true;
--- lib/vendor/doctrine/Doctrine/Query.php.orig 2010-10-07 19:09:10.000000000 +0200
+++ lib/vendor/doctrine/Doctrine/Query.php 2010-10-14 00:03:28.000000000 +0200
@@ -494,12 +494,12 @@
$parentAlias = $this->getSqlTableAlias($componentAlias . '.' . $parent->getComponentName());
$sql[] = $this->_conn->quoteIdentifier($parentAlias) . '.' . $this->_conn->quoteIdentifier($columnName)
. ' AS '
- . $this->_conn->quoteIdentifier($tableAlias . '__' . $columnName);
+ . $this->_conn->quoteIdentifier($tableAlias . '__' . $fieldName);
} else {
- $columnName = $table->getColumnName($fieldName);
+ $columnName = $table->getColumnName($fieldName); // Really needed?
$sql[] = $this->_conn->quoteIdentifier($tableAlias) . '.' . $this->_conn->quoteIdentifier($columnName)
. ' AS '
- . $this->_conn->quoteIdentifier($tableAlias . '__' . $columnName);
+ . $this->_conn->quoteIdentifier($tableAlias . '__' . $fieldName);
}
}
@@ -554,7 +554,7 @@
return $this->_conn->quoteIdentifier($tableAlias . '.' . $name)
. ' AS '
- . $this->_conn->quoteIdentifier($tableAlias . '__' . $name);
+ . $this->_conn->quoteIdentifier($tableAlias . '__' . $field);
}
}
|
[DC-331] Wrong SQL output from Doctrine_Expression for pgsql with timestamp with time zone field Created: 06/Dec/09 Updated: 05/Jan/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.0-RC1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Dennis Gearon | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
This is with Symfony 1.3 alpha (which is pretty good) Can't tell you which Doctrine it comes with |
||
| Description |
|
(1) pgsql connection What I'd like to get access to using that Doctrine construct is the Fortunately, all the databases that I want to use implement |
| Comments |
| Comment by Michael Pearson [ 05/Jan/10 ] |
|
I'm also seeing this with Symfony 1.4.1 (w/Doctrine 1.2). Affects timestampable tables (created_at, updated_at). also, NOW() AT TIME ZONE 'UTC' translates to LOCALTIMESTAMP(0) AT TIME ZONE 'UTC' (via buildSqlQuery). |
[DC-312] Doctrine_Pager query "influences" Doctrine::getTable() query Created: 02/Dec/09 Updated: 02/Dec/09 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Pager |
| Affects Version/s: | 1.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Jan Matousek | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Debian testing squeeze 32 bit. |
||
| Description |
|
When I use the same procedure without Doctrine_Pager everything works fine, with Doctrine_Pager the behavior of later queries is strange. Example: 2. I fetch a row to edit independently on the list above 3. edit properties of the object... 4. $object->replace(); ----------------BROKEN: 2. I fetch a row to edit independently on the list above (in contrast to the first working example this $object is fetched with EMPTY RELATION OBJECTS, which causes inserting empty new rows when calling ->replace()) 3. edit properties of the object... 4. $object->replace(); I've been using Doctrine for I guess 2 years now and I believe this bug/strange behavior has always been there. |
[DC-188] Pager breaks when HAVING clause references existing table column Created: 04/Nov/09 Updated: 20/Jul/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Pager |
| Affects Version/s: | 1.1.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Benedict Bacayon | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Local: Windows/Cygwin/XAMPP |
||
| Description |
|
Pager breaks when HAVING clause references any existing table column. Query used: $q = Doctrine_Query::create() Execution of query by itself works fine (eg via execute(), fetch...) When putting this query in a Doctrine_Pager, error outputs: $pager = new Doctrine_Pager( $pager->execute(); Error Received: |
| Comments |
| Comment by ryan [ 20/Jul/10 ] |
|
a quick fix for this is to enclose the field in parentheses when selecting it, then use an alias to reference it inside the having clause. eg $q = Doctrine_Query::create() |
[DC-49] Wrong query parameter order when using limit() on PostgreSQL Created: 22/Sep/09 Updated: 26/Jul/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.1.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Nicholas Kasyanov | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
latest doctrine 1.1 revision, linux x64, PostgeSQL 8.4, php 5.2.10 |
||
| Attachments: |
|
| Description |
|
Trying to add limit() to complex query with many where's and some joins. In pgsql it causes nested limit subquery and in some cases parameter order (when limit subquery exists params array just merges with itself, i. e. (1,2) becomes (1,2,1,2)) makes result query wrong, i. e. params array order doesn't correspond placeholders order in query. With named query parameters all ok. Testcase attached. |
| Comments |
| Comment by Jonathan H. Wage [ 24/Sep/09 ] |
|
here is the working test case: class Doctrine_Ticket_DC49_TestCase extends Doctrine_UnitTestCase { public static $query; public static $params; public function init() { $this->dbh = new Doctrine_Adapter_Mock('pgsql'); $this->conn = Doctrine_Manager::getInstance()->openConnection($this->dbh); $this->conn->addListener(new PPB_QueryListener()); } public function prepareTables() { $this->tables = array('PPB_Section', 'PPB_Post', 'PPB_PostVote'); parent::prepareTables(); } public function testBug() { $q = Doctrine_Query::create()->from('PPB_Post p') ->where('p.section_id = ?', 1) ->addWhere('p.id = ?', 15) ->leftJoin('p.Votes v WITH v.user_id = ?', 10) ->limit(10); $q->execute(); $this->assertEqual(self::$query, "SELECT p.id AS p__id, p.section_id AS p__section_id, p2.id AS p2__id, p2.post_id AS p2__post_id, p2.user_id AS p2__user_id FROM p_p_b__post p LEFT JOIN p_p_b__post_vote p2 ON p.id = p2.post_id AND (p2.user_id = ?) WHERE p.id IN (SELECT doctrine_subquery_alias.id FROM (SELECT DISTINCT p3.id FROM p_p_b__post p3 LEFT JOIN p_p_b__post_vote p4 ON p3.id = p4.post_id AND (p4.user_id = ?) WHERE p3.section_id = ? AND p3.id = ? LIMIT 10) AS doctrine_subquery_alias) AND (p.section_id = ? AND p.id = ?)"); $this->assertEqual(implode(",", self::$params), '10,10,1,15,1,15'); // correct order of params } } class PPB_Post extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('section_id', 'integer'); } public function setUp() { $this->hasOne('PPB_Section', array('local' => 'section_id', 'foreign' => 'id')); $this->hasMany('PPB_PostVote as Votes', array('local' => 'id', 'foreign' => 'post_id')); } } class PPB_Section extends Doctrine_Record { public function setTableDefinition() { } } class PPB_PostVote extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('post_id', 'integer'); $this->hasColumn('user_id', 'integer'); } } class PPB_QueryListener extends Doctrine_EventListener { public function postStmtExecute(Doctrine_Event $event) { //var_dump($event->getQuery()); //var_dump($event->getParams()); Doctrine_Ticket_DC49_TestCase::$query = $event->getQuery(); Doctrine_Ticket_DC49_TestCase::$params = $event->getParams(); } } |
| Comment by Daniel Bojdo [ 26/Jul/10 ] |
|
I fixed this bug. Patch in attachment. I hope it's clear enough. |
[DC-692] Can not create a subquery in where Created: 18/May/10 Updated: 19/May/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | will ferrer | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
XP Xamp |
||
| Description |
|
Hi All I can not figure out how to make a subquery work in doctrine. I get the subquery to look fine in DQL but when doctrine converts the DQL to SQL the subquery is automatically removed. Here is an example: $q = Doctrine_Query::create();
$q->from('Customer Customer');
$q->addWhere(' Customer.id in (SELECT Customer.id as customer_id FROM Customer Customer)');
$q->addSelect('Customer.id');
$q->addSelect('Customer.id as customer_id');
$q->limit(20);
Creates this DQL: SELECT Customer.id, Customer.id as customer_id FROM Customer Customer WHERE Customer.id in (SELECT Customer.id as customer_id FROM Customer Customer) LIMIT 20 Which creates this broken SQL: SELECT p.id AS p__id, p.id AS p__0 FROM product_customers p WHERE (p.id in ()) LIMIT 20 Notice that the subquery has been replaced with just "()". Is there something wrong with my execution, does doctrine just not support subqueries, or is there a bug here? Thanks much in advance. Sincerely Will Ferrer |
| Comments |
| Comment by will ferrer [ 19/May/10 ] |
|
I have found a way around my problem (looked through the code to figure out how it worked) – seems that if I put 'SQL:' in front of my sub query, and use SQL instead of DQL in the sub query like so: $q = Doctrine_Query::create();
$q->from('Customer Customer');
$q->addWhere(' Customer.id in (SQL:SELECT p.id AS p__0 FROM product_customers p)');
$q->addSelect('Customer.id');
$q->addSelect('Customer.id as customer_id');
The correct sql is made: SELECT p.id AS p__id, p.id AS p__0 FROM product_customers p WHERE (p.id in (SELECT p.id AS p__0 FROM product_customers p)) LIMIT 20 I am not still not sure what is up with trying to use the DQL instead. Looking through the code I see that on line 842 of Doctrine_Query my DQL subquery was being passed to the function $this->createSubquery()->parseDqlQuery($trimmed) like so: $q = $this->createSubquery()->parseDqlQuery($trimmed);
$trimmed = $q->getSqlQuery();
$trimmed was coming back as false here which is why my subquery wasn't working. Hope that is helpful. Best Regards Will Ferrer |
[DC-680] HYDRATE_ARRAY causes timeout with no fields selected Created: 13/May/10 Updated: 13/May/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1, 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | David Ash | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 7, Ubuntu 9.10 (Linux), PHP 5.2.10, Zend Framework 1.10 |
||
| Description |
|
Calling HYDRATE_ARRAY on a query with a) No values selected causes the entire query object to be loaded, rather than just returning an array of all values. If a limit(1) is used, the correct result is returned. But as soon as it becomes a collection, the entire query object is returned. Code to produce problem.. $query = Doctrine_Query::create()
->from('Order ord')
->limit(2)
->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
print_r($query);
|
[DC-651] [PATCH] Doctrine_Record::option('orderBy', ...) of join's right side being applied to refTable in m2m relationship Created: 26/Apr/10 Updated: 31/Aug/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query, Relations |
| Affects Version/s: | 1.2.2, 1.2.3 |
| Fix Version/s: | 1.2.2, 1.2.3, 1.2.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | suhock | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
CentOS 5.4 |
||
| Attachments: |
|
| Description |
|
When using the Doctrine_Record::option('orderBy', ...) feature on a table definition, where that table is the target of a many-to-many join, the specified orderBy columns are applied to the relation table's alias. So for example, given the following definitions: class User extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('uid', 'integer', null, array('primary' => true)); $this->option('orderBy', 'uid'); } public function setUp() { $this->hasMany('Group as groups', array('refClass' => 'UserGroup', 'local' => 'user_uid', 'foreign' => 'group_id')); } } class Group extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('gid', 'integer', null, array('primary' => true)); } public function setUp() { $this->hasMany('User as users', array('refClass' => 'UserGroup', 'local' => 'group_gid', 'foreign' => 'user_id')); } } class UserGroup extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('user_uid', 'integer', null, array('primary' => true)); $this->hasColumn('group_gid', 'integer', null, array('primary' => true)); } public function setUp() { $this->hasOne('User as user', array('local' => 'user_uid', 'foreign' => 'uid')); $this->hasOne('Group as group', array('local' => 'group_gid', 'foreign' => 'gid')); } } the following queries: $query = Doctrine_Query::create()
->select('u.*')
->from('User u')
->leftJoin('u.groups g WITH g.gid=?', 1);
echo $query->getSqlQuery() . "\n";
$query = Doctrine_Query::create()
->select('g.*')
->from('Group g')
->leftJoin('g.users u WITH u.uid=?', 1);
echo $query->getSqlQuery() . "\n";
will output the following:
The orderBy option() call is applied to the User definition. The SQL for the first query is correct (where User is on the left side of the join). The SQL for the second query (where User is on the right-most side of the join), however, is obviously incorrect (UserGroup doesn't even have a uid column). Basically, User's orderBy option is being applied to both the User table and its respective reference table, UserGroup, when it is the target of a join. After digging through the source for a while, I believe I've come up with a patch for this issue (which should be checked by someone more knowledgeable of Doctrine's internals). Basically, in the Doctrine_Query::buildSqlQuery() function, a call is made to Doctrine_Relation::getOrderByStatement() with the reference table (UserGroup)'s alias (u2), which in turn makes a call to Doctrine_Table::getOrderByStatement() on the referenced table (User), filling in the ORDER BY clause with User columns using UserGroup's alias. My solution was to reorder the logic so that the test for a reference class is made before the initial call to getOrderByStatement() is made. It seems to work against my test case and the test cases in the repository. I'll post my patch momentarily. This bug was first mentioned in the comments in DC-313, but the original ticket comes across as more of a feature request for the hasMany() orderBy feature. |
| Comments |
| Comment by suhock [ 26/Apr/10 ] |
|
attached a test case for this bug |
| Comment by suhock [ 26/Apr/10 ] |
|
patch against /branches/1.2 HEAD (should also work apply to 1.2.2 tag) |
| Comment by Dan Ordille [ 30/Aug/10 ] |
|
I can confirm this as an issue. However I don't think the above patch adequately fixes the problem it seems like with it an order by is still added for the ref column however the relation alias is lost. My query with the patch became I made an another patch that prevents this extra order by clause from being added and have attached it. |
| Comment by suhock [ 21/Sep/10 ] |
|
I tried out the new patch (Query_orderby_relation.diff), but it provides a reversed diff (patching goes from a patched version to the original). After applying it manually, it fails the provided test case and several additional test cases from the repository. The original patch DOES pass the provided test case, when applied against 1.2.2, 1.2.3, or the 1.2 branch from the repository. It does not pass, however, Doctrine_Query_Orderby_TestCase. As the previous poster mentioned, it fails to resolve aliases in instances where the 'orderBy' option is specified in a relation definition. I deleted the original patch and am providing a revised patch (Ticket_DC651.patch) against branch 1.2 HEAD (also works with 1.2.3), which fixes this issue. It passes all working test cases, including Doctrine_Query_Orderby_TestCase and DC651TestCase. |
| Comment by José De Araujo [ 31/Aug/11 ] |
|
I had this issue recently on a application I'm working on as described the oderBy option was applied on the joined table on a column that even doesn't exist in it. I used the DC651 patch provided and it solved the issue, so far I haven't seen any side effect to it. |
[DC-637] Many-to-many: Using Association Class (refclass) property in query adds leftJoin Created: 20/Apr/10 Updated: 20/Apr/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query, Relations |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Pablo Grass | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3.2 (cli) (built: Mar 4 2010 22:12:20) |
||
| Attachments: |
|
| Description |
|
When trying to use a refclass property - i.e. normalization table column - in a query, an unnecessary join is added to the query created, which is then used to "access" the property. This issue has already been discussed back in May 2008 but still seems to persist. Unfortunately it is hardly possible to write a test case for this, as working SQL is generated, but the query is just not right (test case basically would have to assert the query string, wich does not make much sense). John Wage commented on this issue |
[DC-625] Doctrine_Query throws exception for custom hydrator that extends stock hydrator Created: 09/Apr/10 Updated: 20/Apr/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Jared Mellentine | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows Vista, Apache 2.2, PHP 5.3, MySQL 5.1 |
||
| Attachments: |
|
| Description |
|
I have a custom hydrator that extends Doctrine_Hydrator_ScalarDriver, for the sole purpose of simplifying the column keys (by passing false as the 3rd parameter on _gatherRowData): class Doctrine_Hydrator_AssocDriver extends Doctrine_Hydrator_ScalarDriver while ($data = $stmt->fetch(Doctrine_Core::FETCH_ASSOC)) { $result[] = $this->_gatherRowData($data, $cache, false); } return $result; The processPendingFields method in Doctrine_Query is unnecessarily throwing a Doctrine_Query_Exception at line 465. This can be resolved by skipping hydration methods that extend None, Scalar and SingleScalar. A diff of the changes is attached. |
[DC-608] Limit and Offset breaks query with multiple non-join FROM statements Created: 30/Mar/10 Updated: 30/Mar/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Sid GBF | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
Generated:
Notice: |
[DC-610] Chaining innerjoins can only be made uni-directional; order matters Created: 30/Mar/10 Updated: 31/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1, 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Exception e | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
I've witnessed the problem in Doctrine 1.2.2 and 1.2.1 |
||
| Description |
|
The following code fails This doesn't work Doctrine_Query::create()
->select('Table t1')
->innerJoin('f1.Foreign2 f2 WITH f1.field = 2')
->innerJoin('t1.Foreign1 f1')
Doctrine seems only to be happy when we change the order of the inner joins This works Doctrine_Query::create()
->select('Table t1')
->innerJoin('t1.Foreign1 f1')
->innerJoin('f1.Foreign2 f2 WITH f1.field = 2')
|
| Comments |
| Comment by Exception e [ 30/Mar/10 ] |
|
fixed typo |
| Comment by dquintard [ 31/Dec/10 ] |
|
What about this issue. $q2 = Doctrine_Query::create() $q3 = Doctrine_Query::create() $q4 = Doctrine_Query::create() Moreover i tried with Doctrine 1.3 and this problem is not resolved. |
[DC-606] [Oracle] Query on M:M with relation name doesn't work Created: 29/Mar/10 Updated: 29/Mar/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Bertrand Zuchuat | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
My schema: ---
Actuality:
connection: web
tableName: actuality
actAs:
softDelete: ~
Timestampable: ~
Sluggable:
fields: [name]
builder: [tool, slugify]
indexName: actuality_sluggable
canUpdate: true
columns:
id:
type: integer(4)
primary: true
unsigned: true
sequence: actuality
created_at:
type: timestamp
updated_at:
type: timestamp
published_at:
type: timestamp
notnull: true
unpublished_at:
type: timestamp
name:
type: string(255)
notnull: true
description_short:
type: string(1000)
notnull: true
description:
type: clob
notnull: true
is_professional:
type: boolean
default: true
relations:
Categories:
class: ActualityCategory
local: actuality_id
foreign: actuality_category_id
refClass: ActualityActualityCategory
foreignAlias: Actualities
And my query: public function retrieveCloud($is_professional, $limit = 20) { return $this->createQuery('ac') ->leftJoin('ac.Actualities a2') ->where('ac.id IN (SELECT aac.actuality_category_id FROM Actuality a LEFTJOIN a.ActualityActualityCategory aac WHERE a.published_at < ? AND a.is_professional = ?)', array(date('Y-m-d H:i:s'), $is_professional)) ->orderBy('ac.name') ->limit($limit) ->execute(); } I have this error: Doctrine_Connection_Oracle_Exception ORA-01008: not all variables bound : SELECT a.id AS a__id, a.created_at AS a__created_at, a.updated_at AS a__updated_at, a.name AS a__name, a.deleted_at AS a__deleted_at, a.slug AS a__slug, a2.id AS a2__id, a2.created_at AS a2__created_at, a2.updated_at AS a2__updated_at, a2.published_at AS a2__published_at, a2.unpublished_at AS a2__unpublished_at, a2.name AS a2__name, a2.description_short AS a2__description_short, a2.description AS a2__description, a2.is_professional AS a2__is_professional, a2.deleted_at AS a2__deleted_at, a2.slug AS a2__slug FROM actuality_category a LEFT JOIN actuality_actuality_category a3 ON (a.id = a3.actuality_category_id) LEFT JOIN actuality a2 ON a2.id = a3.actuality_id AND (a2.deleted_at IS NULL) WHERE a.id IN (SELECT a4.id FROM ( SELECT DISTINCT a4.id FROM actuality_category a4 LEFT JOIN actuality_actuality_category a6 ON (a4.id = a6.actuality_category_id) LEFT JOIN actuality a5 ON a5.id = a6.actuality_id AND (a5.deleted_at IS NULL) WHERE a4.id IN (SELECT a8.actuality_category_id AS a5__actuality_category_id FROM actuality a7 LEFT JOIN actuality_actuality_category a8 ON a7.id = a8.actuality_id WHERE (a7.published_at < :oci_b_var_1 AND a7.is_professional = :oci_b_var_2)) AND (a4.deleted_at IS NULL) ORDER BY a4.name ) a4 WHERE ROWNUM <= 20) AND (a.id IN (SELECT a5.actuality_category_id AS a5__actuality_category_id FROM actuality a4 LEFT JOIN actuality_actuality_category a5 ON a4.id = a5.actuality_id WHERE (a4.published_at < :oci_b_var_3 AND a4.is_professional = :oci_b_var_4)) AND (a.deleted_at IS NULL)) ORDER BY a.name |
[DC-601] When using a join and giving an alias to each select column the hyrdrator only returns one row. Created: 25/Mar/10 Updated: 02/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query, Relations |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | will ferrer | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
XP Xamp |
||
| Description |
|
Hi All $q = Doctrine_Query::create(); Generates this DQL:
SELECT Customer.firstname as first_name, Customer.postalcode as postalcode FROM Customer Customer LEFT JOIN Customer.Zip Zip And this SQL:
SELECT c.firstname AS c_0, c.postalcode AS c_1 FROM customers c LEFT JOIN zips z ON c.postalcode = z.postalcode Which results in this return after hyrdration: array('0'=>array('first_name'=>'Armando', 'postalcode'=>'00659')) However the following code hydrates just fine: $q = Doctrine_Query::create(); As does this code:
$q = Doctrine_Query::create();
Here is the yaml for the sample data I am testing on:
detect_relations: false Perhaps there is something simple I am overlooking. To get around this I am just always selecting the primary key from my main table in every query. Thanks in advance for any advice. |
| Comments |
| Comment by will ferrer [ 03/Apr/10 ] |
|
This problem also exists in 1.2.2 so I have updated the post to reflect this. |
| Comment by Peter Bücker [ 06/Apr/10 ] |
|
I experienced the same problem with Doctrine 1.2 (r7329). I also fixed this by adding the primary key of the table I select from to the select list. |
| Comment by will ferrer [ 07/Apr/10 ] |
|
Hi Peter Thats how I am currently working around the bug as well but hopefully it will get rectified in a later version of doctrine. Thanks for the comment. Will |
| Comment by Sam Doun [ 08/Jun/10 ] |
|
Hi all, I'm new to doctrine and since yesterday, I'm experiencing exactly the same behavior. Regards, |
| Comment by will ferrer [ 08/Jun/10 ] |
|
Hi Sam Currently I am working around this bug by always adding the primary key of the table to the select (like peter also mentions above). It is a work around for the problem but so far it has been reliable for me. I hope that helps until there is a patch for it. Will Ferrer |
| Comment by Sam Doun [ 09/Jun/10 ] |
|
Hi Will I'll do so. Sam Doun |
| Comment by Shuchi Sethi [ 02/Aug/10 ] |
|
Hi, Has there been any patch release for the same? For DQL - function getServiceDetails($merchantId,$merchantServiceId) {
$q = Doctrine_Query::create()
->select('b.*, m.name as merchant_service_name,payment_mode.name as payment_mode_name,payment_mode.id as paymentMode,p.id as paymentModeOption ')
->from('ServicePaymentModeOption b')
->leftJoin("b.MerchantService m")
->leftJoin("m.Merchant merchant")
->leftJoin("b.PaymentModeOption p")
->leftJoin("p.PaymentMode payment_mode")
->where("merchant.id=?",$merchantId)
->andWhere("b.merchant_service_id=?",$merchantServiceId)
->groupBy('p.name');
return $res = $q->execute(array(),Doctrine::HYDRATE_ARRAY);
}
Result with Doctrine 1.1 is Array
(
[0] => Array
(
[id] => 1
[merchant_service_id] => 1
[payment_mode_option_id] => 1
[created_at] =>
[updated_at] =>
[deleted] =>
[created_by] =>
[updated_by] =>
[merchant_service_name] => NIS Passport
[merchant_name] => NIS
[payment_mode_option_name] => Bank
[payment_mode_name] => Bank
[paymentMode] => 1
[paymentModeOption] => 1
[MerchantService] => Array
(
[merchant_service_name] => NIS Passport
[Merchant] => Array
(
[merchant_name] => NIS
)
)
[PaymentModeOption] => Array
(
[payment_mode_option_name] => Bank
[paymentModeOption] => 1
[PaymentMode] => Array
(
[payment_mode_name] => Bank
[paymentMode] => 1
)
)
)
)
Result with Doctrine 1.2 is Array
(
[0] => Array
(
[id] => 1
[merchant_service_id] => 1
[payment_mode_option_id] => 1
[created_at] =>
[updated_at] =>
[deleted_at] =>
[created_by] =>
[updated_by] =>
[merchant_service_name] => NIS Passport
[merchant_name] => NIS
[payment_mode_option_name] => Bank
[payment_mode_name] => Bank
[paymentMode] => 1
[paymentModeOption] => 1
)
)
We have used Hydration for the result set at lot of places. Please suggest if there could be a fix without going about revising everything that has been coded. Looking forward to a quick response. |
[DC-600] Query Cache causes exception when using array parameter and IN in a where clause Created: 25/Mar/10 Updated: 21/Jul/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1, 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Jay Klehr | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
PHP 5.2.11 Linux, Mysql 5.0.x |
||
| Attachments: |
|
| Description |
|
Following the documentation, I'm using an IN condition in a where clause on a Doctrine_Query with Query cache enabled (APC). Syntax:
The first time this query is run, all is fine, and any subsequent runs will be fine as well, UNLESS the values array changes length, like so:
With the query cache enabled, this will throw a PDO "Invalid Parameter Count" exception, because it appears that Doctrine uses the cached query which only has 4 placeholders, but the passed parameters now has a count of 5. A change in the length of the parameters array in this situation should cause Doctrine to insert a new entry into the query cache for this query. Let me know if you need more information regarding this, if I find time I can try to put together a Test case. Thanks! |
| Comments |
| Comment by Jay Klehr [ 30/Mar/10 ] |
|
Failing test case exhibiting this bug. |
| Comment by Jay Klehr [ 30/Mar/10 ] |
|
I've attached a TestCase that I put together that shows this bug. Turns out that when using the sqlite adapter, the exception isn't thrown, so I had to look at the profiler in order to show that the query fetched from the cache has the wrong parameter count. I also tested this with the "whereIn()" method instead of just "where()". whereIn works correctly (but isn't as flexible as where, so I don't believe it's an acceptable replacement in all situations). |
| Comment by Jay Klehr [ 30/Mar/10 ] |
|
fixing my quoted blocks |
| Comment by Jay Klehr [ 30/Mar/10 ] |
|
Updated test case. I discovered that sqlite DOES throw an exception in the array's length grows in the second query so added another test to my test case to exhibit this. |
| Comment by Till Seifert [ 21/Jul/10 ] |
|
Hi, this bug just hit me hard, and made a quick fix: in the Query/Abstract.php the function calculateQueryCacheHash was augmented with the param-count: public function calculateQueryCacheHash($params = array()) { $dql = $this->getDql(); /// quickfox by Till Seifert $hash = md5($dql . '|' . count($this->getFlattenedParams($params)) . '|' . var_export($this->_pendingJoinConditions, true) . 'DOCTRINE_QUERY_CACHE_SALT'); return $hash; }and in protected function _execute($params) the params are passed: Line:927 cann anyone comment on if this could be horribly wrong? for know this fixes this bug for me. [EDIT: posted code as attachment, for better readability) |
| Comment by Till Seifert [ 21/Jul/10 ] |
|
proposed fix. not a patch, sorry. it's also faulty: it runs getFlattenedParams twice, and it fails when you have more than 1 "x IN Array" condition. If the global number or queryparams stays the same, no new cache-entry is created, so you wold have somehow incorporate the individual param-parts-sizes in the cache-hash, not just the number of params. |
[DC-595] Array hydration fails when sorting DESC Created: 23/Mar/10 Updated: 23/Mar/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | admirau | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows, Ubuntu, PostgreSQL, |
||
| Description |
|
Wrong array hydration results. Running toArray() on non hydrated collection Case1. $reputationHydrated = Doctrine_Query::create() $reputation = Doctrine_Query::create() $reputationToArray = $reputation->toArray(); die($reputationToArray === $reputationHydrated); // true, as expected Case 2. $reputationHydrated = Doctrine_Query::create() $reputation = Doctrine_Query::create() $reputationToArray = $reputation->toArray(); die($reputationToArray === $reputationHydrated); // false, should be true Other hydrators do hydrate as expected. Seems that something is wrong in Doctrine_Hydrator_Graph. |
| Comments |
| Comment by admirau [ 23/Mar/10 ] |
|
Changed one condition in Graph.php, and it works. — Doctrine/Hydrator/Graph.php
Plase check if this does not breaks something else. |
[DC-581] ORACLE: Missing fields on subquery with Many:Many Created: 18/Mar/10 Updated: 18/Mar/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Bertrand Zuchuat | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
I use this schema: ---
Actuality:
connection: web
tableName: actuality
actAs:
softDelete: ~
Timestampable: ~
Sluggable:
fields: [name]
indexName: actuality_sluggable
canUpdate: true
columns:
id:
type: integer(4)
primary: true
unsigned: true
sequence: actuality
created_at:
type: timestamp
updated_at:
type: timestamp
published_at:
type: timestamp
notnull: true
unpublished_at:
type: timestamp
name:
type: string(255)
notnull: true
description_short:
type: string(1000)
notnull: true
description:
type: clob
notnull: true
is_professional:
type: boolean
default: true
relations:
Categories:
class: ActualityCategory
local: actuality_id
foreign: actuality_category_id
refClass: ActualityActualityCategory
foreignAlias: Actualities
ActualityActualityCategory:
connection: web
tableName: actuality_actuality_category
options:
symfony:
form: false
filter: false
columns:
actuality_id:
type: integer(4)
primary: true
unsigned: true
actuality_category_id:
type: integer(2)
primary: true
unsigned: true
relations:
Actuality:
onDelete: CASCADE
ActualityCategory:
connection: web
tableName: actuality_category
actAs:
softDelete: ~
Timestampable: ~
Sluggable:
fields: [name]
indexName: actualityc_sluggable
canUpdate: true
columns:
id:
type: integer(2)
primary: true
unsigned: true
sequence: actualitycategory
created_at:
type: timestamp
updated_at:
type: timestamp
name:
type: string(60)
notnull: true
Function in my model Actuality public function retrieveActive($is_authenticated = false) { $q = $this->createQuery('a') ->leftJoin('a.Categories c') ->orderBy('a.published_at DESC'); if (!$is_authenticated) { $q->where('a.is_professional = ?', false); } return $q; } with that, i receive the message "Doctrine_Connection_Oracle_Exception" because Oracle is strict and in the subselect, the field published_at is missing in select. This is the query generate by doctrine: SELECT a.id AS a__id, a.published_at AS a__published_at, a.name AS a__name, a.description_short AS a__description_short, a.slug AS a__slug, a2.id AS a2__id, a2.name AS a2__name FROM actuality a LEFT JOIN actuality_actuality_category a3 ON (a.id = a3.actuality_id) LEFT JOIN actuality_category a2 ON a2.id = a3.actuality_category_id WHERE a.id IN (SELECT a4.id FROM ( SELECT DISTINCT a4.id FROM actuality a4 LEFT JOIN actuality_actuality_category a6 ON (a4.id = a6.actuality_id) LEFT JOIN actuality_category a5 ON a5.id = a6.actuality_category_id WHERE a4.is_professional = 0 ORDER BY a4.published_at DESC ) a4 WHERE ROWNUM <= 5) AND (a.is_professional = 0) ORDER BY a.published_at DESC If i execute this query and add the field published_at in subquery, this is work. SELECT a.id AS a__id, a.published_at AS a__published_at, a.name AS a__name, a.description_short AS a__description_short, a.slug AS a__slug, a2.id AS a2__id, a2.name AS a2__name FROM actuality a LEFT JOIN actuality_actuality_category a3 ON (a.id = a3.actuality_id) LEFT JOIN actuality_category a2 ON a2.id = a3.actuality_category_id WHERE a.id IN (SELECT a4.id FROM ( SELECT DISTINCT a4.id, a4.published_at FROM actuality a4 LEFT JOIN actuality_actuality_category a6 ON (a4.id = a6.actuality_id) LEFT JOIN actuality_category a5 ON a5.id = a6.actuality_category_id WHERE a4.is_professional = 0 ORDER BY a4.published_at DESC ) a4 WHERE ROWNUM <= 5) AND (a.is_professional = 0) ORDER BY a.published_at DESC Thanks for your help. |
| Comments |
| Comment by Bertrand Zuchuat [ 18/Mar/10 ] |
|
I specify another thing. I use this with a pager. |
| Comment by Bertrand Zuchuat [ 18/Mar/10 ] |
|
I create this testcase to find the bug but with that, the test is OK. I execute the same code with symfony/doctrine but the query isn't the same. Why ???? Extract from symfony exception (Doctrine_Connection->execute) SELECT a.id AS a__id, a.published_at AS a__published_at, a.name AS a__name, a.description_short AS a__description_short, a.slug AS a__slug, a2.id AS a2__id, a2.name AS a2__name FROM actuality a LEFT JOIN actuality_actuality_category a3 ON (a.id = a3.actuality_id) LEFT JOIN actuality_category a2 ON a2.id = a3.actuality_category_id WHERE a.id IN (SELECT a4.id FROM ( SELECT DISTINCT a4.id FROM actuality a4 LEFT JOIN actuality_actuality_category a6 ON (a4.id = a6.actuality_id) LEFT JOIN actuality_category a5 ON a5.id = a6.actuality_category_id WHERE a4.is_professional = ? ORDER BY a4.published_at DESC ) a4 WHERE ROWNUM <= 5) AND (a.is_professional = ?) ORDER BY a.published_at DESC |
[DC-575] Select distinct limit problem Created: 16/Mar/10 Updated: 30/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | O. | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
php 5.3.0, mysql 5.1.36, symfony 1.4.3 |
||
| Attachments: |
|
| Description |
|
1)Code This code must return only one result but it returns all results in which user_id is 2 in the database If i looked it in Symfony Debug bar, i saw that; 2)Symfony debug toolbar values: #Query A #Query B And if i test this code in MYSQL query browser i got a result like that; SELECT u.user_id AS u_user_id, m.message_id AS mmessage_id, m.message_senddate AS mmessage_senddate, m.message_title AS mmessage_title, m.message_content AS mmessage_content, m.message_alias AS mmessage_alias, m.message_categoryid AS m_message_categoryid If i changed SQL code like below and put the limit at end, the problem solved: #Query A #Query B But doctrine's limit(1) metod is Select Distinct The query which starts with ... is at query A but it needs to be at the end of query B |
| Comments |
| Comment by O. [ 16/Mar/10 ] |
|
My schema file. |
| Comment by Jonathan H. Wage [ 16/Mar/10 ] |
|
It is hard to understand your issue description. Can you make a clear failing Doctrine test case for us to look at? Thanks, Jon |
| Comment by O. [ 17/Mar/10 ] |
|
Adding problem screencast: |
| Comment by O. [ 17/Mar/10 ] |
|
I found the source of the problem: $limitSubquery values are default TRUE, but FALSE have to be here.. (to me) |
| Comment by will ferrer [ 30/Jun/10 ] |
|
Hi O I made a patch which will allow you to turn off the limit subquery. If you would like to check it out here is the bug it is posted on: http://www.doctrine-project.org/jira/browse/DC-701 Hope that helps. Will |
[DC-554] Distinct query does not work Created: 09/Mar/10 Updated: 15/Mar/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Mishal | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
$limit = 10; $q = Doctrine_Query::create() The QUERY is WRONG: // SELECT DISTINCT p.id AS p_id, p.contractor AS p_contractor FROM public_contract p WHERE (p.contractor LIKE ?) LIMIT 10 - (%Me%) I can simply GROUP BY the contractor field, because DISTINCT can be considered as a special case of GROUP BY - and have the results I want: $q = Doctrine_Query::create() |
| Comments |
| Comment by Jonathan H. Wage [ 15/Mar/10 ] |
|
Test case or patch? |
[DC-544] Doctrine_Pager bug with Oracle. getNumResults doesn't return the correct number of records Created: 04/Mar/10 Updated: 18/Mar/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Pager |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Bertrand Zuchuat | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
The function getNumResults() doesn't work correctly. This is my model class class ReviewListTable extends Doctrine_Table { public function getAvailable() { return $this->createQuery() ->select('DISTINCT(to_char(file_date, \'YYYY-MM-DD\')) fdate') ->orderBy('fdate DESC'); } } If i execute this fonction, the number of record is 31. If i use the Pager, the result is 5744 records Controler: $this->pager = new Doctrine_Pager( Doctrine_Core::getTable('ReviewList')->getAvailable(), $request->getParameter('page', 1), 20); View: $rs = $this->pager->execute();
echo $pager->getNumResults();
|
| Comments |
| Comment by Jonathan H. Wage [ 15/Mar/10 ] |
|
Hmm. I don't quite understand. Can you make a test case? |
[DC-499] Doctrine_Query_Set incorrectly rewrites expressions Created: 14/Feb/10 Updated: 04/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Lukas Kahwe | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
First up Doctrine_Query_Set should extend Doctrine_Query_Condition so that the parseLiteralValue method is available in _processPossibleAggExpression(). However I am not sure what this method is really supposed to do. It seems to do some reordering of clauses, but in my case it actually drops off some parts of my expression: Results in "UPDATE document SET clause_ordering = IF(clause_ordering IS NULL, '67', CONCAT(clause_ordering)) WHERE (id = ?)" And not as expected "UPDATE document SET clause_ordering = IF(clause_ordering IS NULL, '67', CONCAT(clause_ordering, ',67')) WHERE (id = ?)" Adding a space after IF and CONCAT fixes the issue, but is obviously a hack to get around the regexp in _processPossibleAggExpression() |
| Comments |
| Comment by Raphael Araújo [ 19/Jun/10 ] |
|
Guilherme, Implementei uma solução meio nebulosa aqui: http://pastie.org/1011675 O que esta pegando é a expressão regular. Ela não esta aceitando muito bem quando existe na "$hasAggExpression" argumentos separados por vÃrgula. ->set('p.tempo_atual', 'IFNULL(p.tempo_atual, p.lance_tempo) - 1') Na implementação atual ele descarto o segundo argumento do IFNULL(). Não tenho certeza se minha proposta de implementação é correta. não entendi muito bem o funcionamento do preg_match_all. Ao meu ver ele sempre retornaria apenas a posicao 0, mas foi uitlizado um foreach, não entendi o pq. Então como esta com foreach eu deixei e coloquei uma 'glue' variável para o implode no final. |
| Comment by Sebastião Farias Júnior [ 04/Feb/11 ] |
|
Tem como ignorar esta verificação? Pq o que esta acontecendo e que se eu digitar numa frase, exemplo, " teste( 89,0%), " o doctrine pensa que é uma expressão, como evitar isto? |
[DC-828] MSSQL - ORDER BY on text columns throws mssql error 306 [+patch] Created: 16/Aug/10 Updated: 02/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | 1.2.4 |
| Type: | Improvement | Priority: | Major |
| Reporter: | Enrico Stahn | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
Throws: Server: Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Solution:
References:
Patch will be supplied soon ... |
| Comments |
| Comment by Enrico Stahn [ 20/Aug/10 ] |
|
http://github.com/estahn/doctrine1/compare/DC-828 I guess we need more TestCases for the SubQuery stuff. |
| Comment by Enrico Stahn [ 02/Sep/10 ] |
|
I made a mistake with github, the updated branch can be found at |
[DC-809] Doctrine_Query_Abstract::set() Does not handle boolean values correctly. Created: 05/Aug/10 Updated: 05/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexandre Ravey | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
When passing booleans to the set() function on an update DQL query object, the value false is not handled correctly and end up in a corrupted query. Test schema: schema.yml Test:
columns:
bool:
type: boolean
default: false
notnull: true
Steps to reproduce: code.php Doctrine_Query::create()->update('Test')
->set('bool', false)
->execute()
->getSqlQuery();
Result Query: Expected Query: See attached patch file for a possible solution. (I don't have deep know of Doctrine internals...) |
[DC-799] Doctrine_Query::parseFunctionExpression() produces unexpected results if the expression contains a function Created: 27/Jul/10 Updated: 27/Jul/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | 1.2.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Henning Glatter-Gotz | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Mac OS X, LINUX |
||
| Description |
|
When Doctrine_Query::parseFunctionExpression() is called with the following parameter and $this->_conn->expression is of type Doctrine_Expression_MySql: $expr = "DATE_FORMAT(datefield,'%Y-%m-%d'),someotherfield" The expected result from Doctrine_Query::parseFunctionExpressoin() would be DATE_FORMAT(l.datefield,'%Y-%m-%d'),l.someotherfield However, the actual result is DATE_FORMAT(l.datefield,'%Y-%m-%d'),someotherfiel Note the missing leading "l." and the last character ("d") on "someotherfield". This example is a result of calling addGroupby("DATE_FORMAT(datefield,'%Y-%m-%d'),someotherfield") on a Doctrine_Query object. |
[DC-792] Doctrine query with the Oracle SOUNDEX function Created: 16/Jul/10 Updated: 16/Jul/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Ahmed GHALI | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu, oracle 11g, symfony 1.4.3 |
||
| Description |
|
Hi all, related to : |
[DC-787] Join & On override Created: 15/Jul/10 Updated: 15/Jul/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major |
| Reporter: | Thomas Tourlourat - Armetiz | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Users & Books are linked by CompoUsersBooks. So, It's a m:m relationship. Here, a crazy DQL query to fetch users & specifics books. [code] The SQL query As you can see, And also, the left join is a cartesian product ! The number of row return is really big for nothing... That really sux because It's performance killer. |
[DC-766] preQuery() and getConnection() - multiple connections Created: 25/Jun/10 Updated: 25/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.0, 1.2.1, 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Maciej Mazur | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
When preQuery() hook is invoked, any calls to $this->getConnection() in preQuery() body is useless because it always returns the current connection instead of the connection bound with component that is being queried. I am using this hook to switch the connection to connection to master host for schema of the queried component , but cannot do this because the is no way to obtain information about which component this query uses and what would be bounded connection. |
[DC-759] MSSQL Server / ODBC: Cannot order by a column aggregate when a limit subquery is required. Created: 22/Jun/10 Updated: 22/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Craig Marvelley | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows XP |
||
| Attachments: |
|
| Description |
|
It's not possible to use a column aggregate function and a limit subquery together with SQL Server; the logic that constructs the limit subquery is flawed, not recognising the presence of a function and assuming it to be a column. The resulting error occurs: SQLSTATE[42S22]: Column not found: 207 [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name ... This can be observed when running the random sorting example from the manual against SQL Server through ODBC: In addition to the syntax error, it seems SQL Server requires that all aggregate functions that appear in the order by section of the query are declared (i.e. aliased) in the select section which is not currently happening. I also noticed what I think is a bug in the ordering of results within the sub-select on line 214 of Doctrine_Connection_Mssql: which appears to be sorting in the opposite order as to what was intended. I've a fix and a test case which attempts to address these issues. I noticed two other open issues surrounding this section of code (#586 and #744) - if this patch is accepted I think these issues will also be resolved. |
| Comments |
| Comment by Craig Marvelley [ 22/Jun/10 ] |
|
Uploaded patch and test case. |
[DC-760] MSSQL Server: Support for RAND() in Doctrine_Expression_MSSQL Created: 24/Jun/10 Updated: 24/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major |
| Reporter: | Craig Marvelley | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows XP |
||
| Attachments: |
|
| Description |
|
Doctrine_Expression_MSSQL doesn't provide a method for handling SQL Server's RAND() method. I've attached a patch to support it. |
[DC-757] In SQL query, field name is not replaced with real column name in right part of join condition Created: 21/Jun/10 Updated: 21/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Guilliam X | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Doctrine SVN 1.2 r7676 |
||
| Attachments: |
|
| Description |
|
Hi, I have a schema that uses fields aliases: schema.yml User:
Phonenumber:
columns:
theuser:
name: colprefix_user_id as user_id #note the column alias
type: integer
thenumber:
name: colprefix_number as number
type: string(20)
relations:
User:
local: user_id
foreign: id
foreignAlias: Phonenumbers
Now if I make the following 2 DQL queries, the first "plain" and the second with redefining the ON clause, then print generated SQL: $q1 = Doctrine_Query::create()
->from('User u')
->innerJoin('u.Phonenumbers p');
$q2 = Doctrine_Query::create()
->from('User u')
->innerJoin('u.Phonenumbers p ON u.id = p.user_id');
echo $q1->getSqlQuery() . "\n";
echo $q2->getSqlQuery() . "\n";
I get (lines formatted a little): SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
FROM user u INNER JOIN phonenumber p ON u.id = p.colprefix_user_id
SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
FROM user u INNER JOIN phonenumber p ON (u.id = p.user_id)
Note how, on the right end, p.user_id is not replaced with p.colprefix_user_id in the 2nd query! Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'p.user_id' in 'on clause'' in /[...]/doctrine_test/lib/vendor/doctrine/Doctrine/Connection.php:1082 This only happens for the right member of the join condition. If i swap the fields like this: $q3 = Doctrine_Query::create()
->from('User u')
->innerJoin('u.Phonenumbers p ON p.user_id = u.id'); //swapped
echo $q3->getSqlQuery() . "\n";
then we can see that the left member is replaced well: SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
FROM user u INNER JOIN phonenumber p ON (p.colprefix_user_id = u.id)
(This is only an example, there's no point redefining the ON clause here, but the same is occurring in the project I work on, in a WITH clause). I think the problem is in Doctrine_Query_JoinCondition::load(), in which
This can also produce weird results with SQL functions: $q4 = Doctrine_Query::create()
->from('User u')
->innerJoin('u.Phonenumbers p WITH SUBSTRING(p.number,0,3) = \'555\''); //left
$q5 = Doctrine_Query::create()
->from('User u')
->innerJoin('u.Phonenumbers p WITH \'555\' = SUBSTRING(p.number,0,3)'); //right
echo $q4->getSqlQuery() . "\n";
echo $q5->getSqlQuery() . "\n";
Output: SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
FROM user u INNER JOIN phonenumber p ON u.id = p.colprefix_user_id AND (SUBSTRING(p.colprefix_number FROM 0 FOR 3) = '555')
SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
FROM user u INNER JOIN phonenumber p ON u.id = p.colprefix_user_id AND ('555' = SUBSTRING(p.colprefix_number FROM 0 FOR 3 FROM ))
Now, the correct column name is always used, but in the 2nd case the "SUBSTRING" function looks like it has been parsed twice :/ I think both members (left and right) of condition should be treated equally (but I have no fix for now... :s) Thank you |
| Comments |
| Comment by Guilliam X [ 21/Jun/10 ] |
|
Waiting for better, I attach the patch I used; |
[DC-739] Pager returns incorrect page number when constructed on query with HAVING Created: 16/Jun/10 Updated: 16/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Pager |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Paweł Barański | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 9.10, |
||
| Description |
|
//method returns those categories that have any products, it returns 3 records //but when i do count() on created pager it returns 8 records (which is equal to categories in my database): $doctrinePager = $this->getServiceContainer() //pager works, but it "thinks" that there are more pages than in reality. with maxPerPage = 2, it thinks that there are 4 pages, but looking at query result it //should be only 2 pages. |
[DC-254] getLimitSubquery Not Including All Order By Parts Created: 18/Nov/09 Updated: 27/Feb/11 |
|
| Status: | Reopened |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.0-BETA3 |
| Fix Version/s: | 1.2.0-RC1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Michael Card | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
The getLimitSubquery function is only including the first orderby field and ignoring all remaining parts. The function also needs to be changed to include mssql and odbc. The diff's below provide corrections. Thanks, Mike diff -r Doctrine-1.1.2\lib\Doctrine\Query.php Doctrine-1.1.2-Fixes\lib\Doctrine\Query.php 1367c1367 < if ($driverName == 'pgsql' || $driverName == 'oracle' || $driverName == 'oci') { --- > if ($driverName == 'pgsql' || $driverName == 'oracle' || $driverName == 'oci' || $driverName == 'mssql' || $driverName == 'odbc') { 1371,1387c1371,1392 < $part_original = trim($e[0]); < $callback = create_function('$e', 'return trim($e, \'[]`"\');'); < $part = trim(implode('.', array_map($callback, explode('.', $part_original)))); < < if (strpos($part, '.') === false) { < continue; < } < < // don't add functions < if (strpos($part, '(') !== false) { < continue; < } < < // don't add primarykey column (its already in the select clause) < if ($part !== $primaryKey) { < $subquery .= ', ' . $part_original; < } --- > > foreach ($e as $f) { > if ($f == 0 || $f % 2 == 0) { > $part_original = trim($f); > $callback = create_function('$e', 'return trim($e, \'[]`"\');'); > $part = trim(implode('.', array_map($callback, explode('.', $part_original)))); > > if (strpos($part, '.') === false) { > continue; > } > > // don't add functions > if (strpos($part, '(') !== false) { > continue; > } > > // don't add primarykey column (its already in the select clause) > if ($part !== $primaryKey) { > $subquery .= ', ' . $part_original; > } > } > } |
| Comments |
| Comment by Michael Card [ 22/Dec/09 ] |
|
Additonal fix for this issue, was missing dblib originally. Mike diff -r Doctrine-1.1.2\lib\Doctrine\Query.php Doctrine-1.1.2-Fixes\lib\Doctrine\Query.php 1367c1367 < if ($driverName == 'pgsql' || $driverName == 'oracle' || $driverName == 'oci' || $driverName == 'mssql' || $driverName == 'odbc') { — > if ($driverName == 'pgsql' || $driverName == 'oracle' || $driverName == 'oci' || $driverName == 'mssql' || $driverName == 'odbc' || $driverName == 'dblib') { |
| Comment by Andrej Pavlovic [ 27/Feb/11 ] |
|
Come on guys, please include this fix into 1.2.4... |
[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 Fix: Line 1305 in Query.php: I ended up just adding the following just after the above statement in the code: |
[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-1016] Set method in update query ignores 'false' if passed as boolean Created: 05/Jul/11 Updated: 05/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.4 |
| 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: 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-1003] _processWhereIn does not allow the use of named query parameters Created: 05/May/11 Updated: 06/May/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | None |
| Fix Version/s: | 1.2.4 |
| Type: | Improvement | Priority: | Minor |
| Reporter: | alex pilon | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
karmic, php 5.2.10, apache2 |
||
| Attachments: |
|
| Description |
|
When writing a query such as
you are unable to then
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-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: 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) // 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'" " 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 |
| Comments |
| Comment by Tibor Erdész [ 03/Feb/11 ] |
|
Just figured out that I can use notations and I fixed my report. |
[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: |
|
| Description |
|
The following methods on Doctrine_Table create Doctrine_Query objects that are never free()d: |
| 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-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 |
||
| 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() I've tried different variations in the where() clause with no luck. I am using all the other MySQL functions in another query here: 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? |
[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: |
|
| 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 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-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') Am I doing it wrong?, The only other option I've found is to use DSQL and execute a query like "SELECT count Thank you in advance. Pablo. |
[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-918] Causing ORA-01791 when try to sort on relation field and use limit in query to Oracle DB Created: 06/Nov/10 Updated: 06/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Dmitriy | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
Windows 2003 Server, Oracle 10g, Symfony 1.4.8 |
||
| Description |
|
Schema in yml format PrType:
columns:
name: { type: string(255), notnull: true }
PrTypeTranslation:
columns:
id: { type: integer, notnull: true }
name: { type: string(255), notnull: true }
lang: { type: string(255), notnull: true }
relations:
PrType: { onDelete: CASCADE, local: id_id, foreign: id, foreignAlias: Translation }
When i try to execute this code: $q = Doctrine_Query::create()
->from('PrType tp')
->leftJoin('tp.Translation t WITH t.lang = ?', 'ru')
->orderBy('t.name')
->limit(10);
doctrine executes next statement: SELECT "p"."id", "p2"."name" AS "p2__name", "p2"."lang" AS "p2__lang" FROM "pr_type" "p" LEFT JOIN "pr_type_translation" "p2" ON "p"."id" = "p2"."id" AND ("p2"."lang" = :oci_b_var_1) WHERE "p"."id" IN ( SELECT a."id" FROM ( SELECT DISTINCT "p3"."id" FROM "pr_type" "p3" INNER JOIN "pr_type_translation" "p4" ON "p3"."id" = "p4"."id" AND ("p4"."lang" = 'ru') ORDER BY "p4"."name" ) a WHERE ROWNUM <= 10) ORDER BY "p2"."name" This sql code produces next error ORA-01791: not a SELECTed expression Error occures, because (from ORACODE)
|
| Comments |
| Comment by Dmitriy [ 06/Nov/10 ] |
|
Some very similar issue were reported and resolved here http://trac.doctrine-project.org/ticket/1038. |
| Comment by Dmitriy [ 06/Nov/10 ] |
|
Reason of issue was founded. It appears because i'm using oci8 driver, and this drivername not be listed in if statement on line 1401 in Doctrine/Query.php:
LINE 1401: if ($driverName == 'pgsql' || $driverName == 'oracle' || $driverName == 'oci' || $driverName == 'mssql' || $driverName == 'odbc') {
I changed to: LINE 1401: if ($driverName == 'pgsql' || $driverName == 'oracle' || $driverName == 'oci' || $driverName == 'oci8' || $driverName == 'mssql' || $driverName == 'odbc') {
Sorry, but i don't know how to create patch diff file. |
[DC-860] 0 down vote favorite In some circumstances Doctrine_Core::getTable('%Name%') returns Doctrine_Table instance instead of %Name%Table one. Created: 06/Sep/10 Updated: 06/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Relations |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Hong Kil Dong | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
WinXP, Apache, PHP 5.2.14 |
||
| Description |
|
In some circumstances Doctrine_Core::getTable('%Name%') returns Doctrine_Table instance instead of %Name%Table one. In order to give a demonstration of this improper behavior : here is a schema of small issue tracking system User: user_name: { type: string(255) }user_role: { type: enum, values: [worker, dispatcher, manager] }managed_by: { type: integer }password: { type: string(32) }salt: { type: string(32) } relations: Issue: from_ceh: { type: string(255) }from_name: { type: string(255) }from_phone: { type: string(255) }from_location: { type: string(255) }comp_name: { type: string(255) }comp_serial: { type: string(255) }comp_os: { type: enum, values: [Win95, Win98, WinNT, WinME, Win2000, WinXP, Vista, Win7] }issue_title: { type: string(255) }comment: { type: string(255) }owner_id: { type: integer }is_executed: { type: bool } relations: When I just call Doctrine_Core::getTable('User') it returns UserTable instance, but if I call it after such a query: Doctrine_Query::create() calling Doctrine_Core::getTable('User') returns Doctrine_Table instance |
[DC-1021] i am executing doctrine type query i am geting error please gave me reply Created: 24/Jul/11 Updated: 24/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | 1.2.4 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | cherukuri | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
windows ,wamp,php |
||
| Description |
|
$query = new Doctrine_Query(); |
[DC-962] Broken logic when doctrine translates limit's into subqueries, with joins. (with patch) Created: 02/Feb/11 Updated: 02/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Ben Davies | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
All |
||
| Attachments: |
|
| Description |
|
Problem exists when Doctrine formulates a subquery to perform a limit when a join in included. The problem is that the where clause that doctrine creates for the subquery (the WHERE IN clause) is inserted as the first where clause. Consider: select * from table join metadata WITH c = ? where a = ? and b = ? limit 1 with parameters be (1, 2, 3) Doctrine will translate this to
select * from table
join metadata WITH c = ?
where table.id IN (
select id from table
join metadata WITH c = ?
where a = ? and b = ?
limit 1
)
and a = ? and b = ?
Doctrine will duplicate the params (Doctrine_Query_Abstract:969) to (1, 2, 3, 1, 2, 3), but now they are in the wrong order completely. The easy fix is to move the limit subquery to the LAST where clause, which would reuslt in a query like so:
select * from table
join metadata WITH c = ?
where a = ? and b = ?
and table.id IN (
select id from table
join metadata WITH c = ?
where a = ? and b = ?
limit 1
)
Attached is a patch to fix this issue, along with a patch that fixes all unit tests referring to the old query format. |
| Comments |
| Comment by Ben Davies [ 02/Feb/11 ] |
|
upping to blocker since this breaks very basic queries |
[DC-952] Non-Equal Nest Relations Not Working - from "Children" side Created: 03/Jan/11 Updated: 24/Mar/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Record, Relations |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Paweł Barański | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 4 |
| Labels: | None | ||
| Environment: |
Ubuntu 10.04 + PHP 5.3.3 + Symfony 1.4.8 |
||
| Attachments: |
|
||||||||||
| Sub-Tasks: |
|
| Description |
|
I've copy & pasted example from http://www.doctrine-project.org/projects/orm/1.2/docs/manual/defining-models/1_0#relationships:join-table-associations:self-referencing-nest-relations:non-equal-nest-relations . 1. Add 3 User objects (A,B,C) As a result you will see only C set as Children, and strange situation in database : UserReference Table: parent_id | child_id |
| Comments |
| Comment by Paweł Barański [ 06/Jan/11 ] |
|
Same ticket on symfony trac because I'm not sure whose fault is it http://trac.symfony-project.org/ticket/9398 Also some new error path there |
| Comment by Daniel Reiche [ 24/Mar/11 ] |
|
Test Case of Non-Equal Self-Referencing Relations, based on #DC-329. Failure occures in line 75 of the test case file. This should not happen! |
[DC-1034] ORA-00904 in Doctrine_Connection_Oracle Created: 01/Sep/11 Updated: 01/Sep/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Connection |
| Affects Version/s: | 1.2.4 |
| Fix Version/s: | 1.2.4 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Jayson LE PAPE | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 7 64 bits, PHP 5.2.11, Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi, Symfony 1.4.13 |
||
| Description |
|
When i execute this code:
$q = Doctrine_Query::create()
->from('AGENT ag')
->leftJoin('ag.CHANTIER_AGENT cag)
->orderBy('ag.nom')
->limit(10)
->offset(10)
->execute();
Doctrine executes : SELECT a.pk AS a__pk, a.ts AS a__ts, a.ck_agent AS a__ck_agent, a.matricule AS a__matricule, a.nom AS a__nom, a.prenom AS a__prenom, a.agent_maitrise AS a__agent_maitrise, c.pk AS c__pk, c.ts AS c__ts, c.ck_chantier_agent AS c__ck_chantier_agent, c.ek_chantier AS c__ek_chantier, c.fk_chantier AS c__fk_chantier, c.ek_agent AS c__ek_agent, c.fk_agent AS c__fk_agent FROM AGENT a LEFT JOIN CHANTIER_AGENT c ON a.ck_agent = c.ek_agent WHERE a.ck_agent IN (SELECT b.ck_agent FROM ( SELECT a.*, ROWNUM AS doctrine_rownum FROM ( SELECT DISTINCT a2.ck_agent, a2.nom FROM AGENT a2 LEFT JOIN CHANTIER_AGENT c2 ON a2.ck_agent = c2.ek_agent ORDER BY a2.nom ) a2 ) b WHERE doctrine_rownum BETWEEN 11 AND 20) ORDER BY a.nom The problem is in function _createLimitSubquery in Doctrine_Connection_Oracle :
$query= 'SELECT '.$this->quoteIdentifier('b').'.'.$column.' FROM ( '.
'SELECT '.$this->quoteIdentifier('a').'.*, ROWNUM AS doctrine_rownum FROM ( '
. $query . ' ) ' . $this->quoteIdentifier('a') . ' '.
' ) ' . $this->quoteIdentifier('b') . ' '.
'WHERE doctrine_rownum BETWEEN ' . $min . ' AND ' . $max;
Error occures, because table name is AGENT and Doctrine give the first letter of the table name for identifier.
$query = 'SELECT '.$this->quoteIdentifier('limb').'.'.$column.' FROM ( '.
'SELECT '.$this->quoteIdentifier('lima').'.*, ROWNUM AS doctrine_rownum FROM ( '
. $query . ' ) ' . $this->quoteIdentifier('lima') . ' '.
' ) ' . $this->quoteIdentifier('limb') . ' '.
'WHERE doctrine_rownum BETWEEN ' . $min . ' AND ' . $max;
|
[DC-1035] ORA-01791 due to bad driver name in Doctrine_Adapter_Oracle Created: 01/Sep/11 Updated: 01/Sep/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Connection |
| Affects Version/s: | 1.2.4 |
| Fix Version/s: | 1.2.4 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Jayson LE PAPE | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 7 64 bits, PHP 5.2.11, Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi, Symfony 1.4.13 |
||
| Description |
|
When i execute this code:
$q = Doctrine_Query::create()
->from('AGENT ag')
->leftJoin('ag.CHANTIER_AGENT cag)
->orderBy('ag.nom')
->limit(10)
->execute();
$q2 = Doctrine_Query::create()
->from('AGENT ag')
->leftJoin('ag.CHANTIER_AGENT cag)
->orderBy('ag.nom')
->limit(10)
->execute();
Doctrine executes : SELECT a.pk AS a__pk, a.ts AS a__ts, a.ck_agent AS a__ck_agent, a.matricule AS a__matricule, a.nom AS a__nom, a.prenom AS a__prenom, a.agent_maitrise AS a__agent_maitrise, c.pk AS c__pk, c.ts AS c__ts, c.ck_chantier_agent AS c__ck_chantier_agent, c.ek_chantier AS c__ek_chantier, c.fk_chantier AS c__fk_chantier, c.ek_agent AS c__ek_agent, c.fk_agent AS c__fk_agent FROM AGENT a LEFT JOIN CHANTIER_AGENT c ON a.ck_agent = c.ek_agent WHERE a.ck_agent IN ( SELECT a2.ck_agent FROM ( SELECT DISTINCT a2.ck_agent, a2.nom FROM AGENT a2 LEFT JOIN CHANTIER_AGENT c2 ON a2.ck_agent = c2.ek_agent ORDER BY a2.nom ) a2 WHERE ROWNUM <= 10) ORDER BY a.nom SELECT a.pk AS a__pk, a.ts AS a__ts, a.ck_agent AS a__ck_agent, a.matricule AS a__matricule, a.nom AS a__nom, a.prenom AS a__prenom, a.agent_maitrise AS a__agent_maitrise, c.pk AS c__pk, c.ts AS c__ts, c.ck_chantier_agent AS c__ck_chantier_agent, c.ek_chantier AS c__ek_chantier, c.fk_chantier AS c__fk_chantier, c.ek_agent AS c__ek_agent, c.fk_agent AS c__fk_agent FROM AGENT a LEFT JOIN CHANTIER_AGENT c ON a.ck_agent = c.ek_agent WHERE a.ck_agent IN ( SELECT a2.ck_agent FROM ( SELECT DISTINCT a2.ck_agent FROM AGENT a2 LEFT JOIN CHANTIER_AGENT c2 ON a2.ck_agent = c2.ek_agent ORDER BY a2.nom ) a2 WHERE ROWNUM <= 10) ORDER BY a.nom This causes "Oracle DB Error ORA-01791 not a SELECTed expression" because the sql query don't have a2.nom in SELECT DISTINCT and it's indispensable for ORDER BY a2.nom protected $attributes = array(Doctrine_Core::ATTR_DRIVER_NAME => "oci8", Doctrine_Core::ATTR_ERRMODE => Doctrine_Core::ERRMODE_SILENT); The problem is in Query.php line 1417 : if ($driverName == 'pgsql' || $driverName == 'oracle' || $driverName == 'oci' || $driverName == 'mssql' || $driverName == 'odbc') {
The driver name declared in Doctrine_Adapter_Oracle not in this conditional. protected $attributes = array(Doctrine_Core::ATTR_DRIVER_NAME => "oracle", Doctrine_Core::ATTR_ERRMODE => Doctrine_Core::ERRMODE_SILENT); An other problem is probably located at line 1409 if (($driverName == 'oracle' || $driverName == 'oci') && $this->_isOrderedByJoinedColumn()) { and 1497 if (($driverName == 'oracle' || $driverName == 'oci') && $this->_isOrderedByJoinedColumn()) { if don't correct the declaration of $attributes in Doctrine_Adapter_Oracle. |
[DC-1031] CLONE -Multiple connections and i18n (raised as unresolved - original ticket marked as resolved) Created: 23/Aug/11 Updated: 28/Mar/12 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Connection, I18n |
| Affects Version/s: | 1.2.2, 1.2.3 |
| Fix Version/s: | 1.2.3 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | James Bell | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MySQL 5.1.37 symfony 1.4.13 |
||
| Description |
|
I used to work with a single database named "doctrine". The query was working properly. I then decided to use 2 databases so I got my schema like this:
I did setup my connections in config/databases.yml this way:
build-model, build-forms, build-filters and cc got ran. But now, I got an exception saying the "Translation" relation doesn't exist. The Base Models include correctly the bindComponent line:
For now, I managed to kind of fixing it with simply swapping the databases order in my config/databases.yml and it's now working again perfectly. I forgot to mention that in the CategoryTable when i call $this->getConnection()->getName(), it outputs "second" |
| Comments |
| Comment by James Bell [ 23/Aug/11 ] |
|
Original issue: There are some additional comments in there that explain the issue as currently being seen in released versions of Doctrine 1.2. Can I help verify that this is the same ticket? What is needed to help with debug (in addition to the extra information already provided)? |
| Comment by Andy.L [ 28/Mar/12 ] |
|
meet the same issue and it really blocked my project, seems no one will maintain 1.x. I'm considering whether to replace symfony 1.4 with 2.0. |
[DC-1025] Doctrine is unable to handle table names with spaces Created: 02/Aug/11 Updated: 02/Aug/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | 1.2.1, 1.2.2, 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Daniel Borg | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP Version 5.2.14 |
||
| Attachments: |
|
| Description |
|
When trying to query a table which contains spaces I get the following exception I have attached an simple example to reproduce C:\Documents and Settings\daniel\Dokumenter\NetBeansProjects\test>php doctrineTest.php Fatal error: Uncaught exception 'Doctrine_Query_Exception' with message 'Unknown table alias with' in C:\Doctrine-1.2.3\Doctrine\Query\Abstract.php:856 thrown in C:\Doctrine-1.2.3\Doctrine\Query\Abstract.php on line 856 |
[DC-1040] allow queries with table joins across different databases Created: 17/Nov/11 Updated: 17/Nov/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | 1.2.3 |
| Type: | Improvement | Priority: | Blocker |
| Reporter: | Fabrice Agnello | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows XP SP3, Apache 2, PHP 5.3, MySQL 5.1.36, Symfony 1.4.8, Doctrine 1.2.3 |
||
| Attachments: |
|
| Description |
|
I'm currently working on a project which relies upon several databases declared in databases.yml in symfony 1.4.8. I was facing an issue that has already been raised by other people, namely that you can't join tables which reference each other among different mysql databases. I've dug a bit in the Doctrine_Query class and came to a solution that is acceptable for us, and allows now to make joins accross databases. Description follows : first change is in the Doctrine_Core class, that gets stuffed with a new constant : this constant allows us to add a new attribute to the databases.yml file as in :
after that, a few changes have been done in the Doctrine_Query class which is attached to this issue for the sake of readability. This may not be optimal, and probably need some regression testing, but it is currently working fine on our test server. after this is done, I was able to issue queries like the following : where the referenced tables are in different databases. The necessary object binding has been done in every model class following the paradigm : Doctrine_Manager::getInstance()->bindComponent('CdcIndInt ', 'gescdc'); I don't know if this description is clear enough, so let me know if something is missing/wrong. |
[DC-313] Ordering m2m relationship with column from related table (with orderBy option) Created: 02/Dec/09 Updated: 18/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Record, Relations |
| Affects Version/s: | 1.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Maciej Hołyszko | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Environment: |
php 5.3/win, doctrine 1.2 svn, ATTR_QUOTE_IDENTIFIER = true, ATTR_USE_DQL_CALLBACKS = true |
||
| Attachments: |
|
| Description |
|
I find no way to define automatic orderBy in m2m relations with column not from reference table, but actual related table. E.g. BlogPost <= m2m through BlogPostCategory => BlogCategory class BlogPost extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('title', 'string', 128); $this->hasColumn('content', 'string'); } public function setUp() { $this->hasMany('BlogCategory as BlogCategories', array('local' => 'id_blog_post', 'foreign' => 'id_blog_category', 'refClass' => 'BlogPostCategory', 'orderBy' => 'name')); } } class BlogCategory extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('name', 'string', 128); } public function setUp() { $this->hasMany('BlogPost as BlogPosts', array('local' => 'id_blog_category', 'foreign' => 'id_blog_post', 'refClass' => 'BlogPostCategory')); } } class BlogPostCategory extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('id_blog_post', 'integer', null, array('primary' => true)); $this->hasColumn('id_blog_category', 'integer', null, array('primary' => true)); } public function setUp() { $this->hasOne('BlogPost', array('local' => 'id_blog_post', 'foreign' => 'id', 'onDelete' => 'CASCADE')); $this->hasOne('BlogCategory', array('local' => 'id_blog_category', 'foreign' => 'id', 'onDelete' => 'CASCADE')); } } The resulting query contains doubled 'name' column in ORDER BY clause, both from reference table and related table, e.g. ORDER BY t2.name, t3.name I tried putting the following code in BlogCategory::setTableDefinition() instead of attribute in relation definition in BlogPost record: $this->option('orderBy', 'name');
but the result was the same. Maybe I'm doing something wrong? Is there a possibility to define an alias, where to get column name from - in orderBy attribute? Thanks in advance. |
| Comments |
| Comment by Maciej Hołyszko [ 02/Dec/09 ] |
|
Attached test case. |
| Comment by Maciej Hołyszko [ 08/Dec/09 ] |
|
I find this issue as critical one now, because when I use e.g. $this->option('orderBy', 'name');
in a model's definition (not ref class), then when other model is related m2m with it, a query loading both of them with relations will fail because of name column duplicated in ref table. |
| Comment by suhock [ 23/Apr/10 ] |
|
I am having the same issue with an equivalent test case. For some reason, the 'orderBy' option on the target of the join (set by calling the option() function inside the setUp() method of the model class, not the ref class) is being applied to the relation table. After digging through the 1.2.2 tag a bit, I found altering line 1319 of Query.php as follows seems to fix the problem (at least against my test cases):
I'll do some more thorough testing and submit a patch if I find time. |
| Comment by Bart W [ 17/Feb/11 ] |
|
I had this issue as well. suhock's solution fixed it for me. It would be nice if this was merged in to a bug fix release of Doctrine 1.x. |
| Comment by suhock [ 18/Feb/11 ] |
|
I ended up creating a new ticket, DC-651, which addresses a more general problem with the orderBy feature. You should use the attached Ticket_DC651.patch instead, as I found the solution I provided here is not completely correct and does not pass all test cases. |
[DC-839] Version classes not built for models using package attribute Created: 24/Aug/10 Updated: 08/Mar/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Behaviors |
| Affects Version/s: | 1.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Prasad Gupte | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
PHP 5.2.3 / Symfony 1.4.6 |
||
| Description |
|
For models using the 'package' attribute in the schema definition, the version classes do not get created. However, the version table gets created. There is no problem during the build, but when loading fixtures, there is a fatal error: Class TaxCodeVersion not found TaxCode:
|
| Comments |
| Comment by hetsch [ 08/Mar/11 ] |
|
Same here, If i use this yaml file: Page: PageVersion and PageTranslation Models don't get generated if i use 'build-models-yaml'. Have to create the Models manually then it works fine. |
[DC-791] [PostgreSQL] In case model is build from existing database sequence name is invalid and doctrine throw exception Created: 16/Jul/10 Updated: 25/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Schema Files |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | 1.2.4 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Przemysław Ciąćka | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
symfony 1.4.5, postgresql 8.4, debian lenny, nginx |
||
| Attachments: |
|
| Description |
|
Firstly I created database directly in postgresql. When I try to insert new record to database I received following error: sequence "Category_id_seq" does not exist In schema file sequence name is defined like this: sequence: '"Address_id_seq"' In Category model file is same like above, apostrophes and quotes. When I remove quotes from sequence in model files everything is ok and there're no problems with insert new row to database. |
| Comments |
| Comment by Enrico Stahn [ 13/Aug/10 ] |
|
There are 2 solutions to your problem. The first is to change the sequence name in the schema, the second is to change the doctrine configuration. The default behavior of doctrine is to add a "_seq" to each sequence name. If you remove this part from you sequence name then it sould work as expected. The second option is to change the behavior of doctrine with the following configuration parameter: Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_SEQNAME_FORMAT, '%s'); default: Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_SEQNAME_FORMAT, '%s_seq'); |
| Comment by Przemysław Ciąćka [ 25/Aug/10 ] |
|
Problem are quotes in sequence name. Temporarly I fixed it by add str_replace() into importer from PostgreSQL - now in schema sequence names are without quotes. |
[DC-770] Result Cache Created: 29/Jun/10 Updated: 29/Jun/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Record |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Thomas Tourlourat - Armetiz | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Doctrine result cache isn't working properly. Here a simple example, when I'm calling query->execute (); parentProgram is related to a video. line 1014 : I have just add some code to output data. else { $result = $this->_constructQueryFromCache($cached); $oVideo = $result[0]; echo "cached "; var_dump (count ($oVideo->parentProgram->getReferences ())); exit (0); }[/code] The output of a query execution (the first with an empty APC cache) with "useResultCache" is :
The problem is coming from the serialize php function that can't serialize protected properties.. A solution could be use __sleep function, and a public property that contain all important protected data. |
[DC-701] Aggregates functions do not return proper values when using many relationships and limits Created: 24/May/10 Updated: 01/Nov/10 |
|
| Status: | Reopened |
| Project: | Doctrine 1 |
| Component/s: | None |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | 1.2.4 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | will ferrer | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
XP Xamp |
||
| Attachments: |
|
| Description |
|
Hi All I have encountered a problem that seems very core to the way that doctrine works – if you apply an aggregate function to a column in a table and then join to another table via a many relationship while also using a limit, like so: $q = Doctrine_Query::create();
$q->from('Customer Customer');
$q->addSelect('COUNT(Customer.id) as COUNT_customer_id');
$q->addSelect('Customer_Order.id as order_id');
$q->leftJoin('Customer.Order Customer_Order'); // Many relationship here
$q->limit(20);
It produces this correct DQL: SELECT COUNT(Customer.id) as COUNT_customer_id, Customer_Order.id as order_id FROM Customer Customer LEFT JOIN Customer.Order Customer_Order LIMIT 20 However the SQL it produces will not return an accurate count – the count is restricted by the limit: SELECT COUNT(p.id) AS p__0, p2.id AS p2__1
FROM product_customers p
LEFT JOIN product_orders p2 ON p.id = p2.customer_id
WHERE p.id IN ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20')
This produces a count of 21 instead of what it should be (1000). The reason for this is because Doctrine's internal functionality does an intermediary query where it gets gets the ids needed from the customer table in order to use them as the IN portion of the constraints on the final query – like so: SELECT DISTINCT p3.id FROM product_customers p3 LIMIT 20 It may seem strange that I am applying a limit to a query which will aggregate to 1 to row . In the actual queries that alerted me to this problem I am using a group by. The reason I am not reporting this bug with a group by in my example however is that you can not use a group by with a many relationship and a limit in doctrine 1.2.2 as it works currently (see bug: Here is my sample schema in case its helpful. detect_relations: false package: Example options: type: INNODB charset: utf8 Order: tableName: orders columns: order_id: type: integer(4) primary: true notnull: true customer_id: type: integer(4) order_date: timestamp relations: Customer: type: one local: customer_id foreign: customer_id options: type: InnoDB Customer: tableName: customers columns: customer_id: type: integer(4) primary: true notnull: true autoincrement: true firstname: type: string(45) lastname: type: string(45) streetaddress: type: string(45) city: type: string(45) state: type: string(45) postalcode: type: string(45) relations: Order: type: many local: customer_id foreign: customer_id options: type: InnoDB Thanks much. Will Ferrer edit: split SQL code to make the discussion readable without huge horizontal scrolling... |
| Comments |
| Comment by Jonathan H. Wage [ 08/Jun/10 ] |
|
Is this still a problem? I am not sure if this can be patched easily. The limit subquery algorithm is flawed deeply but also a core part of the current way Doctrine 1 works. |
| Comment by will ferrer [ 08/Jun/10 ] |
|
Hi Jon This bug is still an issue for me but I think it may be VERY hard to patch since it seems very core to the way Doctrine 1 works. The project I am working on at the moment is a visual query builder that is highly reliant on Doctrine. In order to prevent users from making queries that would trigger this bug I am currently giving an alert when ever a query that would trigger this bug is created. It would be great if this were patchable but if not I should be able to get by. Does Doctrine 2 fix this problem? Thanks for the help. Will Ferrer |
| Comment by Jonathan H. Wage [ 08/Jun/10 ] |
|
In Doctrine 2 the limit subquery algorithm does not exist. It is now up to the developer to write the query to handle the scenario instead of Doctrine "trying" to automate it for you. Since the situation where it is needed it is so rare, and each case can be slightly different it is better to let the developer handle it in those cases. |
| Comment by will ferrer [ 08/Jun/10 ] |
|
Hi Jon Does that mean that Doctrine 2 can no longer intelligently handle limits with many relationships, and doesn't have the ability to hydrate a return with sub arrays in it for many relationships? Thanks again for your help. Will Ferrer |
| Comment by Jonathan H. Wage [ 09/Jun/10 ] |
|
That is correct. We do not automatically try and limit the relationships with a "limit subquery" as it causes more problems then it helps. |
| Comment by will ferrer [ 10/Jun/10 ] |
|
Hi Jon I was thinking about what you said here – that the "limit subquery" causes more harm than good. It occur to me that I really do like being able to use this method (it comes in very handy very often) but some times it would really help to be able to turn it off (the bug in this thread is a good example such a time). So I figured why not just make an option to turn it off and have the best of both worlds? I looked at the code and found it was really very easy to put in a property which can be set on the query object to enable or disable the use of the limit subquery. I made the change in my code base and found it very useful for several situations I was dealing with in my own project. The one thing I couldn't do is make a test case for this new feature – I couldn't find an existing test case that was actually triggering the limit subquery as I understood it to work (I couldn't find a test case that would put an WHERE IN constraint with all the ids gathered in the limit subquery. I tried some test cases that I THOUGHT would activate this feature but it didn't seem that they did). After adding this feature to my code base I also wanted a new hydrator – one that worked like scalar but would put in array key names that were the same as the ones you would see in HYDRATE_ARRAY. I noticed that HYDRATE_SCALAR already had the ability to do this but it required that a value of false be passed into the $aliasPrefix argument of the _gatherRowData function. I made a custom hydrator I call HYDRATE_ARRAY_SHALLOW that passes in this false value. I then realized this might be handy to add to doctrine so I integrated it into my code base and made a few test cases for it. There are 2 patches I am now attaching this to thread: disableLimitSubquery_2010-06-10_Doctrine_1.2_SVN.patch – this patch adds the disableLimitSubquery property to query objects so that users can turn off the use of the subquery for those times when they don't want to use that behavior (fixing the bug in this thread and probably others) and disableLimitSubquery_and_HYDRATE_ARRAY_SHALLOW_2010-06-10_Doctrine_1.2_SVN.patch – this is the same as the first patch but also contains the HYDRATE_ARRAY_SHALLOW hydration type I mentioned above (which tends to go well with disableLimitSubquery turned on). I put these in 2 patches incase you liked 1 feature but disliked the other. If you like either of this features I would be very happy to see them added to doctrine. Also if you have any advice on how to improve these features (or info on how to make a good test case for disableLimitSubquery) please let me know. Hope you are well. Will Ferrer |
| Comment by will ferrer [ 10/Jun/10 ] |
|
Reopened because I added a patch that I think in essence fixes the issues. |
| Comment by Jonathan H. Wage [ 01/Sep/10 ] |
|
Thanks for the issue and patches. Fixed here http://github.com/doctrine/doctrine1/commit/2ad78e62e360133efc04bf6897bf679c7f3d833b |
| Comment by will ferrer [ 01/Sep/10 ] |
|
individual patch for this issue with out other features included |
| Comment by will ferrer [ 01/Nov/10 ] |
|
adding test cases for these features |
| Comment by will ferrer [ 01/Nov/10 ] |
|
reopened because I posted some test cases to add to doctrine along with the patchs previously posted |
[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-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-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-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-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-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-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-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-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-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-934] One-to-one relationship with cascading deletion and softdelete creates empty records Created: 21/Nov/10 Updated: 29/Nov/11 |
|
| Status: | Open |