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)
21 (deftest :int/convert/1
22 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT FOO FROM BAR")
23 "SELECT FOO FROM BAR")
25 (deftest :int/convert/2
26 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT FOO FROM BAR WHERE ID=?")
27 "SELECT FOO FROM BAR WHERE ID=$1")
29 (deftest :int/convert/3
30 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT FOO FROM \"BAR\" WHERE ID=? AND CODE=?")
31 "SELECT FOO FROM \"BAR\" WHERE ID=$1 AND CODE=$2")
33 (deftest :int/convert/4
34 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT FOO FROM BAR WHERE ID=\"Match?\" AND CODE=?")
35 "SELECT FOO FROM BAR WHERE ID=\"Match?\" AND CODE=$1")
37 (deftest :int/convert/5
38 (clsql-sys::prepared-sql-to-postgresql-sql "SELECT 'FOO' FROM BAR WHERE ID='Match?''?' AND CODE=?")
39 "SELECT 'FOO' FROM BAR WHERE ID='Match?''?' AND CODE=$1")
41 (deftest :int/output-caching/1
42 #.(locally-enable-sql-reader-syntax)
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 #.(locally-enable-sql-reader-syntax)
64 ;; ensure that we can disable the output cache and
65 ;; still have everything work
66 (let ((clsql-sys::*output-hash*))
67 (list (clsql:sql [foo]) (clsql:sql [foo]) (clsql:sql [foo.bar])))
68 ("FOO" "FOO" "FOO.BAR"))