From 69c9baddd5b29df61efaa2264faed74c292000a5 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sun, 21 Feb 2016 11:00:57 +0100 Subject: [PATCH] Replace alist-ref + apply with custom pred-alist-ref The alist-ref + apply version relied on the order alist-ref passes arguments to the equality procedure. However, this order is not guaranteed to be stable and in fact will change with CHICKEN 4.11 so this version is replaced with a custom procedure pred-alist-ref to avoid this issue. --- ssql.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ssql.scm b/ssql.scm index 761646b..48f2382 100644 --- a/ssql.scm +++ b/ssql.scm @@ -185,7 +185,7 @@ (else (error "unknown operator syntax type" type)))) ((ssql->sql ssql) - (let ((handler (alist-ref (list ssql) (self 'type->sql-converters) apply))) + (let ((handler (pred-alist-ref ssql (self 'type->sql-converters)))) (if handler (self handler ssql) (error "unknown datatype" ssql)))) @@ -253,8 +253,14 @@ (define (register-sql-engine! predicate translator) (set! *sql-engines* (alist-cons predicate translator *sql-engines*))) +(define (pred-alist-ref key alist) + (and-let* ((result (find (lambda (pair) + ((car pair) key)) + alist))) + (cdr result))) + (define (get-sql-engine connection) - (alist-ref (list connection) *sql-engines* apply)) + (pred-alist-ref connection *sql-engines*)) (define (call-with-sql-engine connection proc) (let ((engine (get-sql-engine connection)))