Changeset 36672 in project


Ignore:
Timestamp:
09/30/18 17:28:57 (2 weeks ago)
Author:
chust
Message:

[sqlite3] Proper support for integers in the 64-bit range (thanks to wasamasa)

Location:
release/5/sqlite3/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • release/5/sqlite3/trunk/sqlite3.egg

    r36618 r36672  
    33 (author "Thomas Chust")
    44 (license "BSD")
    5  (version "3.7.1")
     5 (version "3.7.2")
    66 (dependencies
    77   srfi-1 srfi-13 srfi-18 srfi-69 object-evict
  • release/5/sqlite3/trunk/sqlite3.html

    r22421 r36672  
    370370<td><tt>integer: #t = 1, #f = 0</tt></td></tr>
    371371<tr>
    372 <td><tt>fixnum?</tt></td>
     372<td><tt>exact-integer?</tt></td>
    373373<td><tt>integer</tt></td></tr>
    374374<tr>
  • release/5/sqlite3/trunk/sqlite3.scm

    r36618 r36672  
    433433          "sqlite3_result_blob(ctx, v, n, SQLITE_TRANSIENT);")
    434434        ctx v (blob-size v))]
    435     [(or (and (fixnum? v) v) (and (boolean? v) (if v 1 0)))
    436       => (lambda (v)
    437           ((foreign-lambda void "sqlite3_result_int" sqlite3:context int)
    438             ctx v))]
     435    [(boolean? v)
     436      ((foreign-lambda void "sqlite3_result_int" sqlite3:context bool)
     437        ctx v)]
     438    [(exact-integer? v)
     439      ((foreign-lambda void "sqlite3_result_int64" sqlite3:context integer64)
     440        ctx v)]
    439441    [(real? v)
    440442      ((foreign-lambda void "sqlite3_result_double" sqlite3:context double)
     
    764766              stmt (fx+ i 1) v (blob-size v))
    765767        => (abort-sqlite3-error 'bind! (statement-database stmt) stmt i v)])]
    766     [(or (and (fixnum? v) v) (and (boolean? v) (if v 1 0)))
    767       => (lambda (v)
    768           (cond [((foreign-lambda sqlite3:status "sqlite3_bind_int"
    769                     sqlite3:statement int int)
    770                   stmt (fx+ i 1) v)
    771             => (abort-sqlite3-error 'bind! (statement-database stmt) stmt i v)]))]
     768    [(boolean? v)
     769      (cond [((foreign-lambda sqlite3:status "sqlite3_bind_int"
     770                sqlite3:statement int bool)
     771              stmt (fx+ i 1) v)
     772        => (abort-sqlite3-error 'bind! (statement-database stmt) stmt i v)])]
     773    [(exact-integer? v)
     774      (cond [((foreign-lambda sqlite3:status "sqlite3_bind_int64"
     775                sqlite3:statement int integer64)
     776              stmt (fx+ i 1) v)
     777        => (abort-sqlite3-error 'bind! (statement-database stmt) stmt i v)])]
    772778    [(real? v)
    773779      (cond [((foreign-lambda sqlite3:status "sqlite3_bind_double"
     
    870876            (string-contains-ci type "bool"))
    871877        ((foreign-lambda bool "sqlite3_column_int" sqlite3:statement int) stmt i)
    872         ((foreign-lambda integer "sqlite3_column_double" sqlite3:statement int) stmt i))]
     878        ((foreign-lambda integer64 "sqlite3_column_int64" sqlite3:statement int) stmt i))]
    873879    [(float)
    874880      ((foreign-lambda double "sqlite3_column_double" sqlite3:statement int) stmt i)]
  • release/5/sqlite3/trunk/tests/run.scm

    r36618 r36672  
    169169          db "SELECT id, data FROM Foo;")))
    170170
     171    (test "inserting fixnums and bignums"
     172      '(10000000 10000000000)
     173      (with-database [db ":memory:"]
     174        (execute db "CREATE TABLE Foo (id INTEGER PRIMARY KEY, data INTEGER);")
     175        (update db "INSERT INTO Foo (data) VALUES (?);" 10000000) ; fixnum
     176        (update db "INSERT INTO Foo (data) VALUES (?);" 10000000000) ; bignum
     177        (map-row identity db "SELECT data FROM Foo;")))
     178
    171179    (test "parameter count"
    172180      3
Note: See TracChangeset for help on using the changeset viewer.