Coverage report: /home/ati/workspace/perec/persistence/oid.lisp

KindCoveredAll%
expression1517 88.2
branch22100.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;; -*- mode: Lisp; Syntax: Common-Lisp; -*-
2
 ;;;
3
 ;;; Copyright (c) 2006 by the authors.
4
 ;;;
5
 ;;; See LICENCE for details.
6
 
7
 (in-package :cl-perec)
8
 
9
 (defstruct oid
10
   "The oid holds sufficient information to access the same persistent object at any time in the database unless it has been deleted. The oid of an object is constant for the whole lifetime of the object and cannot be changed. It is assigned when the persistent object is first time stored in the database."
11
   (id
12
    nil
13
    :type (or null integer))
14
   (class-name
15
    nil
16
    :type (or null symbol)))
17
 
18
 (defparameter +oid-sequence-name+ "_OID"
19
   "The name of the oid sequence in the relational database used to generate life time unique identifiers for all persistent objects.")
20
 
21
 (defparameter +id-column-name+ '_id
22
   "The RDBMS table column name for the oid's id slot.")
23
 
24
 (defparameter +class-name-column-name+ '_class_name
25
   "The RDBMS table column name for the oid's class name slot.")
26
 
27
 (defparameter +oid-column-names+ (list +id-column-name+ +class-name-column-name+)
28
   "All RDBMS table column names for an oid. The order of columns does matter.")
29
 
30
 (defparameter *oid-sequence-exists* #f
31
   "Tells if the oid sequence exists in the relational database or not. This flag is initially false but will be set to true as soon as the sequence is created or first time seen in the database.")
32
 
33
 (defun make-new-oid (class-name)
34
   "Creates a fresh new oid which was never used before. It never returns the same oid or an oid that is already used."
35
   (or *oid-sequence-exists* (ensure-oid-sequence))
36
   (make-oid :id (sequence-next +oid-sequence-name+) :class-name class-name))
37
 
38
 (defun ensure-oid-sequence ()
39
   "Makes sure the oid sequence exists in the database."
40
   (unless (sequence-exists-p +oid-sequence-name+)
41
     (create-sequence +oid-sequence-name+))
42
   (setf *oid-sequence-exists* #t))