[racket] Bug in racket db module ??
> I am using the racket 'db' module to interact with my postgresql database. I
> think there is some mismatch in the documentation towards the end of section
> 1.1. Here is my sample repl session.
>
>> (define get-less-than-pst
> (prepare pgc "select n from the_numbers where n < $1"))
>
>> (query-list pgc get-less-than-pst 1)
> '(0)
>> (query-list pgc (bind-prepared-statement get-less-than-pst 2))
> . . bind-prepared-statement: contract violation, expected: list?, given: 2
> contract from: <collects>/db/base.rkt, blaming: anonymous-module
> contract:
> (-> prepared-statement? list? any)
> at: <collects>/db/base.rkt:125.2
Agreed. The documentation near the end of:
http://docs.racket-lang.org/db/introduction.html
appears to be passing 2, rather than a list containing 2.
> After checking the documentation for the 'bind-prepared-statement' it
> expects a variable and a list as it parameter types. Is this correct or am I
> missing something?
I think it should be:
(query-list pgc (bind-prepared-statement get-less-than-pst
(list 2)))
In fact, that's how it's done in the documentation later on:
http://docs.racket-lang.org/db/query-api.html#(def._((lib._db/main..rkt)._bind-prepared-statement))
so I suspect the documentation is wrong.
But that's really surprising: I would have expected the documentation
to be "live", in the sense of being generated by running Racket, so
this should have been caught earlier. Checking...
(reading through
http://git.racket-lang.org/plt/blob_plain/HEAD:/collects/db/scribblings/introduction.scrbl
...)
Ah! Ok, it's not live. It's not using Scribble's @interaction form,
but something else that doesn't do real Racket evaluation. That's why
the documentation is deviating.