1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242
|
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; ======================================================================
;;;; File: test-oodml.lisp
;;;; Created: 01/04/2004
;;;;
;;;; Tests for the CLSQL Object Oriented Data Definition Language
;;;; (OODML).
;;;;
;;;; This file is part of CLSQL.
;;;;
;;;; CLSQL users are granted the rights to distribute and use this software
;;;; as governed by the terms of the Lisp Lesser GNU Public License
;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; ======================================================================
(in-package #:clsql-tests)
(clsql-sys:file-enable-sql-reader-syntax)
(defmacro has-sql-value-conversion-error (() &body body)
`(let (*debugger-hook*)
(handler-case
(progn ,@body nil)
(clsql-sys::sql-value-conversion-error (c)
(declare (ignore c))
t))))
(setq *rt-oodml*
'(
(deftest :oodml/read-symbol-value/1-into-this-package
(clsql-sys::read-sql-value
(clsql-sys::database-output-sql-as-type 'symbol 'clsql-tests::foo nil nil)
'symbol nil nil)
clsql-tests::foo)
(deftest :oodml/read-symbol-value/2-into-another-pacakge
(clsql-sys::read-sql-value
(clsql-sys::database-output-sql-as-type 'symbol 'clsql-sys::foo nil nil)
'symbol nil nil)
clsql-sys::foo)
(deftest :oodml/read-symbol-value/3-keyword
(clsql-sys::read-sql-value
(clsql-sys::database-output-sql-as-type 'keyword ':foo nil nil)
'keyword nil nil)
:foo)
(deftest :oodml/read-symbol-value/4-keyword-error
(has-sql-value-conversion-error ()
(clsql-sys::read-sql-value
(clsql-sys::database-output-sql-as-type 'keyword 'foo nil nil)
'keyword nil nil))
T)
(deftest :oodml/read-symbol-value/5-unknown-type-error-1
(has-sql-value-conversion-error ()
(clsql-sys::read-sql-value
(clsql-sys::database-output-sql-as-type 'bloop 'foo nil nil)
'bloop nil nil))
t)
(deftest :oodml/read-symbol-value/6-unknown-type-error-2
(has-sql-value-conversion-error ()
(clsql-sys::read-sql-value
(clsql-sys::database-output-sql-as-type 'bloop 'foo nil nil)
'(or integer float) nil nil))
t)
(deftest :oodml/read-symbol-value/read-list
(clsql-sys::read-sql-value
(clsql-sys::database-output-sql-as-type
'list '(("status" "new" "open")) nil nil)
'list nil nil)
(("status" "new" "open")))
(deftest :oodml/select/1
(with-dataset *ds-employees*
(mapcar #'(lambda (e) (slot-value e 'last-name))
(clsql:select 'employee :order-by [last-name] :flatp t :caching nil)))
("Andropov" "Brezhnev" "Chernenko" "Gorbachev" "Kruschev" "Lenin" "Putin"
"Stalin" "Trotsky" "Yeltsin"))
(deftest :oodml/select/2
(with-dataset *ds-employees*
(mapcar #'(lambda (e) (slot-value e 'name))
(clsql:select 'company :flatp t :caching nil)))
("Widgets Inc."))
(deftest :oodml/select/3
(with-dataset *ds-employees*
(mapcar #'(lambda (e) (slot-value e 'ecompanyid))
(clsql:select 'employee
:where [and [= [slot-value 'employee 'ecompanyid]
[slot-value 'company 'companyid]]
[= [slot-value 'company 'name]
"Widgets Inc."]]
:flatp t
:caching nil)))
(1 1 1 1 1 1 1 1 1 1))
(deftest :oodml/select/4
(with-dataset *ds-employees*
(mapcar #'(lambda (e)
(concatenate 'string (slot-value e 'first-name)
" "
(slot-value e 'last-name)))
(clsql:select 'employee :where [= [slot-value 'employee 'first-name]
"Vladimir"]
:flatp t
:order-by [last-name]
:caching nil)))
("Vladimir Lenin" "Vladimir Putin"))
(deftest :oodml/select/5
(with-dataset *ds-employees*
(length (clsql:select 'employee :where [married] :flatp t :caching nil)))
3)
(deftest :oodml/select/6
(with-dataset *ds-employees*
(let ((a (caar (clsql:select 'address :where [= 1 [addressid]] :caching nil))))
(values
(slot-value a 'street-number)
(slot-value a 'street-name)
(slot-value a 'city)
(slot-value a 'postal-code))))
10 "Park Place" "Leningrad" 123)
(deftest :oodml/select/7
(with-dataset *ds-employees*
(let ((a (caar (clsql:select 'address :where [= 2 [addressid]] :caching nil))))
(values
(slot-value a 'street-number)
(slot-value a 'street-name)
(slot-value a 'city)
(slot-value a 'postal-code))))
nil "" "no city" 0)
(deftest :oodml/select/8
(with-dataset *ds-employees*
(mapcar #'(lambda (e) (slot-value e 'married))
(clsql:select 'employee :flatp t :order-by [emplid] :caching nil)))
(t t t nil nil nil nil nil nil nil))
(deftest :oodml/select/9
(with-dataset *ds-employees*
(mapcar #'(lambda (pair)
(list
(typep (car pair) 'address)
(typep (second pair) 'employee-address)
(slot-value (car pair) 'addressid)
(slot-value (second pair) 'aaddressid)
(slot-value (second pair) 'aemplid)))
(employee-addresses employee1)))
((t t 1 1 1) (t t 2 2 1)))
(deftest :oodml/select/10
(with-dataset *ds-employees*
(mapcar #'(lambda (pair)
(list
(typep (car pair) 'address)
(typep (second pair) 'employee-address)
(slot-value (car pair) 'addressid)
(slot-value (second pair) 'aaddressid)
(slot-value (second pair) 'aemplid)))
(employee-addresses employee2)))
((t t 2 2 2)))
(deftest :oodml/select/11
(with-dataset *ds-employees*
(values (mapcar #'(lambda (x) (slot-value x 'emplid))
(clsql:select 'employee :order-by '(([emplid] :asc))
:flatp t))
(mapcar #'(lambda (x) (slot-value x 'emplid))
(clsql:select 'employee :order-by '(([emplid] :desc))
:flatp t))))
(1 2 3 4 5 6 7 8 9 10)
(10 9 8 7 6 5 4 3 2 1))
;; test retrieval of node, derived nodes etc
(deftest :oodml/select/12
(with-dataset *ds-nodes*
(length (clsql:select 'node :where [not [null [node-id]]] :flatp t :caching nil)))
11)
(deftest :oodml/select/13
(with-dataset *ds-nodes*
(let ((a (car (clsql:select 'node :where [= 1 [node-id]] :flatp t :caching nil))))
(values
(slot-value a 'node-id)
(slot-value a 'title))))
1 "Bare node")
(deftest :oodml/select/14
(with-dataset *ds-nodes*
(length (clsql:select 'setting :where [not [null [setting-id]]] :flatp t :caching nil)))
4)
(deftest :oodml/select/15
(with-dataset *ds-nodes*
(let ((a (car (clsql:select 'setting :where [= 3 [setting-id]] :flatp t :caching nil))))
(values
(slot-value a 'node-id)
(slot-value a 'setting-id)
(slot-value a 'title)
(slot-value a 'vars))))
3 3 "Setting2" "var 2")
(deftest :oodml/select/16
(with-dataset *ds-nodes*
(length (clsql:select 'user :where [not [null [user-id]]] :flatp t :caching nil)))
2)
(deftest :oodml/select/17
(with-dataset *ds-nodes*
(let ((a (car (clsql:select 'user :where [= 4 [user-id]] :flatp t :caching nil))))
(values
(slot-value a 'node-id)
(slot-value a 'user-id)
(slot-value a 'title)
(slot-value a 'nick))))
4 4 "user-1" "first user")
(deftest :oodml/select/18
(with-dataset *ds-nodes*
(length (clsql:select 'theme :where [not [null [theme-id]]] :flatp t :caching nil)))
2)
(deftest :oodml/select/19
(with-dataset *ds-nodes*
(let ((a (car (clsql:select 'theme :where [= 6 [theme-id]] :flatp t :caching nil))))
(slot-value a 'theme-id)))
6)
(deftest :oodml/select/20
(with-dataset *ds-nodes*
(let ((a (car (clsql:select 'theme :where [= 7 [theme-id]] :flatp t :caching nil))))
(values
(slot-value a 'node-id)
(slot-value a 'theme-id)
(slot-value a 'title)
(slot-value a 'vars)
(slot-value a 'doc)
)))
7 7 "theme-2"
nil "second theme")
;; Some tests to check weird subclassed nodes (node without own table, or subclassed of same)
(deftest :oodml/select/21
(with-dataset *ds-nodes*
(let ((a (car (clsql:select 'location :where [= [title] "location-1"] :flatp t :caching nil))))
(values
(slot-value a 'node-id)
(slot-value a 'title))))
8 "location-1")
(deftest :oodml/select/22
(with-dataset *ds-nodes*
(let ((a (car (clsql:select 'subloc :where [not [null [subloc-id]]] :flatp t :caching nil))))
(values
(slot-value a 'node-id)
(slot-value a 'subloc-id)
(slot-value a 'title)
(slot-value a 'loc))))
10 10 "subloc-1" "a subloc")
(deftest :oodml/select/23
(with-dataset *ds-artists*
(length (clsql:select 'artist :flatp t :caching nil)))
0)
;; test retrieval is deferred
(deftest :oodm/retrieval/1
(with-dataset *ds-employees*
(every #'(lambda (e) (not (slot-boundp e 'company)))
(select 'employee :flatp t :caching nil)))
t)
(deftest :oodm/retrieval/2
(with-dataset *ds-employees*
(every #'(lambda (e) (not (slot-boundp e 'address)))
(select 'deferred-employee-address :flatp t :caching nil)))
t)
;; :retrieval :immediate should be boundp before accessed
(deftest :oodm/retrieval/3
(with-dataset *ds-employees*
(every #'(lambda (ea) (slot-boundp ea 'address))
(select 'employee-address :flatp t :caching nil)))
t)
(deftest :oodm/retrieval/4
(with-dataset *ds-employees*
(every #'(lambda (ea) (typep (slot-value ea 'address) 'address))
(select 'employee-address :flatp t :caching nil)))
t)
(deftest :oodm/retrieval/5
(with-dataset *ds-employees*
(every #'(lambda (ea) (typep (slot-value ea 'address) 'address))
(select 'deferred-employee-address :flatp t :caching nil)))
t)
(deftest :oodm/retrieval/6
(with-dataset *ds-employees*
(every #'(lambda (ea) (slot-boundp (slot-value ea 'address) 'addressid))
(select 'employee-address :flatp t :caching nil)))
t)
(deftest :oodm/retrieval/7
(with-dataset *ds-employees*
(every #'(lambda (ea) (slot-boundp (slot-value ea 'address) 'addressid))
(select 'deferred-employee-address :flatp t :caching nil)))
t)
(deftest :oodm/retrieval/8
(with-dataset *ds-employees*
(mapcar #'(lambda (ea) (slot-value (slot-value ea 'address) 'street-number))
(select 'employee-address :flatp t :order-by [aaddressid] :caching nil)))
(10 10 nil nil nil nil))
(deftest :oodm/retrieval/9
(with-dataset *ds-employees*
(mapcar #'(lambda (ea) (slot-value (slot-value ea 'address) 'street-number))
(select 'deferred-employee-address :flatp t :order-by [aaddressid] :caching nil)))
(10 10 nil nil nil nil))
(deftest :oodm/retrieval/10-slot-columns
(with-dataset *ds-employees*
(mapcar #'title
(select 'employee :flatp t :caching nil
:where [<= [emplid] 3]
:order-by `((,[emplid] :asc)))))
(supplicant :adherent cl-user::novice))
;; tests update-records-from-instance
(deftest :oodml/update-records/1
(with-dataset *ds-employees*
(values
(progn
(let ((lenin (car (clsql:select 'employee
:where [= 1 [slot-value 'employee 'emplid]]
:flatp t
:caching nil))))
(format nil "~a ~a: ~a"
(first-name lenin)
(last-name lenin)
(employee-email lenin))))
(progn
(setf (slot-value employee1 'first-name) "Dimitriy"
(slot-value employee1 'last-name) "Ivanovich"
(slot-value employee1 'email) "ivanovich@soviet.org")
(clsql:update-records-from-instance employee1)
(let ((lenin (car (clsql:select 'employee
:where [= 1 [slot-value 'employee 'emplid]]
:flatp t
:caching nil))))
(format nil "~a ~a: ~a"
(first-name lenin)
(last-name lenin)
(employee-email lenin))))))
"Vladimir Lenin: lenin@soviet.org"
"Dimitriy Ivanovich: ivanovich@soviet.org")
;; tests update-record-from-slot
(deftest :oodml/update-records/2
(with-dataset *ds-employees*
;(start-sql-recording :type :both)
(values
(employee-email
(car (clsql:select 'employee
:where [= 1 [slot-value 'employee 'emplid]]
:flatp t
:caching nil)))
(progn
(setf (slot-value employee1 'email) "lenin-nospam@soviet.org")
(clsql:update-record-from-slot employee1 'email)
(employee-email
(car (clsql:select 'employee
:where [= 1 [slot-value 'employee 'emplid]]
:flatp t
:caching nil))))))
"lenin@soviet.org" "lenin-nospam@soviet.org")
;; tests update-record-from-slots
(deftest :oodml/update-records/3
(with-dataset *ds-employees*
(values
(let ((lenin (car (clsql:select 'employee
:where [= 1 [slot-value 'employee 'emplid]]
:flatp t
:caching nil))))
(format nil "~a ~a: ~a"
(first-name lenin)
(last-name lenin)
(employee-email lenin)))
(progn
(setf (slot-value employee1 'first-name) "Dimitriy"
(slot-value employee1 'last-name) "Ivanovich"
(slot-value employee1 'email) "ivanovich@soviet.org")
(clsql:update-record-from-slots employee1 '(first-name last-name email))
(let ((lenin (car (clsql:select 'employee
:where [= 1 [slot-value 'employee 'emplid]]
:flatp t
:caching nil))))
(format nil "~a ~a: ~a"
(first-name lenin)
(last-name lenin)
(employee-email lenin))))))
"Vladimir Lenin: lenin@soviet.org"
"Dimitriy Ivanovich: ivanovich@soviet.org")
(deftest :oodml/update-records/4
(with-dataset *ds-nodes*
(flet ((print-fresh-node ()
(let ((base (car (clsql:select 'node
:where [= 1 [slot-value 'node 'node-id]]
:flatp t :caching nil))))
(format nil "~a ~a"
(slot-value base 'node-id)
(slot-value base 'title)))))
(values
(print-fresh-node)
(let ((base (car (clsql:select 'node
:where [= 1 [slot-value 'node 'node-id]]
:flatp t :caching nil))))
(setf (slot-value base 'title) "Altered title")
(clsql:update-records-from-instance base)
(print-fresh-node)))))
"1 Bare node"
"1 Altered title")
(deftest :oodml/update-records/4-slots ;just like 4, but use slots fns.
(with-dataset *ds-nodes*
(flet ((print-fresh-setting ()
(let ((node (car (clsql:select 'setting
:where [= 3 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(format nil "~a ~a ~a"
(slot-value node 'setting-id)
(slot-value node 'title)
(slot-value node 'vars)))))
(values
(print-fresh-setting)
(let ((node (car (clsql:select 'setting
:where [= 3 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Altered title")
(setf (slot-value node 'vars) "Altered vars")
(clsql-sys:update-record-from-slot node 'title)
(clsql-sys:update-record-from-slot node 'vars)
(print-fresh-setting))
(let ((node (car (clsql:select 'setting
:where [= 3 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Setting2")
(setf (slot-value node 'vars) "var 2")
(clsql:update-records-from-instance node)
(clsql-sys:update-record-from-slots node '(vars title))
(print-fresh-setting)))))
"3 Setting2 var 2"
"3 Altered title Altered vars"
"3 Setting2 var 2")
(deftest :oodml/update-records/5
(with-dataset *ds-nodes*
(flet ((print-fresh-setting ()
(let ((node (car (clsql:select 'setting
:where [= 3 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(format nil "~a ~a ~a"
(slot-value node 'setting-id)
(slot-value node 'title)
(slot-value node 'vars)))))
(values
(print-fresh-setting)
(let ((node (car (clsql:select 'setting
:where [= 3 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Altered title")
(setf (slot-value node 'vars) "Altered vars")
(clsql:update-records-from-instance node)
(print-fresh-setting)))))
"3 Setting2 var 2"
"3 Altered title Altered vars")
(deftest :oodml/update-records/5-slots
(with-dataset *ds-nodes*
(flet ((print-fresh-setting ()
(let ((node (car (clsql:select 'setting
:where [= 3 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(format nil "~a ~a ~a"
(slot-value node 'setting-id)
(slot-value node 'title)
(slot-value node 'vars)))))
(values
(print-fresh-setting)
(let ((node (car (clsql:select 'setting
:where [= 3 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Altered title")
(setf (slot-value node 'vars) "Altered vars")
(clsql-sys:update-record-from-slot node 'title)
(clsql-sys:update-record-from-slot node 'vars)
(print-fresh-setting))
(let ((node (car (clsql:select 'setting
:where [= 3 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Setting2")
(setf (slot-value node 'vars) "var 2")
(clsql-sys:update-record-from-slots node '(title vars))
(print-fresh-setting)))))
"3 Setting2 var 2"
"3 Altered title Altered vars"
"3 Setting2 var 2")
(deftest :oodml/update-records/6
(with-dataset *ds-nodes*
(flet ((print-fresh-setting ()
(let ((node (car (clsql:select 'setting
:where [= 7 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(format nil "~a ~a ~a"
(slot-value node 'setting-id)
(slot-value node 'title)
(or (slot-value node 'vars) "NIL")))))
(values
(print-fresh-setting)
(let ((node (car (clsql:select 'setting
:where [= 7 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Altered title")
(setf (slot-value node 'vars) "Altered vars")
(clsql:update-records-from-instance node)
(print-fresh-setting))
(let ((node (car (clsql:select 'setting
:where [= 7 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "theme-2")
(setf (slot-value node 'vars) nil)
(clsql:update-records-from-instance node)
(print-fresh-setting)))))
"7 theme-2 NIL"
"7 Altered title Altered vars"
"7 theme-2 NIL")
(deftest :oodml/update-records/7
(with-dataset *ds-nodes*
(flet ((print-fresh-user ()
"requery to get what the db has, and print out."
(let ((node (car (clsql:select 'user
:where [= 5 [slot-value 'user 'user-id]]
:flatp t :caching nil))))
(format nil "~a ~a ~a"
(slot-value node 'user-id)
(slot-value node 'title)
(slot-value node 'nick)))))
(values
(print-fresh-user)
(let ((node (car (clsql:select 'user
:where [= 5 [slot-value 'user 'user-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Altered title")
(setf (slot-value node 'nick) "Altered nick")
(clsql:update-records-from-instance node)
(print-fresh-user)))))
"5 user-2 second user"
"5 Altered title Altered nick")
(deftest :oodml/update-records/8
(with-dataset *ds-nodes*
(flet ((print-fresh-theme ()
(let ((node (car (clsql:select 'theme
:where [= 6 [slot-value 'theme 'theme-id]]
:flatp t :caching nil))))
(with-slots (node-id setting-id theme-id title vars doc) node
(format nil "~a ~a ~a ~a ~a ~a"
node-id setting-id theme-id
title (or vars "NIL") doc)))))
(values
(print-fresh-theme)
(let ((node (car (clsql:select 'setting
:where [= 6 [slot-value 'setting 'setting-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Altered title")
(setf (slot-value node 'vars) nil)
(clsql:update-records-from-instance node)
(print-fresh-theme))
(let ((node (car (clsql:select 'theme
:where [= 6 [slot-value 'theme 'theme-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "Altered title again")
(setf (slot-value node 'doc) "altered doc")
(clsql:update-records-from-instance node)
(print-fresh-theme))
(let ((node (car (clsql:select 'theme
:where [= 6 [slot-value 'theme 'theme-id]]
:flatp t :caching nil))))
(setf (slot-value node 'title) "theme-1")
(setf (slot-value node 'vars) "empty")
(setf (slot-value node 'doc) "first theme")
(clsql:update-records-from-instance node)
(print-fresh-theme)))))
"6 6 6 theme-1 empty first theme"
"6 6 6 Altered title NIL first theme"
"6 6 6 Altered title again NIL altered doc"
"6 6 6 theme-1 empty first theme")
(deftest :oodml/update-records/9
(with-dataset *ds-nodes*
(flet ((print-fresh-subloc ()
(let ((sl (car (clsql:select 'subloc
:where [= 10 [slot-value 'subloc 'subloc-id]]
:flatp t :caching nil))))
(unless sl
(error "Couldn't find expected sublocation"))
(format nil "~a ~a ~a"
(slot-value sl 'subloc-id)
(slot-value sl 'title)
(slot-value sl 'loc)))))
(values
(print-fresh-subloc)
(let ((sl (car (clsql:select 'subloc
:where [= 10 [slot-value 'subloc 'subloc-id]]
:flatp t :caching nil))))
(setf (slot-value sl 'title) "Altered subloc title")
(setf (slot-value sl 'loc) "Altered loc")
(clsql:update-records-from-instance sl)
(print-fresh-subloc)))))
"10 subloc-1 a subloc"
"10 Altered subloc title Altered loc")
(deftest :oodml/update-records/9-slots ;like 9, but use slots fns.
(with-dataset *ds-nodes*
(flet ((print-fresh-subloc ()
(let ((sl (car (clsql:select 'subloc
:where [= 10 [slot-value 'subloc 'subloc-id]]
:flatp t :caching nil))))
(unless sl
(error "In psfl: found no sublocation with id = 10"))
(format nil "~a ~a ~a"
(slot-value sl 'subloc-id)
(slot-value sl 'title)
(slot-value sl 'loc)))))
(values
(print-fresh-subloc)
(let ((sl (car (clsql:select 'subloc
:where [= 10 [slot-value 'subloc 'subloc-id]]
:flatp t :caching nil))))
(unless sl
(error "Select for modification: Found no sublocation with id = 10"))
(setf (slot-value sl 'title) "Altered subloc title")
(setf (slot-value sl 'loc) "Altered loc")
(clsql:update-record-from-slot sl 'title)
(clsql:update-record-from-slot sl 'loc)
(print-fresh-subloc))
(let ((sl (car (clsql:select 'subloc
:where [= 10 [slot-value 'subloc 'subloc-id]]
:flatp t :caching nil))))
(unless sl
(error "Select for next modification: Found no sublocation with id = 10"))
(setf (slot-value sl 'title) "subloc-1")
(setf (slot-value sl 'loc) "a subloc")
(clsql:update-record-from-slots sl '(title loc))
(print-fresh-subloc)))))
"10 subloc-1 a subloc"
"10 Altered subloc title Altered loc"
"10 subloc-1 a subloc")
;; Verify that we can set a float to nil and then read it back
;; (was failing in Postgresql at somepoint)
(deftest :oodml/update-records/10
(with-dataset *ds-employees*
(let ((emp (first (clsql:select 'employee :where [= [emplid] 1] :flatp t))))
(setf (height emp) nil)
(clsql-sys:update-record-from-slot emp 'height)
(values
(clsql:select [height] :from [employee] :where [= [emplid] 1])
(progn
(setf (height emp) 42.0)
(clsql-sys:update-record-from-slot emp 'height)
(clsql:select [height] :from [employee] :where [= [emplid] 1]))
(progn
(setf (height emp) 24.13d0)
(clsql-sys:update-record-from-slot emp 'height)
(clsql:select [height] :from [employee] :where [= [emplid] 1])))))
((nil))
((42.0d0))
((24.13d0)))
(deftest :oodml/update-records/11
(with-dataset *ds-artists*
(clsql:update-records-from-instance artist1)
(list (name artist1) (artist_id artist1)))
("Mogwai" 1))
(deftest :oodml/update-records/12
(with-dataset *ds-artists*
(clsql:update-records-from-instance artist1)
(list (name artist1) (genre artist1)))
("Mogwai" "Unknown"))
;; tests update-instance-from-records
(deftest :oodml/update-instance/1
(with-dataset *ds-employees*
(values
(format nil "~a ~a: ~a"
(slot-value employee1 'first-name)
(slot-value employee1 'last-name)
(slot-value employee1 'email))
(progn
(clsql:update-records [employee]
:av-pairs '(([first-name] "Ivan")
([last-name] "Petrov")
([email] "petrov@soviet.org"))
:where [= [emplid] 1])
(clsql:update-instance-from-records employee1)
(format nil "~a ~a: ~a"
(slot-value employee1 'first-name)
(slot-value employee1 'last-name)
(slot-value employee1 'email)))))
"Vladimir Lenin: lenin@soviet.org"
"Ivan Petrov: petrov@soviet.org")
;; tests update-slot-from-record
(deftest :oodml/update-instance/2
(with-dataset *ds-employees*
(values
(slot-value employee1 'email)
(progn
(clsql:update-records [employee]
:av-pairs '(([email] "lenin-nospam@soviet.org"))
:where [= [emplid] 1])
(clsql:update-slot-from-record employee1 'email)
(slot-value employee1 'email))))
"lenin@soviet.org" "lenin-nospam@soviet.org")
;; tests normalizedp update-instance-from-records
(deftest :oodml/update-instance/3
(with-dataset *ds-nodes*
(values
(with-output-to-string (out)
(format out "~a ~a ~a ~a"
(slot-value theme2 'theme-id)
(slot-value theme2 'title)
(or (slot-value theme2 'vars) "NIL")
(slot-value theme2 'doc)))
(progn
(clsql:update-records [node] :av-pairs '(([title] "Altered title"))
:where [= [node-id] 7])
(clsql:update-records [setting] :av-pairs '(([vars] "Altered vars"))
:where [= [setting-id] 7])
(clsql:update-records [theme] :av-pairs '(([doc] "Altered doc"))
:where [= [theme-id] 7])
(clsql:update-instance-from-records theme2)
(with-output-to-string (out)
(format out "~a ~a ~a ~a"
(slot-value theme2 'theme-id)
(slot-value theme2 'title)
(slot-value theme2 'vars)
(slot-value theme2 'doc))))))
"7 theme-2 NIL second theme"
"7 Altered title Altered vars Altered doc")
(deftest :oodml/update-instance/4
(with-dataset *ds-nodes*
(values
(progn
(setf loc2 (car (clsql:select 'location
:where [= [node-id] 9]
:flatp t :caching nil)))
(format nil "~a ~a"
(slot-value loc2 'node-id)
(slot-value loc2 'title)))
(progn
(clsql:update-records [node] :av-pairs '(([title] "Altered title"))
:where [= [node-id] 9])
(clsql:update-instance-from-records loc2)
(format nil "~a ~a"
(slot-value loc2 'node-id)
(slot-value loc2 'title)))))
"9 location-2"
"9 Altered title")
(deftest :oodml/update-instance/5
(with-dataset *ds-nodes*
(values
(format nil "~a ~a ~a"
(slot-value subloc2 'subloc-id)
(slot-value subloc2 'title)
(slot-value subloc2 'loc))
(progn
(clsql:update-records [node] :av-pairs '(([title] "Altered title"))
:where [= [node-id] 11])
(clsql:update-records [subloc] :av-pairs '(([loc] "Altered loc"))
:where [= [subloc-id] 11])
(clsql:update-instance-from-records subloc2)
(format nil "~a ~a ~a"
(slot-value subloc2 'subloc-id)
(slot-value subloc2 'title)
(slot-value subloc2 'loc)))))
"11 subloc-2 second subloc"
"11 Altered title Altered loc")
;; tests update-slot-from-record with normalizedp stuff
(deftest :oodml/update-instance/6
(with-dataset *ds-nodes*
(values
(slot-value theme1 'doc)
(slot-value theme1 'vars)
(progn
(clsql:update-records [theme]
:av-pairs '(([doc] "altered doc"))
:where [= [theme-id] 6])
(clsql:update-slot-from-record theme1 'doc)
(slot-value theme1 'doc))
(progn
(clsql:update-records [setting]
:av-pairs '(([vars] "altered vars"))
:where [= [setting-id] 6])
(clsql:update-slot-from-record theme1 'vars)
(slot-value theme1 'vars))))
"first theme" "empty"
"altered doc" "altered vars")
(deftest :oodml/update-instance/7
(flet ((print-loc (l)
(format nil "~a: ~a"
(slot-value l 'node-id) (slot-value l 'title)))
(print-subloc (sl)
(format nil "~a: ~a"
(slot-value sl 'node-id) (slot-value sl 'loc))))
(with-dataset *ds-nodes*
(values
(print-loc loc2)
(print-subloc subloc2)
(progn
(clsql:update-records [node]
:av-pairs '(([title] "altered title"))
:where [= [node-id] (node-id loc2)])
(clsql:update-slot-from-record loc2 'title)
(print-loc loc2))
(progn
(clsql:update-records [subloc]
:av-pairs '(([loc] "altered loc"))
:where [= [subloc-id] (subloc-id subloc2)])
(clsql:update-slot-from-record subloc2 'loc)
(print-subloc subloc2)))))
"9: location-2" "11: second subloc"
"9: altered title" "11: altered loc")
(deftest :oodml/do-query/1
(with-dataset *ds-employees*
(let ((result '()))
(clsql:do-query ((e) [select 'employee :order-by [emplid]])
(push (slot-value e 'last-name) result))
result))
("Putin" "Yeltsin" "Gorbachev" "Chernenko" "Andropov" "Brezhnev" "Kruschev"
"Trotsky" "Stalin" "Lenin"))
(deftest :oodml/do-query/2
(with-dataset *ds-employees*
(let ((result '()))
(clsql:do-query ((e c) [select 'employee 'company
:where [= [slot-value 'employee 'last-name]
"Lenin"]])
(push (list (slot-value e 'last-name) (slot-value c 'name))
result))
result))
(("Lenin" "Widgets Inc.")))
(deftest :oodml/map-query/1
(with-dataset *ds-employees*
(clsql:map-query 'list #'last-name [select 'employee :order-by [emplid]]))
("Lenin" "Stalin" "Trotsky" "Kruschev" "Brezhnev" "Andropov" "Chernenko"
"Gorbachev" "Yeltsin" "Putin"))
(deftest :oodml/map-query/2
(with-dataset *ds-employees*
(clsql:map-query 'list #'(lambda (e c) (list (slot-value e 'last-name)
(slot-value c 'name)))
[select 'employee 'company :where [= [slot-value 'employee 'last-name]
"Lenin"]]))
(("Lenin" "Widgets Inc.")))
(deftest :oodml/iteration/3
(with-dataset *ds-employees*
(loop for (e) being the records in
[select 'employee :where [< [emplid] 4] :order-by [emplid]]
collect (slot-value e 'last-name)))
("Lenin" "Stalin" "Trotsky"))
(deftest :oodml/cache/1
(with-dataset *ds-employees*
(let ((*default-caching* t))
(setf (clsql-sys:record-caches *default-database*) nil)
(let ((employees (select 'employee)))
(every #'(lambda (a b) (eq a b))
employees (select 'employee)))))
t)
(deftest :oodml/cache/2
(with-dataset *ds-employees*
(let* ((*default-caching* t)
(employees (select 'employee)))
(equal employees (select 'employee :flatp t))))
nil)
(deftest :oodml/refresh/1
(with-dataset *ds-employees*
(let* ((clsql-sys:*default-caching* t)
(addresses (select 'address)))
(equal addresses (select 'address :refresh t))))
t)
(deftest :oodml/refresh/2
(with-dataset *ds-employees*
(let* ((clsql-sys:*default-caching* t)
(addresses (select 'address :order-by [addressid] :flatp t :refresh t))
(city (slot-value (car addresses) 'city)))
(clsql:update-records [addr]
:av-pairs '((city_field "A new city"))
:where [= [addressid] (slot-value (car addresses) 'addressid)])
(let* ((new-addresses (select 'address :order-by [addressid] :refresh t :flatp t))
(new-city (slot-value (car addresses) 'city))
)
(clsql:update-records [addr]
:av-pairs `((city_field ,city))
:where [= [addressid] (slot-value (car addresses) 'addressid)])
(values (equal addresses new-addresses)
city
new-city))))
t "Leningrad" "A new city")
(deftest :oodml/refresh/3
(with-dataset *ds-employees*
(let* ((clsql-sys:*default-caching* t)
(addresses (select 'address :order-by [addressid] :flatp t)))
(values
(equal addresses (select 'address :refresh t :flatp t))
(equal addresses (select 'address :flatp t)))))
nil nil)
(deftest :oodml/refresh/4
(with-dataset *ds-employees*
(let* ((clsql-sys:*default-caching* t)
(addresses (select 'address :order-by [addressid] :flatp t :refresh t))
(*db-auto-sync* t))
(make-instance 'address :addressid 1000 :city "A new address city")
(let ((new-addresses (select 'address :order-by [addressid] :flatp t :refresh t)))
(values
(length addresses)
(length new-addresses)
(eq (first addresses) (first new-addresses))
(eq (second addresses) (second new-addresses))))))
3 4 t t)
(deftest :oodml/uoj/full-set
(with-dataset *ds-employees*
(progn
(let* ((dea-list (select 'deferred-employee-address
:caching nil :order-by ["ea_join" aaddressid]
:flatp t))
(dea-list-copy (copy-seq dea-list))
(initially-unbound (every #'(lambda (dea) (not (slot-boundp dea 'address))) dea-list)))
(update-objects-joins dea-list :slots 'address :max-len nil)
(values
initially-unbound
(equal dea-list dea-list-copy)
(every #'(lambda (dea) (slot-boundp dea 'address)) dea-list)
(every #'(lambda (dea) (typep (slot-value dea 'address) 'address)) dea-list)
(mapcar #'(lambda (dea) (slot-value (slot-value dea 'address) 'addressid)) dea-list)))))
t t t t (1 1 2 2 2 3))
(deftest :oodml/uoj/batched
(with-dataset *ds-employees*
(progn
(let* ((dea-list (select 'deferred-employee-address
:caching nil :order-by ["ea_join" aaddressid]
:flatp t))
(dea-list-copy (copy-seq dea-list))
(initially-unbound (every #'(lambda (dea) (not (slot-boundp dea 'address))) dea-list)))
(update-objects-joins dea-list :slots 'address :max-len 2)
(values
initially-unbound
(equal dea-list dea-list-copy)
(every #'(lambda (dea) (slot-boundp dea 'address)) dea-list)
(every #'(lambda (dea) (typep (slot-value dea 'address) 'address)) dea-list)
(mapcar #'(lambda (dea) (slot-value (slot-value dea 'address) 'addressid)) dea-list)))))
t t t t (1 1 2 2 2 3))
;; update-object-joins needs to be fixed for multiple keys
#+ignore
(deftest :oodml/uoj/multi-key
(progn
(clsql:update-objects-joins (list company1))
(mapcar #'(lambda (e)
(slot-value e 'ecompanyid))
(company-employees company1)))
(1 1 1 1 1 1 1 1 1 1))
(deftest :oodml/big/1
(with-dataset *ds-big*
(let ((objs (clsql:select 'big :order-by [i] :flatp t)))
(values
(length objs)
(do ((i 0 (1+ i))
(max (expt 2 60))
(rest objs (cdr rest)))
((= i (length objs)) t)
(let ((obj (car rest))
(index (1+ i)))
(unless (and (eql (slot-value obj 'i) index)
(eql (slot-value obj 'bi) (truncate max index)))
(print index)
(describe obj)
(return nil)))))))
555 t)
(deftest :oodml/db-auto-sync/1
(with-dataset *ds-employees*
(values
(progn
(make-instance 'employee :emplid 20 :groupid 1
:last-name "Ivanovich")
(select [last-name] :from [employee] :where [= [emplid] 20]
:flatp t :field-names nil))
(let ((*db-auto-sync* t))
(make-instance 'employee :emplid 20 :groupid 1
:last-name "Ivanovich")
(prog1 (select [last-name] :from [employee] :flatp t
:field-names nil
:where [= [emplid] 20])
(delete-records :from [employee] :where [= [emplid] 20])))))
nil ("Ivanovich"))
(deftest :oodml/db-auto-sync/2
(with-dataset *ds-employees*
(values
(let ((instance (make-instance 'employee :emplid 20 :groupid 1
:last-name "Ivanovich")))
(setf (slot-value instance 'last-name) "Bulgakov")
(select [last-name] :from [employee] :where [= [emplid] 20]
:flatp t :field-names nil))
(let* ((*db-auto-sync* t)
(instance (make-instance 'employee :emplid 20 :groupid 1
:last-name "Ivanovich")))
(setf (slot-value instance 'last-name) "Bulgakov")
(prog1 (select [last-name] :from [employee] :flatp t
:field-names nil
:where [= [emplid] 20])
(delete-records :from [employee] :where [= [emplid] 20])))))
nil ("Bulgakov"))
(deftest :oodml/db-auto-sync/3
(with-dataset *ds-nodes*
(values
(progn
(make-instance 'theme :title "test-theme" :vars "test-vars"
:doc "test-doc")
(select [node-id] :from [node] :where [= [title] "test-theme"]
:flatp t :field-names nil))
(let ((*db-auto-sync* t))
(make-instance 'theme :title "test-theme" :vars "test-vars"
:doc "test-doc")
(prog1 (select [title] :from [node] :where [= [title] "test-theme"]
:flatp t :field-names nil)
(delete-records :from [node] :where [= [title] "test-theme"])
(delete-records :from [setting] :where [= [vars] "test-vars"])
(delete-records :from [theme] :where [= [doc] "test-doc"])))))
nil ("test-theme"))
(deftest :oodml/db-auto-sync/4
(with-dataset *ds-nodes*
(values
(let ((inst (make-instance 'theme
:title "test-theme" :vars "test-vars"
:doc "test-doc"))
(*print-circle* nil))
(setf (slot-value inst 'title) "alternate-test-theme")
(format nil "~a ~a ~a ~a"
(or (select [title] :from [node]
:where [= [title] "test-theme"]
:flatp t :field-names nil) "NIL")
(or (select [vars] :from [setting]
:where [= [vars] "test-vars"]
:flatp t :field-names nil) "NIL")
(or (select [doc] :from [theme]
:where [= [doc] "test-doc"]
:flatp t :field-names nil) "NIL")
(or (select [title] :from [node]
:where [= [title] "alternate-test-theme"]
:flatp t :field-names nil) "NIL")))
(let* ((*db-auto-sync* t)
(inst (make-instance 'theme
:title "test-theme" :vars "test-vars"
:doc "test-doc")))
(setf (slot-value inst 'title) "alternate-test-theme")
(prog1
(format nil "~a ~a ~a ~a"
(or (select [title] :from [node]
:where [= [title] "test-theme"]
:flatp t :field-names nil) "NIL")
(or (select [vars] :from [setting]
:where [= [vars] "test-vars"]
:flatp t :field-names nil) "NIL")
(or (select [doc] :from [theme]
:where [= [doc] "test-doc"]
:flatp t :field-names nil) "NIL")
(or (select [title] :from [node]
:where [= [title] "alternate-test-theme"]
:flatp t :field-names nil) "NIL"))
(delete-records :from [node] :where [= [title] "alternate-test-theme"])
(delete-records :from [setting] :where [= [vars] "test-vars"])
(delete-records :from [theme] :where [= [doc] "test-doc"])))))
"NIL NIL NIL NIL"
"NIL (test-vars) (test-doc) (alternate-test-theme)")
(deftest :oodml/setf-slot-value/1
(with-dataset *ds-employees*
(let* ((*db-auto-sync* t)
(instance (make-instance 'employee :emplid 20 :groupid 1)))
(prog1
(setf
(slot-value instance 'first-name) "Mikhail"
(slot-value instance 'last-name) "Bulgakov")
(delete-records :from [employee] :where [= [emplid] 20]))))
"Bulgakov")
(deftest :oodml/float/1
(with-dataset *ds-employees*
(let* ((emp1 (car (select 'employee
:where [= [slot-value 'employee 'emplid]
1]
:flatp t
:caching nil)))
(height (slot-value emp1 'height)))
(prog1
(progn
(setf (slot-value emp1 'height) 1.0E0)
(clsql:update-record-from-slot emp1 'height)
(= (car (clsql:select [height] :from [employee]
:where [= [emplid] 1]
:flatp t
:field-names nil))
1))
(setf (slot-value emp1 'height) height)
(clsql:update-record-from-slot emp1 'height))))
t)
(deftest :oodml/float/2
(with-dataset *ds-employees*
(let* ((emp1 (car (select 'employee
:where [= [slot-value 'employee 'emplid]
1]
:flatp t
:caching nil)))
(height (slot-value emp1 'height)))
(prog1
(progn
(setf (slot-value emp1 'height) 1.0S0)
(clsql:update-record-from-slot emp1 'height)
(= (car (clsql:select [height] :from [employee]
:where [= [emplid] 1]
:flatp t
:field-names nil))
1))
(setf (slot-value emp1 'height) height)
(clsql:update-record-from-slot emp1 'height))))
t)
(deftest :oodml/float/3
(with-dataset *ds-employees*
(let* ((emp1 (car (select 'employee
:where [= [slot-value 'employee 'emplid]
1]
:flatp t
:caching nil)))
(height (slot-value emp1 'height)))
(prog1
(progn
(setf (slot-value emp1 'height) 1.0F0)
(clsql:update-record-from-slot emp1 'height)
(= (car (clsql:select [height] :from [employee]
:where [= [emplid] 1]
:flatp t
:field-names nil))
1))
(setf (slot-value emp1 'height) height)
(clsql:update-record-from-slot emp1 'height))))
t)
(deftest :oodml/float/4
(with-dataset *ds-employees*
(let* ((emp1 (car (select 'employee
:where [= [slot-value 'employee 'emplid]
1]
:flatp t
:caching nil)))
(height (slot-value emp1 'height)))
(prog1
(progn
(setf (slot-value emp1 'height) 1.0D0)
(clsql:update-record-from-slot emp1 'height)
(= (car (clsql:select [height] :from [employee]
:where [= [emplid] 1]
:flatp t
:field-names nil))
1))
(setf (slot-value emp1 'height) height)
(clsql:update-record-from-slot emp1 'height))))
t)
(deftest :oodml/float/5
(with-dataset *ds-employees*
(let* ((emp1 (car (select 'employee
:where [= [slot-value 'employee 'emplid]
1]
:flatp t
:caching nil)))
(height (slot-value emp1 'height)))
(prog1
(progn
(setf (slot-value emp1 'height) 1.0L0)
(clsql:update-record-from-slot emp1 'height)
(= (car (clsql:select [height] :from [employee]
:where [= [emplid] 1]
:flatp t
:field-names nil))
1))
(setf (slot-value emp1 'height) height)
(clsql:update-record-from-slot emp1 'height))))
t)
))
|