Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix support for refPhpName, keep BC with fkRefPhpName.

  • Loading branch information...
commit aa037e5a13c6d79647eff0f70441caed63aafd9c 1 parent 51678fe
Bert-Jan de Lange authored
View
6 doc/schema.md
@@ -130,7 +130,7 @@ Foreign key columns accept additional parameters:
* `foreignReference`: The name of the related column if a foreign key is defined via `foreignTable`.
* `onDelete`: Determines the action to trigger when a record in a related table is deleted. When set to `setnull`, the foreign key column is set to `null`. When set to `cascade`, the record is deleted. If the database engine doesn't support the set behavior, the ORM emulates it.
* `fkPhpName`: Name of the related object seen from the current object. Propel uses this name to generate filters and accessors (see the 'Relation Names' section below)
- * `fkRefPhpName`: Name of the current object seen from the related object.
+ * `refPhpName`: Name of the current object seen from the related object.
* `fkSkipSql`: Set to true for virtual foreign keys, not translated into SQL
### Empty Column Definition
@@ -389,7 +389,7 @@ Here, Propel creates a `User` relation on the `Book` object, and a `Book` relati
->filterByUser($user)
->find();
-You may want to customize the relation names to qualify the relationship. In the previous example, when related to an `Article`, a `User` would better be called an `Author`. Symmetrically, from the `User` point of view, a `Book` should be named a `Work`. Use the `fkPhpName` and `fkRefPhpName` column attributes to choose custom relation names:
+You may want to customize the relation names to qualify the relationship. In the previous example, when related to an `Article`, a `User` would better be called an `Author`. Symmetrically, from the `User` point of view, a `Book` should be named a `Work`. Use the `fkPhpName` and `refPhpName` column attributes to choose custom relation names:
[yaml]
propel:
@@ -398,7 +398,7 @@ You may want to customize the relation names to qualify the relationship. In the
id: ~
title: varchar(150)
body: longvarchar
- user_id: { fkPhpName: Author, fkRefPhpName: Work, type: integer, foreignTable: user, foreignReference: id, onDelete: cascade }
+ user_id: { fkPhpName: Author, refPhpName: Work, type: integer, foreignTable: user, foreignReference: id, onDelete: cascade }
Now the generated code looks like this:
View
10 lib/addon/sfPropelDatabaseSchema.class.php
@@ -804,7 +804,7 @@ protected function getAttributesForColumn($tb_name, $col_name, $column)
{
foreach ($column as $key => $value)
{
- if (!in_array($key, array('foreignClass', 'foreignTable', 'foreignReference', 'fkPhpName', 'fkRefPhpName', 'fkSkipSql', 'onDelete', 'onUpdate', 'index', 'unique', 'sequence', 'inheritance', 'vendor')))
+ if (!in_array($key, array('foreignClass', 'foreignTable', 'foreignReference', 'fkPhpName', 'refPhpName', 'fkRefPhpName', 'fkSkipSql', 'onDelete', 'onUpdate', 'index', 'unique', 'sequence', 'inheritance', 'vendor')))
{
$attributes_string .= " $key=\"".htmlspecialchars($this->getCorrectValueFor($key, $value), ENT_QUOTES, sfConfig::get('sf_charset'))."\"";
}
@@ -893,9 +893,13 @@ protected function getAttributesForColumn($tb_name, $col_name, $column)
{
$attributes_string .= " phpName=\"{$column['fkPhpName']}\"";
}
- if (isset($column['fkRefPhpName']))
+ if (isset($column['refPhpName']))
{
- $attributes_string .= " refPhpName=\"{$column['fkRefPhpName']}\"";
+ $attributes_string .= " refPhpName=\"{$column['refPhpName']}\"";
+ }
+ elseif (isset($column['fkRefPhpName']))
+ {
+ $attributes_string .= " refPhpName=\"{$column['fkRefPhpName']}\"";
}
if (isset($column['fkSkipSql']))
{
View
2  test/unit/fixtures/new_schema.yml
@@ -45,7 +45,7 @@ classes:
stripped_title: { type: longvarchar, required: true, primaryKey: true, sequence: my_custom_sequence_name }
user_id:
my_group: { type: integer, foreignTable: ab_group, foreignReference: id, onDelete: setnull }
- my_other_group: { type: integer, foreignTable: ab_group, foreignReference: id, onDelete: setnull, phpName: MyOtherGroupPhpName, fkPhpName: MyOtherGroupFkPhpName, fkRefPhpName: MyOtherGroupFkRefPhpName }
+ my_other_group: { type: integer, foreignTable: ab_group, foreignReference: id, onDelete: setnull, phpName: MyOtherGroupPhpName, fkPhpName: MyOtherGroupFkPhpName, refPhpName: MyOtherGroupRefPhpName }
created_at: timestamp
updated_at:
View
2  test/unit/fixtures/schema.xml
@@ -57,7 +57,7 @@
<reference local="my_group" foreign="id" />
</foreign-key>
<column name="my_other_group" type="integer" phpName="MyOtherGroupPhpName" />
- <foreign-key foreignTable="ab_group" onDelete="setnull" phpName="MyOtherGroupFkPhpName" refPhpName="MyOtherGroupFkRefPhpName">
+ <foreign-key foreignTable="ab_group" onDelete="setnull" phpName="MyOtherGroupFkPhpName" refPhpName="MyOtherGroupRefPhpName">
<reference local="my_other_group" foreign="id" />
</foreign-key>
<column name="created_at" type="timestamp" />
View
2  test/unit/fixtures/schema.yml
@@ -34,7 +34,7 @@ propel:
stripped_title: { type: longvarchar, required: true, primaryKey: true, sequence: my_custom_sequence_name }
user_id:
my_group: { type: integer, foreignTable: ab_group, foreignReference: id, onDelete: setnull }
- my_other_group: { type: integer, foreignTable: ab_group, foreignReference: id, onDelete: setnull, phpName: MyOtherGroupPhpName, fkPhpName: MyOtherGroupFkPhpName, fkRefPhpName: MyOtherGroupFkRefPhpName }
+ my_other_group: { type: integer, foreignTable: ab_group, foreignReference: id, onDelete: setnull, phpName: MyOtherGroupPhpName, fkPhpName: MyOtherGroupFkPhpName, refPhpName: MyOtherGroupRefPhpName }
created_at: timestamp
updated_at:

0 comments on commit aa037e5

Please sign in to comment.
Something went wrong with that request. Please try again.