Closed wnortje closed 8 years ago
I'm not sure I understand the problem. Do you have an example of this behaviour? At least in the tests it seems to work.
CREATE and SINGLE returns objects while SINGLE! and SINGLE-OR-CREATE returns strings. I expect them to also return objects.
This script demonstrates the problem.
(ql:quickload :crane)
(use-package :crane)
(setup :migrations-directory #p"migrations/"
:databases `(:strongroom (:type :sqlite3 :name "bug.db"))
:debug nil)
(connect)
(deftable name ()
(name :type text))
(format t "CREATE : ~S~%" (create 'name :name "A"))
(format t "SINGLE : ~S~%" (single 'name :name "A"))
(format t "SINGLE! : ~S~%" (single! 'name :name "A"))
(format t "SINGLE-OR-CREATE: ~S~%" (single-or-create 'name :name "B"))
(format t "SINGLE-OR-CREATE: ~S~%" (single-or-create 'name :name "B"))
Actual output:
CREATE : #<NAME #x302001A86E1D>
SINGLE : #<NAME #x302001AAF3FD>
SINGLE! : "A"
SINGLE-OR-CREATE: "B"
SINGLE-OR-CREATE: "B"
Expected output:
CREATE : #<NAME #xZZZZZZZZZZ>
SINGLE : #<NAME #xZZZZZZZZZZ>
SINGLE! : #<NAME #xZZZZZZZZZZ>
SINGLE-OR-CREATE: #<NAME #xZZZZZZZZZZ>
SINGLE-OR-CREATE: #<NAME #xZZZZZZZZZZ>
This is with SQLite. I don't know about postgres.
I think the latest commit has fixed it. I get this now:
CREATE : #<NAME {1006D09123}>
SINGLE : #<NAME {1007870793}>
SINGLE! : #<NAME {1007C345E3}>
SINGLE-OR-CREATE: #<NAME {10055D5BC3}>
SINGLE-OR-CREATE: #<NAME {1005871BC3}>
Wow, that is incredibly quick response time.
Thanks, the issue is fixed.
This also causes SINGLE to return an object for existing records and strings for new records.