|
In theory, your code would look up how constraints
are defined in system tables for your database and check to see if any
constraints would be violated as part of validation. The code would obviously
be database-specific. Beth From: Brian Kotek
[mailto:[EMAIL PROTECTED] That is one option, but
that results in this: On 4/26/06, Doug
Sims <[EMAIL PROTECTED]>
wrote: I would switch to an ID field for the primary key, rather than using
the username. you can still force that to be unique, just use an ID to locate
and identify records. On 4/26/06, Brian
Kotek <[EMAIL PROTECTED]>
wrote: Lets say you have a table called user, with a primary key of userName,
and then firstName and lastName columns. If you create a new user and populate
a UserRecord with these values and call save(), it will insert this record into
the database. This is fine. The problem (as I see it) is this: Later on lets
say another new UserRecord is created with the same userName but different
firstName and lastName values. When you call save(), it will silently update
the existing record instead of telling the user that they are trying to insert
a record with a duplicate userName. This seems to be a problem (and a common
one at that).
On 4/26/06, Doug
Hughes <[EMAIL PROTECTED]>
wrote: From my perspective there is no problem…. Am I missing
something? Doug From: [EMAIL PROTECTED]
[mailto:
[EMAIL PROTECTED]] On Behalf Of Brian
Kotek Yep, that's the same method that save() uses to
determine whether to insert or update. I just wasn't sure if that is the way
others are doing this or if anyone else has even run into the same problem. On
4/26/06, Bowden, Beth (NIH/NIEHS) [E]
<[EMAIL PROTECTED]>
wrote: The base dao.cfc has an "exists" function that
returns true or false if the record already exists. Beth Bowden Phone: 919-541-3355 FAX: 919-541-3687 From: Brian Kotek [mailto: [EMAIL PROTECTED]] Just
thought I'd ask in case I'm missing something within the API. I just realized
that if a user attempts to insert a duplicate record using the same primary key
values as an existing record, when you call save() reactor will treat it as an
UPDATE instead of throwing an error due to a duplicate primary key. I'm sure I
could create something that checks to see if the record already exists (which
is really what save() does under the hood) and skip the save(), but I wanted to
ask the group first if they have any other ideas. Thanks. --
Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
--
Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
|
RE: [Reactor For CF] Duplicate Insert vs. Update?
Bowden, Beth \(NIH/NIEHS\) [E] Wed, 26 Apr 2006 12:10:10 -0700
- [Reactor For CF] Duplicate Insert vs. Updat... Brian Kotek
- RE: [Reactor For CF] Duplicate Insert ... Bowden, Beth \(NIH/NIEHS\) [E]
- Re: [Reactor For CF] Duplicate Ins... Brian Kotek
- RE: [Reactor For CF] Duplicate... Doug Hughes
- Re: [Reactor For CF] Dupli... Brian Kotek
- Re: [Reactor For CF] ... Doug Sims
- Re: [Reactor For ... Brian Kotek
- RE: [Reactor ... Bowden, Beth \(NIH/NIEHS\) [E]
- Re: [Reactor ... Brian Kotek
- RE: [Reactor ... Doug Hughes
- Re: [Reactor ... Brian Kotek
- Re: [Reactor ... Doug Arthur
- Re: [Reactor ... Jeff Lester
- Re: [Reactor ... Doug Arthur
- Re: [Reactor ... Jeff Lester
- RE: [Reactor For ... Doug Hughes
- Re: [Reactor For CF] Duplicate Insert ... Daryl

