[Ur] select .. where a <> NULL is not working

Sergey Mironov grrwlf at gmail.com
Tue Jun 17 18:01:57 EDT 2014


Hi. I've just discovered that Ur/Web maps option'ed values to
NULL/non-NULL representation in the database. Unfortunately, there are
a big pitfall. Looks like <> NULL clause does not selects all non-NULL
values. For me it always selects no rows. For example, consider the
following program:


table a : { A : option int }
task initialize = fn _ =>
  dml(INSERT INTO a(A) VALUES ({[Some 1]}));
  r <- oneRow1(SELECT * FROM a WHERE a.A <> {[None]});
  debug "OK"



Instead of printing OK it fails with
Failed to initialize database!
/home/grwlf/local/lib/urweb/ur/top.ur:366:24-367:3: Query returned no
rows

Probably, 'a <> b' should be mapped to 'a IS NOT NULL'  or to 'b IS
NOT NULL' if one of arguments evaluate to NULL, but stay in form 'a <>
b' otherwise.  In other words, the situation is complex, since
databases have special NULL algebra..

Please, help!
Sergey.



More information about the Ur mailing list