Improved sortable behavior: onDelete="setnull" #456

Merged
merged 11 commits into from Nov 11, 2012

Conversation

Projects
None yet
5 participants
Contributor

rozwell commented Aug 25, 2012

When scope column is a FK and onDelete="setnull", removing related object now moves all objects to the end of null scope.
This is continuation of #359
New method: _"moveRelatedObjectsToNullScope()_
Note: it generates only 2 SQL queries.

@rozwell rozwell sortable behavior: when scope column is a FK and onDelete="setnull", …
…removing related object now moves all objects to the end of null scope
924839c

This pull request passes (merged 924839c into 19dc671).

Contributor

rozwell commented Aug 25, 2012

2nd query can be changed to shiftRank($maxRank, 1, null, $this->getPrimaryKey(), $con);
but it will generate slower sql:

UPDATE `article` SET `SORTABLE_RANK` = article.SORTABLE_RANK + 20 WHERE article.SORTABLE_RANK>=1 AND article.CATEGORY_ID=8

and now it's:

UPDATE article SET sortable_rank = sortable_rank+20 WHERE article.CATEGORY_ID = 8

What do you guys think about that?

This pull request fails (merged 1e16f2c into 19dc671).

This pull request passes (merged 4c369ba into 19dc671).

This pull request passes (merged ed54050 into 19dc671).

Owner

willdurand commented Aug 31, 2012

Ok, great. Is it covered by tests?

Contributor

rozwell commented Aug 31, 2012

Not yet.

Owner

willdurand commented Sep 10, 2012

I fixed the test suite, I guess you have to rebase your PR :)

Contributor

rozwell commented Sep 15, 2012

Merge was enough, tests should be this week finally..

Contributor

rozwell commented Nov 9, 2012

Alrighty then, please check if there isn't anything missing ;)
Sorry I couldn't make it faster..

Owner

willdurand commented Nov 11, 2012

Perfect. Thank you so much @rozwell

willdurand merged commit 15f4fa1 into propelorm:master Nov 11, 2012

1 check passed

default The Travis build passed
Details

When we use namespaces the {$this->queryClassname} does not build the full namesapce class and the use for this class is not added on the top of the file. So i've a fatal when i try to delete my object

Owner

willdurand replied Jan 17, 2013

weird because there is:

$builder->declareClassFromBuilder($builder->getStubQueryBuilder());
Member

jaugustin replied Jan 18, 2013

@cedriclombardot could you give us more information and create an issue ?

could you provide the stacktrace, schema, ... to reproduce your issue ?

Contributor

cedriclombardot replied Jan 22, 2013

Well I ve :

 <table name="tool">
        <column name="id" type="integer" primaryKey="true" required="true" autoIncrement="true" description="id, primary key" />
        <column name="category_id" type="integer" required="true" description="the tool category" />
        <column name="name" type="varchar" size="300" required="false" description="The tool title" />
        <column name="small_description" type="varchar" size="500" required="false" description="The tool small description" />
        <column name="description" type="longvarchar" required="false" description="The tool description" />
        <column name="type" type="enum" required="true" valueSet="active, add, soon, vote" default="vote" description="The tool type" />
        <column name="image" type="varchar" required="false" description="The tool picture thumb" />
        <column name="image_thumb" type="varchar" required="false" description="The tool picture" />
        <column name="functionalities" type="array" required="false" description="The functionnalities" />
        <column name="price" type="float" required="false" description="The tool price" />
        <column name="website_poll" type="varchar" required="false" description="The tool poll website" />
        <column name="note" type="float" required="true" default="3.5" description="The tool note" />

        <foreign-key foreignTable="tool_category" onUpdate="cascade" onDelete="cascade" phpName="Category">
            <reference local="category_id" foreign="id" />
        </foreign-key>

        <behavior name="sortable" />

        <behavior name="sluggable">
            <parameter name="slug_pattern" value="{Name}" />
            <parameter name="permanent" value="true" />
        </behavior>
    </table>

And it generate BaseToolPeer

public static function shiftRank($delta, $first = null, $last = null, PropelPDO $con = null)
{
.....
$whereCriteria = ToolQuery::create();
.....

But not add ToolQuery in use statements

Contributor

cedriclombardot replied Jan 28, 2013

Any news ?

Member

jaugustin replied Jan 28, 2013

@cedriclombardot no news, sorry, could you create an issue for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment