I don't see the issue with that.  Unless you want it to fail anyhow?

You have a unique key.  You execute an update that sets all rows to have the 
same unique key.  Using UPDATE OR REPLACE implies that you want SQLite to do 
the right thing, which is end up with a single row.

Do you see the 'right thing' as being different?

> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of Petite Abeille
> Sent: Monday, May 07, 2012 10:05 AM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Bug: Increment unique integer field
> 
> 
> On May 7, 2012, at 3:44 PM, Pavel Ivanov wrote:
> 
> > It's a well documented feature: "or replace" means "if you see
> > constraint violations while updating please delete all violating rows
> > and then proceed with update"
> 
> Yep, I'm familiar with the ON CONFLICT clause. Or I thought I was as I
> haven't fully internalize its dramatic implication in relation to
> update statements.
> 
> For example, delete all your rows but one with one easy update
> statement:
> 
> sqlite> create table numbers(num int unique ); insert into numbers( num
> sqlite> ) values( 1 ); insert into numbers( num )  values( 2 ); insert
> sqlite> into numbers( num )  values( 3 ); insert into numbers( num )
> sqlite> values( 4 ); insert into numbers( num )  values( 5 ); select
> sqlite> count( * ) from numbers;
> 5
> sqlite> update or replace numbers set num = 1; select count( * ) from
> sqlite> numbers;
> 1
> 
> Oh, well... caveat emptor...
> _______________________________________________
> 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