logo       

Re: Difference between has_many and might_have: msg#00108

Subject: Re: Difference between has_many and might_have



On Mon, 16 Apr 2007, Priya Sivaraman wrote:


I have defined a list of tables that has some relation to each other. At
the beginning I was using has_many to define some relation between
table1 and table2. The relation between table1 and table2 might be for
each record in table1 there can be 0 or more records in table2. For that
I use to have the has_many relationship.



Now when I am trying to use the copy command to make a copy of record in
table1 I am having problem. It throws error telling "Cannot insert the
record in table2 due to violation of UNIQUE constraint";


The copy command will copy related objects from has_many as well, unless you set cascade_copy => 1 on the relationship.

The copy should have given your new object a new ID though, so how did you get unique constraint problems?


Now I tried using might_have it is not throwing error.

Yup, that one doesn't cascade_copy..

I would like to know the impact of changing this has_many to might_have.
Because I used dev server and did the testing. Now when I will move the
code to live I would like to know whether this code will have any
impact.

I don't think so.. probably better to use has_many and turn off the copy though, or fix the unique problem.

Jess




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe