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.
master
Moritz Heidkamp 9 years ago
parent e3911142b9
commit 69c9baddd5

@ -185,7 +185,7 @@
(else (error "unknown operator syntax type" type)))) (else (error "unknown operator syntax type" type))))
((ssql->sql ssql) ((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 (if handler
(self handler ssql) (self handler ssql)
(error "unknown datatype" ssql)))) (error "unknown datatype" ssql))))
@ -253,8 +253,14 @@
(define (register-sql-engine! predicate translator) (define (register-sql-engine! predicate translator)
(set! *sql-engines* (alist-cons predicate translator *sql-engines*))) (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) (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) (define (call-with-sql-engine connection proc)
(let ((engine (get-sql-engine connection))) (let ((engine (get-sql-engine connection)))

Loading…
Cancel
Save