Re: IF NOT EXISTS on UPDATE statements?

2014-12-30 Thread DuyHai Doan
persons or entities other than the intended recipient is > strictly prohibited. > > > > > From: Robert Stupp > Reply-To: > Date: Tuesday, November 18, 2014 at 2:26 PM > To: > Subject: Re: IF NOT EXISTS on UPDATE statements? > > > For (2), we would lov

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Brian O'Neill
prohibited. From: Robert Stupp Reply-To: Date: Tuesday, November 18, 2014 at 2:26 PM To: Subject: Re: IF NOT EXISTS on UPDATE statements? > > For (2), we would love to see: > UPSERT value=new_value where (not exists || value=read_value) > That would be something like &q

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Robert Stupp
> > For (2), we would love to see: > UPSERT value=new_value where (not exists || value=read_value) > That would be something like "UPDATE … IF column=value OR NOT EXISTS“. Took at the C* source and that feels like a LHF (for 3.0) so I opened https://issues.apache.org/jira/browse/CASSANDRA-8335

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Brian O'Neill
persons or entities other than the intended recipient is strictly prohibited. From: Robert Stupp Reply-To: Date: Tuesday, November 18, 2014 at 12:35 PM To: Subject: Re: IF NOT EXISTS on UPDATE statements? >> > There is no way to mimic IF NOT EXISTS on UPDATE and it's not a bug.

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Robert Stupp
> > There is no way to mimic IF NOT EXISTS on UPDATE and it's not a bug. INSERT > > and UPDATE are not totally orthogonal > in CQL and you should use INSERT for actual insertion and UPDATE for updates > (granted, the database will not reject > our query if you break this rule but it's nonetheles

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Kevin Burton
> There is no way to mimic IF NOT EXISTS on UPDATE and it's not a bug. INSERT and UPDATE are not totally orthogonal in CQL and you should use INSERT for actual insertion and UPDATE for updates (granted, the database will not reject our query if you break this rule but it's nonetheless the way it's

Re: IF NOT EXISTS on UPDATE statements?

2014-11-18 Thread Sylvain Lebresne
On Mon, Nov 17, 2014 at 10:52 PM, Kevin Burton wrote: > There’s still a lot of weirdness in CQL. > > For example, you can do an INSERT with an UPDATE .. .which I’m generally > fine with. Kind of make sense. > > However, with INSERT you can do IF NOT EXISTS. > > … but you can’t do the same thing

Re: IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread Kevin Burton
Oh yes. That will work because a value is already there. I’m talking if the value does not exist. Otherwise I’d have to insert a null first. On Mon, Nov 17, 2014 at 3:30 PM, DuyHai Doan wrote: > Just tested with C* 2.1.1 > > cqlsh:test> CREATE TABLE simple(id int PRIMARY KEY, val text); > cqlsh

Re: IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread DuyHai Doan
Just tested with C* 2.1.1 cqlsh:test> CREATE TABLE simple(id int PRIMARY KEY, val text); cqlsh:test> INSERT INTO simple (id) VALUES (1); cqlsh:test> SELECT * FROM simple ; id | val +-- 1 | null (1 rows) cqlsh:test> UPDATE simple SET val = 'new val' WHERE id=1 *IF val = null*; [appl

Re: IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread Kevin Burton
> "you can still do IF on UPDATE though… but it’s not possible to do IF > mycolumn IS NULL" --> If mycolumn = null should work > > Alas.. it doesn’t :-/ -- Founder/CEO Spinn3r.com Location: *San Francisco, CA* blog: http://burtonator.wordpress.com … or check out my Google+ profile

Re: IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread DuyHai Doan
"So I foolishly wrote all my code assuming that INSERT/UPDATE were orthogonal, but now they’re not" There are some subtle differences. INSERT will create marker columns, UPDATE won't touch/modify them. What are marker columns ? Some insights here: http://www.slideshare.net/doanduyhai/cassandra-

IF NOT EXISTS on UPDATE statements?

2014-11-17 Thread Kevin Burton
There’s still a lot of weirdness in CQL. For example, you can do an INSERT with an UPDATE .. .which I’m generally fine with. Kind of make sense. However, with INSERT you can do IF NOT EXISTS. … but you can’t do the same thing on UPDATE. So I foolishly wrote all my code assuming that INSERT/UPD