Changeset 14755 in project


Ignore:
Timestamp:
05/23/09 17:25:06 (10 years ago)
Author:
sjamaan
Message:

Columns are symbols

Location:
release/4/postgresql/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/postgresql/trunk/postgresql.scm

    r14754 r14755  
    390390(define (result-column result index)
    391391  (check-result-column-index! result index 'result-column)
    392   (PQfname (pg-result-ptr result) index))
     392  (string->symbol (PQfname (pg-result-ptr result) index)))
    393393
    394394(define (result-columns result)
     
    398398    (if (= idx 0)
    399399        row
    400         (loop ptr (cons (PQfname ptr (sub1 idx)) row) (sub1 idx)))))
     400        (loop ptr (cons (string->symbol
     401                         (PQfname ptr (sub1 idx))) row) (sub1 idx)))))
    401402
    402403(define (result-column-index result name)
    403   (let ((idx (PQfnumber (pg-result-ptr result) name)))
     404  (let ((idx (PQfnumber (pg-result-ptr result) (symbol->string name))))
    404405    (and (>= idx 0) idx)))
    405406
  • release/4/postgresql/trunk/tests/run.scm

    r14754 r14755  
    4343        (result-column-count (exec-query conn "SELECT 1, 2, 3, 4")))
    4444  (test "Correct column name"
    45         "one"
     45        one
    4646        (result-column
    4747         (exec-query conn "SELECT 1 AS one, 2 AS two") 0))
    4848  (test "Correct column names"
    49         '("one" "two")
     49        '(one two)
    5050        (result-columns
    5151         (exec-query conn "SELECT 1 AS one, 2 AS two")))
     
    5454               (exec-query conn "SELECT 1 AS one, 2 AS two") 3))
    5555  (test "Not false for nameless column"
    56         #f ;; Could check for "?column?", but that's a bit too specific
     56        #f ;; Could check for ?column?, but that's a bit too specific
    5757        (not (result-column
    5858              (exec-query conn "SELECT 1, 2") 0)))
     
    6464        0
    6565        (result-column-index
    66          (exec-query conn "SELECT 1 AS one, 2 AS two") "one"))
     66         (exec-query conn "SELECT 1 AS one, 2 AS two") 'one))
    6767  (test "False column index for nonexistant column name"
    6868        #f
    6969        (result-column-index
    70          (exec-query conn "SELECT 1 AS one, 2 AS two") "foo"))
     70         (exec-query conn "SELECT 1 AS one, 2 AS two") 'foo))
    7171  (test "False oid for virtual table"
    7272        #f
Note: See TracChangeset for help on using the changeset viewer.