[postmodern-devel] Unbound slots on nullable values?

Ryan Davis ryan at acceleration.net
Tue Mar 18 17:57:33 UTC 2008


If you want trx to be null by default, try changing the slot definition:

(trx :type (or integer db-null) :initarg :trx :accessor trx :initform nil)

HTH,

Ryan Davis
Acceleration.net
Director of Programming Services
2831 NW 41st street, suite B
Gainesville, FL 32606

Office: 352-335-6500 x 124
Fax: 352-335-6506



Mikko Ahonen wrote:
> Hello,
>
> I am new to the list, so please forgive me if this is a stupid user error.
>
> Am I doing something wrong or is there a bug in how postmodern handles
> non-null fields?
>
> Even very simple dao reports that slot is unbound although according
> table-description value may be NULL.
>
> This is the message I get:
>
>  The slot TRX is unbound in the object #<KOE {11BA1751}>.
>
> I run
> - Postgres 8.3
> - OS X Leopard 10.5.2
> - SBCL 1.0.7
> -  I installed latest postmodern today.
>
> I attached output below.
>
> Best regards,
>
> Mikko Ahonen
>
> --
>
> (asdf:oos 'asdf:load-op :postmodern)
> (use-package :postmodern)
>
> ; loading system definition from
> ; /usr/local/lib/sbcl/site-systems/postmodern.asd into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM :POSTMODERN {11E033B9}> as POSTMODERN
> ; registering #<SYSTEM :POSTMODERN-TESTS {11F4BC91}> as POSTMODERN-TESTS
> ; loading system definition from
> ; /usr/local/lib/sbcl/site-systems/bordeaux-threads.asd into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM BORDEAUX-THREADS {120D0031}> as BORDEAUX-THREADS
> ; registering #<SYSTEM BORDEAUX-THREADS-TEST {11636C29}> as
> ; BORDEAUX-THREADS-TEST
> ; loading system definition from /usr/local/lib/sbcl/site-systems/s-sql.asd
> ; into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM :S-SQL {117B6C01}> as S-SQL
> ; loading system definition from
> ; /usr/local/lib/sbcl/site-systems/simple-date.asd into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM :SIMPLE-DATE {1191A041}> as SIMPLE-DATE
> ; registering #<SYSTEM :SIMPLE-DATE-TESTS {11A4BFB1}> as SIMPLE-DATE-TESTS
> ; loading system definition from
> ; /usr/local/lib/sbcl/site-systems/cl-postgres.asd into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM :CL-POSTGRES {11BDA379}> as CL-POSTGRES
> ; registering #<SYSTEM :CL-POSTGRES-TESTS {11D181D1}> as CL-POSTGRES-TESTS
> ; loading system definition from
> ; /usr/local/lib/sbcl/site-systems/trivial-utf-8.asd into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM :TRIVIAL-UTF-8 {11E8E3A1}> as TRIVIAL-UTF-8
> ; registering #<SYSTEM :TRIVIAL-UTF-8-TESTS {11FCC3B1}> as TRIVIAL-UTF-8-TESTS
> ; loading system definition from
> ; /usr/local/lib/sbcl/site-systems/ieee-floats.asd into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM :IEEE-FLOATS {1214B319}> as IEEE-FLOATS
> ; registering #<SYSTEM :IEEE-FLOATS-TESTS {122CFC91}> as IEEE-FLOATS-TESTS
> ; loading system definition from /usr/local/lib/sbcl/site-systems/usocket.asd
> ; into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM USOCKET {11783E61}> as USOCKET
> ; loading system definition from
> ; /usr/local/lib/sbcl/site-systems/split-sequence.asd into #<PACKAGE "ASDF0">
> ; registering #<SYSTEM :SPLIT-SEQUENCE {11938B69}> as SPLIT-SEQUENCE
> ; loading system definition from /usr/local/lib/sbcl/site-systems/md5.asd into
> ; #<PACKAGE "ASDF0">
> ; registering #<SYSTEM MD5 {11ABD991}> as MD5
> WARNING: Either there is no Bordeaux-threads support for your
> implementation, or your implementation does not support threads
> therefore some features may not work. Feel free to implement it, or
> bug one of the maintainers to do so if your lisp supports threads at
> all.
> STYLE-WARNING: implicitly creating new generic function SOCKET-ACCEPT
> NIL
> *
> T
> (defparameter *db* "foobar")
>
> *DB*
> (defparameter *db-user* "mikko")
>
> *DB-USER*
> (defparameter *db-pwd* "")
>
> *DB-PWD*
> (defparameter *db-host* "localhost")
>
>
> *DB-HOST*
> * (connect-toplevel *db* *db-user* *db-pwd* *db-host*)
>
> (deftable koe ()
>  ((data-id :type integer :initarg :data-id :accessor data-id)
>   (ver :type (or integer db-null) :initarg :ver :accessor ver)
>   (trx :type (or integer db-null) :initarg :trx :accessor trx))
>
>   (:class-name koe)
>   (:indices data-id))
>
> * (drop-table 'koe)
>
> NIL
> * (create-table 'koe)
> WARNING:
>   Postgres warning: CREATE TABLE / PRIMARY KEY will create implicit
> index "koe_pkey" for table "koe"
>
> NIL
> * (make-instance 'koe :data-id 1 :ver 3)
>
> #<KOE {11B3EB71}>
> * (table-description 'koe)
>
> (("data_id" "int4" NIL) ("ver" "int4" T) ("trx" "int4" T))
> * (make-instance 'koe :data-id 1 :ver 3)
>
> #<KOE {11BA1751}>
> * (save-dao *)
>
> debugger invoked on a UNBOUND-SLOT:
>  The slot TRX is unbound in the object #<KOE {11BA1751}>.
>
> Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
>
> restarts (invokable by number or by possibly-abbreviated name):
>  0: [USE-VALUE  ] Return a value as the slot-value.
>  1: [STORE-VALUE] Store and return a value as the slot-value.
>  2: [ABORT      ] Exit debugger, returning to top level.
>
> ((SB-PCL::FAST-METHOD SLOT-UNBOUND (T T T))
>  #<unavailable argument>
>  #<unavailable argument>
>  #<unavailable argument>
>  #<KOE {11BA1751}>
>  TRX)
> 0] 2
> _______________________________________________
> postmodern-devel mailing list
> postmodern-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
>
>   



More information about the postmodern-devel mailing list