Make sql-null
a transparent struct.
This allows it to cooperate better with Typed Racket, particularly regarding the `Any` type. The guard and use of `#:authentic` also check that it's still a singleton in all cases.
This commit is contained in:
parent
de82588e08
commit
25efc68b17
|
@ -11,15 +11,23 @@
|
||||||
;; NULL
|
;; NULL
|
||||||
|
|
||||||
(define-values (sql-null sql-null?)
|
(define-values (sql-null sql-null?)
|
||||||
(let ()
|
(let ([created? #false])
|
||||||
(struct sql-null ()
|
(struct sql-null ()
|
||||||
;; must deserialize to singleton, so can't just use serializable-struct
|
#:transparent
|
||||||
#:property prop:serializable
|
#:authentic
|
||||||
(make-serialize-info (lambda _ '#())
|
#:guard (lambda (n)
|
||||||
#'deserialize-info:sql-null-v0
|
(when created?
|
||||||
#f
|
(error 'sql-null "cannot create new instances of sql-null"))
|
||||||
(or (current-load-relative-directory)
|
(set! created? #true)
|
||||||
(current-directory))))
|
(values))
|
||||||
|
#:property prop:custom-write (lambda (v p w?) (write-string "#<sql-null>" p))
|
||||||
|
;; must deserialize to singleton, so can't just use serializable-struct
|
||||||
|
#:property prop:serializable
|
||||||
|
(make-serialize-info (lambda _ '#())
|
||||||
|
#'deserialize-info:sql-null-v0
|
||||||
|
#f
|
||||||
|
(or (current-load-relative-directory)
|
||||||
|
(current-directory))))
|
||||||
(values (sql-null) sql-null?)))
|
(values (sql-null) sql-null?)))
|
||||||
|
|
||||||
(define (sql-null->false x)
|
(define (sql-null->false x)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user