When you can a foreign-key, sqlpp adds all the primary-key fields to the
linked table without altering the names. Now this approach does not work if
you link "twice" the same table or you are doing a self-reference.
In that case, you can use reference/@field-prefix to tag the name of the
added fields. For example, field-prefix="Parent" will lead to field:
ParentUserID and so on.
In your case:
<reference id="ref_myBoss" ref-table="users" field-prefix="Parent"
nullable="true" />
At 14:41 24/04/2004 +0200, you wrote:
>Hi!
>Can I implement a reference from a foreign key to a primary key field
>in the same table?
>I try the something like this:
><table id="users" name="Users" field-prefix="User" qualifier="test_"
>fixed="false" signed="false" suffix="">
> <field id="userid" name="ID" type="int" primary-key="true" />
> <!-- <field id="bossid" name="bossID" type="int" /> -->
> <field id="username" name="Name" type="NVARCHAR(30)"
> nullable="false" />
> <field id="userlastname" name="LastName" type="NVARCHAR(30)"
> nullable="true" />
> <reference id="ref_myBoss" ref-table="users" field-prefix=""
> nullable="false" match="userid" name="bossid" />
> <!-- <reference id="ref_myBoss" ref-table="users"
> field-prefix="" nullable="false" name="bossid"/> -->
></table>
>but I get error that a "duplicate field name while creating foreign keys"
>was found.
>Could you help me?
>
>What make the match and name attribute in reference-type tag exactly?
>
>Thank you!
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
>For a limited time only, get FREE Ground shipping on all orders of $35
>or more. Hurry up and shop folks, this offer expires April 30th!
>http://www.thinkgeek.com/freeshipping/?cpg=12297
>_______________________________________________
>Sqlpp-devel mailing list
>Sql...@li...
>https://lists.sourceforge.net/lists/listinfo/sqlpp-devel
-----------------------------------------------------------------------------------
Jonathan de Halleux, Research Assistant
Center for Systems Engineering and Applied Mechanics (CESAME)
Universite catholique de Louvain
Batiment Euler , Av. Georges Lemaitre, 4 Tel : +32-10-47 2595
B-1348 Louvain-la-Neuve Belgium
E-mail : deh...@au...
-----------------------------------------------------------------------------------
|