Coverage report: /home/ati/workspace/perec/persistence/oid.lisp
Kind | Covered | All | % |
expression | 15 | 17 | 88.2 |
branch | 2 | 2 | 100.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;; -*- mode: Lisp; Syntax: Common-Lisp; -*-
3
;;; Copyright (c) 2006 by the authors.
5
;;; See LICENCE for details.
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."
13
:type (or null integer))
16
:type (or null symbol)))
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.")
21
(defparameter +id-column-name+ '_id
22
"The RDBMS table column name for the oid's id slot.")
24
(defparameter +class-name-column-name+ '_class_name
25
"The RDBMS table column name for the oid's class name slot.")
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.")
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.")
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))
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))