Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
submarine
submarine
Commits
c8fdfc9a
Commit
c8fdfc9a
authored
Aug 20, 2007
by
ryszard.szopa
Browse files
with-transaction added to create-table, export get-id.
darcs-hash:eabf7415a6af57c8fb59be3a75f71f96211da476
parent
8790c947
Changes
2
Hide whitespace changes
Inline
Side-by-side
db.lisp
View file @
c8fdfc9a
...
...
@@ -32,19 +32,20 @@ names is used."))
(
list
:type
(
if
(
not-null-p
slot
)
(
slot-definition-type
slot
)
`
(
or
db-null
,
(
slot-definition-type
slot
)))))))
(
postmodern:execute
(
sql-compile
`
(
:create-table
,
class-name
,
(
iter
(
for
slot
in
(
class-non-transient-slots
class
))
(
collect
(
cons
(
slot-definition-name
slot
)
(
type-and-reference
slot
))))
(
:primary-key
id
))))
;id is hardcoded as a primary key
(
dolist
(
index
(
mapcar
(
lambda
(
x
)
(
if
(
consp
x
)
x
(
list
x
)))(
db-class-indices
class
)))
(
postmodern:execute
(
sql-compile
`
(
:create-index
(
:raw
,
(
index-name
index
))
:on
,
class-name
:fields
,@
index
))))
(
postmodern:execute
(
:create-sequence
(
id-seq-name
class
)))))
(
postmodern:with-transaction
()
(
postmodern:execute
(
sql-compile
`
(
:create-table
,
class-name
,
(
iter
(
for
slot
in
(
class-non-transient-slots
class
))
(
collect
(
cons
(
slot-definition-name
slot
)
(
type-and-reference
slot
))))
(
:primary-key
id
))))
;id is hardcoded as a primary key
(
dolist
(
index
(
mapcar
(
lambda
(
x
)
(
if
(
consp
x
)
x
(
list
x
)))(
db-class-indices
class
)))
(
postmodern:execute
(
sql-compile
`
(
:create-index
(
:raw
,
(
index-name
index
))
:on
,
class-name
:fields
,@
index
))))
(
postmodern:execute
(
:create-sequence
(
id-seq-name
class
))))))
(
database-error
(
err
)
(
if
(
string=
(
database-error-code
err
)
"42P07"
)
;table already exists
(
progn
...
...
package.lisp
View file @
c8fdfc9a
...
...
@@ -11,5 +11,5 @@
#:class-name-of
#:class-non-transient-slots
#:slot-value-or-id-if-foreign
#:with-connection
#:with-object-connection
#:with-class-connection
#:dao
#:defdao
#:save-dao
#:dao-exists-p
#:insert-dao
#:update-dao
#:select-dao
#:get-dao
))
#:dao
#:defdao
#:save-dao
#:dao-exists-p
#:insert-dao
#:update-dao
#:select-dao
#:get-dao
#:get-id
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment