Re: TIP #185: Null Handling
From: Andreas Leitgeb (avl_at_gamma.logic.tuwien.ac.at)
Date: 04/13/04
- Next message: Andreas Leitgeb: "Re: Tk apps do not have a maximise button under KDE 3.2?"
- Previous message: Arjen Markus: "Re: Tcl_DoOneEvent() and message queue on Windows"
- In reply to: John H. Harris: "TIP #185: Null Handling"
- Next in thread: Arjen Markus: "Re: TIP #185: Null Handling"
- Reply: Arjen Markus: "Re: TIP #185: Null Handling"
- Reply: Jean-Claude Wippler: "Re: TIP #185: Null Handling"
- Reply: JHHarris: "Re: TIP #185: Null Handling"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 13 Apr 2004 09:40:19 GMT
John H Harris <JHHarris@valley.net> wrote:
> Tcl lacks the ability to handle /nulls/, data with missing or unknown
> values. In this TIP I suggest a means for representing and propagating
> nulls, and command modifications for manipulating them.
I disagree with the target of this TIP.
Tcl itself doesn't need a NULL value, but most likely your
database-extension needs some way to deal with NULLs.
I haven't yet done Database-stuff with tcl (only in C), but with
an ideal API, you should be able to specify a "one-or-zero-llength
list of strings" where your current db-API only accepts strings
directly, and have an empty list interpreted as null, whereas a list
containing an empty string distinguishable a non-NULL empty string.
Perhaps there even already exist db-extensions that do it this way.
> set result [ db eval {select id, name from person}
> foreach -null <unknown> { id name } $result {
> puts "$id: $name" }
proc value {li {def {}}} { if {[llength $li]} {lindex $li 0} {return $def} }
set result [ idealdb -list eval {select id, name from person} ]
foreach {_id _name} $result {
set id [value $_id <unknown>]; set name [value $_name <unknown>]
puts "$id: $name"
}
idealdb would use option -list to embed values in lists, and thus
make NULL-values recognizeable. That's not a proposal, just a
sketch on how it could be done. Similar list-embedding functionality
would be required for the API that writes values to the DB.
This list-embedding is principially equivalent to your quote-prepending,
but the main point is, that the db-extension has to translate the list
(or your quote)-trick to possible NULLs, forward and backward.
The database-extension would have to be modified anyway, (unless it
already has such an API).
- Next message: Andreas Leitgeb: "Re: Tk apps do not have a maximise button under KDE 3.2?"
- Previous message: Arjen Markus: "Re: Tcl_DoOneEvent() and message queue on Windows"
- In reply to: John H. Harris: "TIP #185: Null Handling"
- Next in thread: Arjen Markus: "Re: TIP #185: Null Handling"
- Reply: Arjen Markus: "Re: TIP #185: Null Handling"
- Reply: Jean-Claude Wippler: "Re: TIP #185: Null Handling"
- Reply: JHHarris: "Re: TIP #185: Null Handling"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]