validatesUniquenessOf()

10 views
Skip to first unread message

Andy Bellenie

unread,
Nov 26, 2009, 5:06:07 AM11/26/09
to ColdFusion on Wheels
If you pass multiple properties into validatesUniquenessOf(), it
validates them in seperate queries instead of combined, so there's no
way of checking for the uniqueness when using more than one key. Is
this how it's supposed to work?

I'd expect...
<cfset validatesUniquenessOf(properties="key1,key2", message="combined
keys 1 and 2 aren't unique")>
...to check for records that exists on both keys.

If I wanted to check them independantly I could do this instead:
<cfset validatesUniquenessOf(properties="key1," message="key1 isn't
unique")>
<cfset validatesUniquenessOf(properties="key2", message="key2 isn't
unique")>

Per Djurner

unread,
Nov 26, 2009, 9:35:43 AM11/26/09
to cfwh...@googlegroups.com
Yes, that is the intended behavior.
To ensure uniqueness across multiple columns you can use the "scope" argument:
<cfset validatesUniquenessOf(properties="key1", scope="key2", message="combine keys 1 and 2 aren't unique")>


--

You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.



raulriera

unread,
Nov 26, 2009, 4:01:26 PM11/26/09
to ColdFusion on Wheels
Nice, I didn't know that :)

On Nov 26, 10:35 am, Per Djurner <per.djur...@gmail.com> wrote:
> Yes, that is the intended behavior.
> To ensure uniqueness across multiple columns you can use the "scope"
> argument:
> <cfset validatesUniquenessOf(properties="key1", scope="key2",
> message="combine keys 1 and 2 aren't unique")>
>
> On Thu, Nov 26, 2009 at 5:06 AM, Andy Bellenie
> <andybelle...@googlemail.com>wrote:
>
>
>
> > If you pass multiple properties into validatesUniquenessOf(), it
> > validates them in seperate queries instead of combined, so there's no
> > way of checking for the uniqueness when using more than one key. Is
> > this how it's supposed to work?
>
> > I'd expect...
> > <cfset validatesUniquenessOf(properties="key1,key2", message="combined
> > keys 1 and 2 aren't unique")>
> > ...to check for records that exists on both keys.
>
> > If I wanted to check them independantly I could do this instead:
> > <cfset validatesUniquenessOf(properties="key1," message="key1 isn't
> > unique")>
> > <cfset validatesUniquenessOf(properties="key2", message="key2 isn't
> > unique")>
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "ColdFusion on Wheels" group.
> > To post to this group, send email to cfwh...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscribe@googlegroups.c om>
> > .
Reply all
Reply to author
Forward
0 new messages