On Sat, 9 Mar 2013 09:43:35 -0800
Peter Haworth <p...@lcsql.com> wrote:

> Seems like there are several ways to skin this cat.  The problem I
> have with CHECK is the generic error message it produces.  If a table
> has several columns with CHECK statements, how does my application
> know which one failed?  

Well, yes, that's a problem, and it won't be remedied easily.  

Looking at the sources, the name of the constraint would have to be
dragged from the parser through the virtual machine, where it would be
associated with the generated code that enforces the constraint.
Compare that with, for instance, verifying a uniqueness constraint for
a key: when that fails the message "column FOO is not unique" is
relatively easy to generate because the offending column name is readily
available.  

--jkl

> 
> On Sat, Mar 9, 2013 at 9:00 AM, <sqlite-users-requ...@sqlite.org>
> wrote:
> 
> > Message: 17
> > Date: Fri, 8 Mar 2013 14:26:06 -0500
> > From: "James K. Lowden" <jklow...@schemamania.org>
> > To: sqlite-users@sqlite.org
> > Subject: Re: [sqlite] SQLite strong-typing [WAS: inner vs. outer
> > join inconsistency]
> > Message-ID: <20130308142606.15776668.jklow...@schemamania.org>
> > Content-Type: text/plain; charset=ISO-8859-1
> >
> > On Thu, 7 Mar 2013 19:20:44 +0100
> > Petite Abeille <petite.abei...@gmail.com> wrote:
> >
> > > > In conclusion, if you want to allow affine type conversions on
> > > > INSERT, but not disallow values that cannot be so converted,
> > > > then CHECK(my_column = CAST(my_column AS <TYPE>)) works.  And
> > > > if you want to disallow values of incorrect types even when
> > > > type conversion is possible then use CHECK(typeof(my_column =
> > > > <TYPE>).  That's pretty cool, IMO.
> > >
> > > Yeah? 'cool' is not necessarily how I would describe it? having a
> > > check constraint 'magically' coerce - change! - the inserted data
> > > type is? well? not cool. I would call it a misfeature :)
> >
> > To be clear, the contraints Nico described don't coerce anything.
> > By preventing the insertion of values outside the column's domain
> > (per its affinity), the constraints ensure that future coersions --
> > as part of a join, say -- won't lose data.
> >
> 
> 
> 
> Pete
> lcSQL Software <http://www.lcsql.com>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to