What are the Slack Archives?
Itโs a history of our time together in the Slack Community! Thereโs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonโt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hi everyone, how can I create a self-referencing one-to-one relationship? ```
Hi everyone,
how can I create a self-referencing one-to-one relationship?
<table name="spy_tax_rate"> <column name="fk_parent_tax_rate" type="INTEGER" required="false"/> <foreign-key name="spy_tax_rate-fk_parent_tax_rate" foreignTable="spy_tax_rate" phpName="ParentTaxRate" refPhpName="ChildTaxRate"> <reference local="fk_parent_tax_rate" foreign="id_tax_rate"/> </foreign-key> </table>
creates a one-to-many relationship.
Comments
-
Hi. Will making the fk unique do the job?
0 -
I tried...it didn't
0 -
I added
but it didn't change anything
0 -
you mean that after running the migration, you are still able to add duplicated values to the column? ๐ฎ
0 -
at least SpyTaxRate only has a method
getChildTaxRates
that gives me a collection instead of a single entity0 -
this seems to be a propel limitation& I see no way to do it except one http://propelorm.org/documentation/04-relationships.html#one-to-one-relationships
here is someone with the same problem https://github.com/propelorm/Propel2/issues/1187
0 -
yes, I saw that
0 -
that's not so great
0 -
so if your fk is the primary key for the table, it will work. Agreed, not fun at all
0 -
<table name="spy_tax_rate"> <column name="id_tax_rate" type="INTEGER" primaryKey="true" autoIncrement="true"/> <column name="fk_parent_tax_rate" type="INTEGER" required="false"/> <foreign-key name="spy_tax_rate-fk_parent_tax_rate" foreignTable="spy_tax_rate"> <reference local="fk_parent_tax_rate" foreign="id_tax_rate"/> </foreign-key> </table>
it is the primary key...doesn't create a one-to-one relationship though
0 -
you can put this in
src/Pyz/Zed/Tax/Persistence/Propel/Schema/spy_tax.schema.xml
and test yourself0 -
I just ran
docker/sdk console propel:install
- I think that's enough!?0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K ๐ Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random