1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: test-internal.lisp
6 ;;;; Purpose: Tests for internal clsql functions
7 ;;;; Author: Kevin M. Rosenberg
10 ;;;; This file, part of CLSQL, is Copyright (c) 2004-2010 by Kevin M. Rosenberg
12 ;;;; CLSQL users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
17 (in-package #:clsql-tests)
18 (clsql-sys:file-enable-sql-reader-syntax)
22 (deftest :int/convert/1
23 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT FOO FROM BAR")
24 "SELECT FOO FROM BAR")
26 (deftest :int/convert/2
27 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT FOO FROM BAR WHERE ID=?")
28 "SELECT FOO FROM BAR WHERE ID=$1")
30 (deftest :int/convert/3
31 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT FOO FROM \"BAR\" WHERE ID=? AND CODE=?")
32 "SELECT FOO FROM \"BAR\" WHERE ID=$1 AND CODE=$2")
34 (deftest :int/convert/4
35 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT FOO FROM BAR WHERE ID=\"Match?\" AND CODE=?")
36 "SELECT FOO FROM BAR WHERE ID=\"Match?\" AND CODE=$1")
38 (deftest :int/convert/5
39 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT 'FOO' FROM BAR WHERE ID='Match?''?' AND CODE=?")
40 "SELECT 'FOO' FROM BAR WHERE ID='Match?''?' AND CODE=$1")
42 (deftest :int/output-caching/1
43 ;; ensure that key generation and matching is working
44 ;; so that this table doesnt balloon (more than designed)
46 (progn (clsql:sql [foo])
48 (hash-table-count clsql-sys::*output-hash*))
50 (progn (clsql:sql [foo.bar])
52 (hash-table-count clsql-sys::*output-hash*))
53 (progn (clsql:sql (clsql-sys:sql-expression
54 :table (clsql-sys::database-identifier 'foo)
55 :attribute (clsql-sys::database-identifier 'bar)))
56 (clsql:sql (clsql-sys:sql-expression
57 :table (clsql-sys::database-identifier 'foo)
58 :attribute (clsql-sys::database-identifier 'bar)))
59 (hash-table-count clsql-sys::*output-hash*)))
62 (deftest :int/output-caching/2
63 ;; ensure that we can disable the output cache and
64 ;; still have everything work
65 (let ((clsql-sys::*output-hash*))
66 (list (clsql:sql [foo]) (clsql:sql [foo]) (clsql:sql [foo.bar])))
67 ("FOO" "FOO" "FOO.BAR"))