Hi,
I'm just exploring the db.tuples vocabulary, it's fantastic.
Unfortunately there's rather little documentation, so I had to figure
out some things myself. For Example: when I define a slot as
+foreign-key+, there are certain useful triggers inserted in my db. It
is not allowed then, to insert a tuple, with that slot set to f (=
NULL). Isn't that, what the flag +not-null+ should add?
However, when I add the rather confusingly named +not-null+ to the
declaration, the trigger is more complex. I _think_ it should allow
for tuples, that have either a valid foreign id set in the slot, or f
(= NULL).
In sqlite.factor:243 (in insert-trigger-not-null) it says:

WHERE NEW.${foreign-table-id} IS NOT NULL
                AND (SELECT ${foreign-table-id} FROM ${foreign-table}
WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL;

That does not make much sense to me, since it asks for the ID-column
of the foreign table _from the current table_. Ids are always called
"ID" in my case, so at first it didn't matter. But it won't allow you
to insert a tuple with a foreign-id = NULL. So I think it should be:

WHERE NEW.${table-id} IS NOT NULL
                AND (SELECT ${foreign-table-id} FROM ${foreign-table}
WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL;

 ${table-id} being the column-name of the foreign id in the current
table. It's still weird though, since that is the behaviour the
trigger should have in case +not-null+ is _not_ given. I'm thoroughly
confused.
Please, help.

Ben

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to