[racket] Bug in racket db module ??

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Mon Apr 30 17:58:08 EDT 2012

> 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:


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:


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

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.

Posted on the users mailing list.