mirror of
https://github.com/groue/GRDB.swift
synced 2026-12-06 05:28:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebeb7bc969 | ||
|
|
6ccac5f69c | ||
|
|
cc41b8b259 | ||
|
|
db1a3456b7 | ||
|
|
1b9305c073 | ||
|
|
a33814ef40 | ||
|
|
581bc9f27c | ||
|
|
40cff0053f | ||
|
|
cc33b12b0d | ||
|
|
2add1c68ea | ||
|
|
380b6676a6 | ||
|
|
f133a36477 | ||
|
|
5f2d6f8e2f | ||
|
|
a72c207ec5 | ||
|
|
ae3c28dee1 | ||
|
|
bd919e5209 | ||
|
|
d1697756e9 | ||
|
|
83c3745165 | ||
|
|
56a4a964b7 | ||
|
|
c9a02faf08 | ||
|
|
e59388738e | ||
|
|
c8368d98eb | ||
|
|
d12dad2e34 | ||
|
|
1ee8c73562 | ||
|
|
ad8de84257 | ||
|
|
48398b4913 | ||
|
|
d719fe4612 | ||
|
|
034a30b444 | ||
|
|
9609e2ac4c | ||
|
|
66c2b72a28 | ||
|
|
da48b0880e | ||
|
|
4134b1549a | ||
|
|
7265b2535b | ||
|
|
bb638377ac | ||
|
|
466113fc4a | ||
|
|
31aea350cb | ||
|
|
56869577d4 | ||
|
|
ed3c597a92 | ||
|
|
cbb607b6b0 | ||
|
|
7f64abe820 | ||
|
|
b43dc1ba37 | ||
|
|
59962e5e88 | ||
|
|
8eabcecb69 | ||
|
|
a3ad726111 | ||
|
|
a46b4edb0a | ||
|
|
7059fe3815 | ||
|
|
780f1afe91 | ||
|
|
2459b4e56f | ||
|
|
f750cee594 | ||
|
|
1c3824f4b9 | ||
|
|
5ba1fa856d | ||
|
|
f40a685ac9 | ||
|
|
bf3b6577d5 | ||
|
|
7b0659332b | ||
|
|
19812cb015 | ||
|
|
b283c80776 | ||
|
|
49838c67ee | ||
|
|
4a40bddd82 | ||
|
|
208b7860aa | ||
|
|
05e7c9470b | ||
|
|
2f79d5f805 | ||
|
|
1f120a04f9 | ||
|
|
90a46f6556 | ||
|
|
4dff14a02a | ||
|
|
d9a9acb616 | ||
|
|
8ea215931e | ||
|
|
6caed6aacc | ||
|
|
0c192fcb57 | ||
|
|
3e819a5051 | ||
|
|
b31983cc3a | ||
|
|
e24cb1783c | ||
|
|
a913aba018 | ||
|
|
35d34ab524 | ||
|
|
604cf6b522 | ||
|
|
e987695732 | ||
|
|
09f37a86ad | ||
|
|
ff32f99610 | ||
|
|
4cd099ef30 | ||
|
|
54d3b0eabc | ||
|
|
b3d731b040 | ||
|
|
6629ec48a3 | ||
|
|
19c273771d | ||
|
|
e7b6919bc1 | ||
|
|
60e6c7d250 | ||
|
|
4feeb0e608 | ||
|
|
b3243efdf5 | ||
|
|
60a23bb280 | ||
|
|
973f38727d | ||
|
|
deaac5808d | ||
|
|
22dc01610e | ||
|
|
fe702d8fea | ||
|
|
10e669423f | ||
|
|
fbf146657e | ||
|
|
8667fab206 | ||
|
|
e974cd4b33 | ||
|
|
43c96803be | ||
|
|
70b42a5633 | ||
|
|
9f989f7706 | ||
|
|
4d976ef803 | ||
|
|
02257fd78f | ||
|
|
929c8f49a6 | ||
|
|
a6ec38c805 | ||
|
|
e5ec8ea3b2 | ||
|
|
36ac5a2802 | ||
|
|
b5beff5030 | ||
|
|
d1d1a5da77 | ||
|
|
713d58612e | ||
|
|
bd0990deb4 | ||
|
|
35e8d9c12b | ||
|
|
1fb7f9ff5b | ||
|
|
7eecb059e6 | ||
|
|
ba8375adb1 | ||
|
|
2ef547c461 | ||
|
|
a34784ca73 | ||
|
|
5594d46c2d | ||
|
|
dc7a1e3f41 | ||
|
|
68732487f9 | ||
|
|
5ea1d4376d | ||
|
|
9cb8b205c5 | ||
|
|
a35c453423 | ||
|
|
e7f91d7c25 | ||
|
|
4886f43463 | ||
|
|
929c8ac2b5 | ||
|
|
1438934aa6 | ||
|
|
ec65335fcd | ||
|
|
39d31dbd11 | ||
|
|
6c5be7a169 | ||
|
|
b45894fd51 | ||
|
|
a660b4e5c4 | ||
|
|
e11c88cf05 | ||
|
|
40f930f08a | ||
|
|
0c55e7819d | ||
|
|
3c17ee941f | ||
|
|
5a67ca0411 | ||
|
|
63d04a6707 | ||
|
|
676a116cda | ||
|
|
55435fd324 | ||
|
|
612f8059b8 | ||
|
|
ffd16f7639 | ||
|
|
528860161e | ||
|
|
1fe6094da5 | ||
|
|
399c51b1ee | ||
|
|
55e4abd534 | ||
|
|
e9d02f441b | ||
|
|
f858bcbe5b | ||
|
|
cd107711a9 | ||
|
|
ce4c20b112 | ||
|
|
0b8ba1ccfa | ||
|
|
c72c97fd53 | ||
|
|
1e12068e64 | ||
|
|
1799fe1ff9 | ||
|
|
ae5175c5b4 | ||
|
|
86d5b0b23d | ||
|
|
341044356f | ||
|
|
5eb7a62062 | ||
|
|
74f96c0766 | ||
|
|
49b62cb27a | ||
|
|
798588c54b | ||
|
|
f1a9cdaa8e | ||
|
|
c66c0a11b6 | ||
|
|
b1cdd1360b | ||
|
|
7c8b48e08a | ||
|
|
64df5c6b41 | ||
|
|
a5c1361dc9 | ||
|
|
798b1a7d2e | ||
|
|
e484e4c6de | ||
|
|
31299a529a | ||
|
|
53ac681d49 | ||
|
|
828ef48441 | ||
|
|
63e8742fb1 | ||
|
|
192a958fdc | ||
|
|
f606e633da | ||
|
|
e2d2b031a5 | ||
|
|
c203a972ff | ||
|
|
44df1aa0bd | ||
|
|
d010587f44 | ||
|
|
840525c11a | ||
|
|
a0881d851c | ||
|
|
ac00e05a72 | ||
|
|
4938568ea7 | ||
|
|
cb4c07a5fb | ||
|
|
4edd76341e | ||
|
|
bb8aee8965 | ||
|
|
5d97d2d680 | ||
|
|
3eb2646cad | ||
|
|
96c3dadb7b | ||
|
|
4d9a238c27 | ||
|
|
a475cfa340 | ||
|
|
e54cec9123 | ||
|
|
3edad29501 | ||
|
|
392a004bd1 | ||
|
|
7f8ec17511 | ||
|
|
d9e6fd3b89 | ||
|
|
6cf59838a6 | ||
|
|
3efa60ce8a | ||
|
|
7a90cd2562 | ||
|
|
4cdbe4f0f4 | ||
|
|
595408b351 | ||
|
|
4ee1fd9f65 | ||
|
|
f16f4d557a | ||
|
|
27314d1af3 | ||
|
|
4f14fb0ccd | ||
|
|
9b2a8f847f | ||
|
|
dae4ae1c6b | ||
|
|
c8023adff1 | ||
|
|
c34ac0f17b | ||
|
|
2222a1bfe2 | ||
|
|
3134809c22 | ||
|
|
203e8c41ce | ||
|
|
5804c044d5 | ||
|
|
80c378df21 | ||
|
|
0f3bc5922d | ||
|
|
1810edfa6e | ||
|
|
362b8d3243 | ||
|
|
b06f76512d | ||
|
|
6c2b421b57 | ||
|
|
63b3b4225a | ||
|
|
5b7ad40163 | ||
|
|
1751fb38e5 | ||
|
|
184a2bcf18 | ||
|
|
57fce9d20f | ||
|
|
d354157c0e | ||
|
|
de78e065cb | ||
|
|
17a49b5d8c | ||
|
|
6c6bbf6294 | ||
|
|
72f04367d9 | ||
|
|
7395305f87 | ||
|
|
1c62a665c7 | ||
|
|
518919aeee | ||
|
|
da798b3748 | ||
|
|
441e936d88 | ||
|
|
23def44101 | ||
|
|
35fafdb476 | ||
|
|
0e20e6a0bb | ||
|
|
04654a5c85 | ||
|
|
e17c4e5271 | ||
|
|
4d79b35c47 | ||
|
|
26aeb7dcbd | ||
|
|
7bc3582525 | ||
|
|
1ad00e1102 | ||
|
|
311ad6b940 | ||
|
|
c65f3289a3 | ||
|
|
cfeaf2f376 | ||
|
|
8434e856f4 | ||
|
|
35a700027c | ||
|
|
2196158f58 | ||
|
|
56d5ca180a | ||
|
|
60326b8f65 | ||
|
|
363943583d | ||
|
|
4348889865 | ||
|
|
50e50e82e1 | ||
|
|
fd30f16364 | ||
|
|
21879db549 | ||
|
|
313b9d64f6 | ||
|
|
87be97a38d | ||
|
|
4f5054d792 | ||
|
|
51545c4db0 | ||
|
|
98fb48eb1d | ||
|
|
fa2817ab52 | ||
|
|
2a35601ff4 | ||
|
|
ed70058a1f | ||
|
|
79a1b65547 | ||
|
|
cccddd8455 | ||
|
|
9a4d9f7f1f | ||
|
|
c532f40b7d | ||
|
|
d7e68c340c | ||
|
|
42a985112a | ||
|
|
16a653ed9d | ||
|
|
91f18323be | ||
|
|
09bbb50e1f | ||
|
|
a4eebfeeb2 | ||
|
|
62d19c9d11 | ||
|
|
07142b3052 | ||
|
|
a304bc0eed | ||
|
|
857b7e53d9 | ||
|
|
2987bb129c | ||
|
|
8da9ad696b | ||
|
|
8720d6937a | ||
|
|
9262834ffb | ||
|
|
a41b1a5a2d | ||
|
|
1e362fdd53 | ||
|
|
8dfe166944 | ||
|
|
8d0feea2c2 | ||
|
|
47d9f5920f | ||
|
|
25eca4146c | ||
|
|
61938601fd | ||
|
|
61d114f297 | ||
|
|
eddebfbba5 | ||
|
|
323d828eb7 | ||
|
|
bb763f7315 | ||
|
|
b1d93112da | ||
|
|
56bd3513a3 | ||
|
|
ddcf26058b | ||
|
|
ba4ee3f1fc | ||
|
|
dedfd5cd33 | ||
|
|
b5296f4206 | ||
|
|
e2e2c58d9f | ||
|
|
7a90b9ce23 | ||
|
|
ae0928e686 | ||
|
|
b815ad7a8c | ||
|
|
06cca9033a | ||
|
|
5302364139 | ||
|
|
78b7fc6169 | ||
|
|
b159c30cf1 | ||
|
|
5c7712bf6c | ||
|
|
e64b766599 | ||
|
|
89a852286c | ||
|
|
1e312cfbb1 | ||
|
|
8d4522227c | ||
|
|
eee39a7c0b | ||
|
|
bd58c18bb0 | ||
|
|
685b3a4f21 | ||
|
|
4e82a482d1 | ||
|
|
1214e28563 | ||
|
|
9170ed6e3a | ||
|
|
f2bb8bb8af | ||
|
|
24d74698ef | ||
|
|
ba615c15cb | ||
|
|
88f206e7f5 | ||
|
|
511740ccd7 | ||
|
|
7a2fab1126 | ||
|
|
fd435f0941 | ||
|
|
ffd5a8b321 | ||
|
|
5454e43bc4 | ||
|
|
a94fd2d127 | ||
|
|
14c53c5e3e | ||
|
|
b25648eea1 | ||
|
|
10d0d162b5 | ||
|
|
e5b2be4346 | ||
|
|
4cea442b59 | ||
|
|
532f682fc7 | ||
|
|
c2cd689c32 | ||
|
|
c3e986eb56 | ||
|
|
d91f4c244f | ||
|
|
22b768963f | ||
|
|
57354cd1ef | ||
|
|
c74cc40d5c | ||
|
|
b867a74b6b | ||
|
|
7a10486492 | ||
|
|
f36b833654 | ||
|
|
ef9206088e | ||
|
|
e141b26411 | ||
|
|
1f4da13060 | ||
|
|
4ec85e2f25 | ||
|
|
842831d729 | ||
|
|
39a0b5672b | ||
|
|
2729892676 | ||
|
|
50318354a6 | ||
|
|
77593c8031 | ||
|
|
3bfb9adb99 | ||
|
|
deebf289de | ||
|
|
d4e777900c | ||
|
|
1b44683cfe | ||
|
|
0ff53f0bd7 | ||
|
|
a5cbf08a76 | ||
|
|
023fa8afc9 | ||
|
|
a721748de1 | ||
|
|
ad112285e6 | ||
|
|
fe05ac9753 | ||
|
|
b873162a6f | ||
|
|
846604cce5 | ||
|
|
b1ea970f62 | ||
|
|
5bcfb7f488 | ||
|
|
1908f1b4f6 | ||
|
|
b0bf8e81aa | ||
|
|
4866ba0c84 | ||
|
|
8dadf42504 | ||
|
|
fc18b15106 | ||
|
|
9b4e55be28 | ||
|
|
8a4686984a | ||
|
|
42ebffc4fc | ||
|
|
2d2c596f75 | ||
|
|
fa464b489d | ||
|
|
b531504912 | ||
|
|
e4a346995b | ||
|
|
f0d1f2387d | ||
|
|
7eb592df79 | ||
|
|
a704c0ad35 | ||
|
|
acf4077878 | ||
|
|
ba50771007 | ||
|
|
898db8b7d4 | ||
|
|
d452a00592 | ||
|
|
4ab8fb359b | ||
|
|
29e6082663 | ||
|
|
7c6197b1fc | ||
|
|
1e0e40912b | ||
|
|
ff84638df8 | ||
|
|
90dee9c171 | ||
|
|
53873c7864 | ||
|
|
f60a9708b2 | ||
|
|
84497bfba7 | ||
|
|
4dfd672c04 | ||
|
|
d8b64aa2f4 | ||
|
|
4968100420 | ||
|
|
b52687f356 | ||
|
|
71d4565aa5 | ||
|
|
42ff295092 | ||
|
|
f0758e2a6c | ||
|
|
33e93ea156 | ||
|
|
9f212184fd | ||
|
|
1c16d4bd3f | ||
|
|
0008ffc735 | ||
|
|
e5dce929bb | ||
|
|
40bcf96c2b | ||
|
|
519d4470e3 | ||
|
|
cdf18b5480 | ||
|
|
dbe4965438 | ||
|
|
899b9b07dd | ||
|
|
54d8a03e87 | ||
|
|
052ad87da0 | ||
|
|
2a515b1d8d | ||
|
|
dad48df039 | ||
|
|
ee798df57d | ||
|
|
eed21b8f8f | ||
|
|
29938f5703 | ||
|
|
52bcf97d73 | ||
|
|
9934184f5f | ||
|
|
fdf33cbf81 | ||
|
|
34458bc86e | ||
|
|
9b061b3aa7 | ||
|
|
2fa6acef1c | ||
|
|
3afb1f145a | ||
|
|
b03b75d125 | ||
|
|
b9756f0bdc | ||
|
|
c3234cb79f | ||
|
|
828ab97837 | ||
|
|
ac66510f32 | ||
|
|
599397b6f7 | ||
|
|
e230f5d358 | ||
|
|
91486f1b70 | ||
|
|
95e6de8654 | ||
|
|
784baaec46 | ||
|
|
6adaca568f | ||
|
|
bcdcceb809 | ||
|
|
de3d075ff2 | ||
|
|
c5f3aa21b3 | ||
|
|
9831b0e3d4 | ||
|
|
24a8df801f | ||
|
|
e0cfd404a1 | ||
|
|
0e62c3455b | ||
|
|
9cd5a7926a | ||
|
|
8e4995c8d9 | ||
|
|
ca5fc1e8fc | ||
|
|
14dca4667a | ||
|
|
ebff14adac | ||
|
|
51f02ed46e | ||
|
|
03740d0918 | ||
|
|
c83a16e22e | ||
|
|
e1bf662884 | ||
|
|
d866bc9044 | ||
|
|
fd0e4c20ee | ||
|
|
55ca0a80b6 | ||
|
|
eeaf3dc2cf | ||
|
|
467b948349 | ||
|
|
f368af3d02 | ||
|
|
0f34ee7d16 | ||
|
|
2fe89fc41b | ||
|
|
968942f128 | ||
|
|
b5fae096a9 | ||
|
|
5cad9a1071 | ||
|
|
f4a350c3d0 | ||
|
|
89885ed4d9 | ||
|
|
612878d3b1 | ||
|
|
65d0bb6a90 | ||
|
|
484b440816 | ||
|
|
92d78515c4 | ||
|
|
341bedd7ca | ||
|
|
e9f54f1841 | ||
|
|
4c4af5f1fc | ||
|
|
2558cd9356 | ||
|
|
4670026c92 | ||
|
|
302b9c2ac5 | ||
|
|
000f1d02c3 | ||
|
|
63ce8429f2 | ||
|
|
61993c4a50 | ||
|
|
c248efc9fe | ||
|
|
ec64ca2865 | ||
|
|
d4fe7467b6 | ||
|
|
e8a229103a | ||
|
|
e6cdab37b0 | ||
|
|
26c88ffaec | ||
|
|
abf1c144c5 | ||
|
|
c4e04d6e07 | ||
|
|
ed4826a67f | ||
|
|
dee2df9e45 | ||
|
|
acabd11d40 | ||
|
|
8adea6ba1e | ||
|
|
c36be55c2f | ||
|
|
5355555568 | ||
|
|
176735d4cf | ||
|
|
3e01bca690 | ||
|
|
dd99d96c24 | ||
|
|
22e8c59031 | ||
|
|
44cefc89e4 | ||
|
|
df15249f23 | ||
|
|
b737321cbd | ||
|
|
319380ec6c | ||
|
|
cae7cad5d4 | ||
|
|
d4c7b41897 | ||
|
|
0ecf6b5aa1 | ||
|
|
cb51c03992 | ||
|
|
5dca5fe3cb | ||
|
|
a7acd50159 | ||
|
|
e732ec9fe4 | ||
|
|
e4070c8b5e | ||
|
|
b171b5904b | ||
|
|
cc89c994c8 | ||
|
|
fc2689e207 | ||
|
|
a5979b2e47 | ||
|
|
2eb8e32705 | ||
|
|
b32984b1d6 | ||
|
|
7e2fd9e690 | ||
|
|
a96dac8205 | ||
|
|
6afc2fd75a | ||
|
|
e44bd4684b | ||
|
|
115158a70e | ||
|
|
63577feca4 | ||
|
|
e8b91bf617 | ||
|
|
567e6f1d82 | ||
|
|
2b9b8ce536 | ||
|
|
a0f4cb9271 | ||
|
|
46f24c582c | ||
|
|
2068710a30 | ||
|
|
0568b5c6de | ||
|
|
a0d9b9fbe8 | ||
|
|
2190e449c1 | ||
|
|
f665b56e2b | ||
|
|
041b6abd59 | ||
|
|
fb7ace729c | ||
|
|
a68ed01003 | ||
|
|
95af80acde | ||
|
|
18664b7e7e | ||
|
|
37f9634389 | ||
|
|
a995b76f24 | ||
|
|
cb81e50f71 | ||
|
|
f8ba151b76 | ||
|
|
a0af67fce8 | ||
|
|
1467936c89 | ||
|
|
0d3008b839 | ||
|
|
517821632a | ||
|
|
0ed3e540c2 | ||
|
|
c96bb16db6 | ||
|
|
bd82441883 | ||
|
|
18421cde49 | ||
|
|
6dea26932e | ||
|
|
258768505e | ||
|
|
8caa20b746 | ||
|
|
5efc39af6a | ||
|
|
66daa2eb29 | ||
|
|
02687991e0 | ||
|
|
1e64592a39 | ||
|
|
9d2b074bec | ||
|
|
384a6f3d36 | ||
|
|
754d972253 | ||
|
|
9a29a6de5a | ||
|
|
f6513932b0 | ||
|
|
368f91c4c5 | ||
|
|
f1f40f0289 | ||
|
|
1d6671c11a | ||
|
|
9a0fa2f8b3 | ||
|
|
9b6ec9ffd3 | ||
|
|
e9b8fe5018 | ||
|
|
4a5cec8ed5 | ||
|
|
fa6f0ba77c | ||
|
|
a8fc58e143 | ||
|
|
57961e04b3 | ||
|
|
6628aa7eaf | ||
|
|
b7e492e03d | ||
|
|
2f2dc86c9d | ||
|
|
bfb2ff9390 | ||
|
|
cbd14c4b8c | ||
|
|
cb08660a78 | ||
|
|
87e1b075e0 | ||
|
|
26a3682c6e | ||
|
|
be30a2463a | ||
|
|
cc1df37725 | ||
|
|
3510032050 | ||
|
|
07aecd3a95 | ||
|
|
0e2a96b402 | ||
|
|
603c121874 | ||
|
|
9e634196bf | ||
|
|
4f20ea4570 | ||
|
|
c851708b3d | ||
|
|
fd6a693bc8 | ||
|
|
bab56b4c9d | ||
|
|
970da50910 | ||
|
|
0008e4b645 | ||
|
|
89e7a62d99 | ||
|
|
74e89c542a | ||
|
|
d441483201 | ||
|
|
f11d4fa613 | ||
|
|
11f9880ccf | ||
|
|
8c440961c5 | ||
|
|
8f5d7da934 | ||
|
|
807347da80 | ||
|
|
9364491316 | ||
|
|
255e12849e | ||
|
|
5c0fe81dcf | ||
|
|
e34dee8852 | ||
|
|
a803420576 | ||
|
|
a1939bc295 | ||
|
|
8c7bbd937f | ||
|
|
c87b2eaf7b | ||
|
|
f156718d86 | ||
|
|
9cabfacb99 | ||
|
|
377237d7c0 | ||
|
|
13f2611b25 | ||
|
|
519dfd3be7 | ||
|
|
c9c8d23ed5 | ||
|
|
ed4ceb41b5 | ||
|
|
fb4643630b | ||
|
|
999c3be21a | ||
|
|
0793a0638e | ||
|
|
8ad1d93cc6 | ||
|
|
afb4c9a00d | ||
|
|
93d9516a07 | ||
|
|
7950f23b6d | ||
|
|
178e206d19 | ||
|
|
d157308306 | ||
|
|
261eb19fea | ||
|
|
6a973421e3 | ||
|
|
325110c0cd | ||
|
|
184360925d | ||
|
|
58710196ca | ||
|
|
a3c57a01d6 | ||
|
|
63d26c2a51 | ||
|
|
8cd824f66f | ||
|
|
1652990324 | ||
|
|
28221e398e | ||
|
|
49fde8158f | ||
|
|
59d1526a88 | ||
|
|
36fdf1f67b | ||
|
|
a2771c262b | ||
|
|
de4e753429 | ||
|
|
cac9104769 | ||
|
|
f56cb03a09 | ||
|
|
911d3ad722 | ||
|
|
72a1984331 | ||
|
|
67035b8422 | ||
|
|
1c9416fbed | ||
|
|
cf25ced2e6 | ||
|
|
4003697850 | ||
|
|
7f48c7abbe | ||
|
|
b8d924ab6f | ||
|
|
b58a4e90da | ||
|
|
f781da41a4 | ||
|
|
c0695e80a8 | ||
|
|
019363e56b | ||
|
|
bf76567fdf | ||
|
|
e64250c519 | ||
|
|
4d190cd055 | ||
|
|
fe02fd7284 | ||
|
|
d73ced98ad | ||
|
|
ee5f915cca | ||
|
|
d801f1f5fb | ||
|
|
bd32afbed2 | ||
|
|
226d98cf6b | ||
|
|
dc3b4d3770 | ||
|
|
409169061e | ||
|
|
c539166747 | ||
|
|
2bb199bc25 | ||
|
|
6da9c50b9d | ||
|
|
8118f781d9 | ||
|
|
2e2f28d1bb | ||
|
|
316bb91625 | ||
|
|
263adb157c | ||
|
|
18937bdcc4 | ||
|
|
948d7498bd | ||
|
|
59ff18b508 | ||
|
|
baa9501c65 | ||
|
|
5c44f55ef6 | ||
|
|
095778cf0f | ||
|
|
2cec3f29d1 | ||
|
|
9523b88d77 | ||
|
|
6bcab179d1 | ||
|
|
fc1fdab51a | ||
|
|
f9bb3defde | ||
|
|
6075a92905 | ||
|
|
f495edfb3a | ||
|
|
6af47fa6ee | ||
|
|
972789dba3 | ||
|
|
cec1ed8d3d | ||
|
|
374963167a | ||
|
|
ccb5826a25 | ||
|
|
527aed0ea3 | ||
|
|
a8e266377c | ||
|
|
de57dc9410 | ||
|
|
617f0c8c17 | ||
|
|
2e73199153 | ||
|
|
5b0b674988 | ||
|
|
d85a74570d | ||
|
|
bb1f8aab24 | ||
|
|
0c4fb36827 | ||
|
|
ec2017ff72 | ||
|
|
f3cc0a07bc | ||
|
|
5e2dc95331 | ||
|
|
ee99abc266 | ||
|
|
cbf4ab797d | ||
|
|
bbe0bfadd9 | ||
|
|
35414e0afd | ||
|
|
90e99aac3b | ||
|
|
59506a97d6 | ||
|
|
ebf9b0e4f1 | ||
|
|
b85a8b8b0b | ||
|
|
f8029a6dc9 | ||
|
|
95eb9afeef | ||
|
|
87024f0426 | ||
|
|
09697f2593 | ||
|
|
e99e9f3e40 | ||
|
|
b8c05e551d | ||
|
|
829eb7d3a2 | ||
|
|
268080cbc5 | ||
|
|
8d9d0dd826 | ||
|
|
195c201f87 | ||
|
|
ceb0fc4db9 | ||
|
|
6121a9b48c | ||
|
|
e3138154f1 | ||
|
|
ac6c7f6a35 | ||
|
|
af6e31dcdf | ||
|
|
6f158e3382 | ||
|
|
81504bba1e | ||
|
|
66bedf46a1 | ||
|
|
a196ac03b1 | ||
|
|
ae1010166a | ||
|
|
a548212f27 | ||
|
|
1aeb6d0d9e | ||
|
|
612c963105 | ||
|
|
173a60eac6 | ||
|
|
8411efc8ef | ||
|
|
af8fe35222 | ||
|
|
a0e5f64ddf | ||
|
|
c80f0d317a | ||
|
|
e5a9159282 | ||
|
|
8215791051 | ||
|
|
ab62abed79 | ||
|
|
b31356aada | ||
|
|
b0db219aeb | ||
|
|
20a7c550fe | ||
|
|
2eb190dbbb | ||
|
|
d97360ef52 | ||
|
|
fab64c61c4 | ||
|
|
b9fea2ea12 | ||
|
|
adc4ae48d6 | ||
|
|
e7549a2887 | ||
|
|
f28507a366 | ||
|
|
a1b2c011f5 | ||
|
|
b8ee051f8f | ||
|
|
06e34c88b5 | ||
|
|
9866b92405 | ||
|
|
d1846217fd | ||
|
|
aa82f3637b | ||
|
|
731684f22f | ||
|
|
48b84270c4 | ||
|
|
acc4bbf628 | ||
|
|
1718c3bc16 | ||
|
|
235fa57423 | ||
|
|
90f0ebde1d | ||
|
|
e016725814 | ||
|
|
3f449a40ad | ||
|
|
e92726bdb3 | ||
|
|
45fe70d8ed | ||
|
|
e833e5d86d | ||
|
|
3dff5cb99f | ||
|
|
666d09e296 | ||
|
|
6e1e49a185 | ||
|
|
15c13ece27 | ||
|
|
754efefd32 | ||
|
|
f81e69f73c | ||
|
|
dd8e73e8f2 | ||
|
|
660520b939 | ||
|
|
a1c3096556 | ||
|
|
8cd9dea821 | ||
|
|
0cf64a7dde | ||
|
|
53aff4fbbb | ||
|
|
78789fad1c | ||
|
|
3c54d844b2 | ||
|
|
d8e27abff9 | ||
|
|
b7b8f9caa6 | ||
|
|
7e1cd47a4e | ||
|
|
badbd846c2 | ||
|
|
e08089ba3e | ||
|
|
27f57ce0b3 | ||
|
|
8aa773df9a | ||
|
|
8fb19d24e8 | ||
|
|
fd1376be53 | ||
|
|
051f0fd377 | ||
|
|
954644a001 | ||
|
|
19fcbf8f25 | ||
|
|
c1e2c20ace | ||
|
|
09dbbc17e4 | ||
|
|
4d9db3665f | ||
|
|
625f19ae00 | ||
|
|
dcc715d75d | ||
|
|
e8717498b5 | ||
|
|
ecfbbb39bd | ||
|
|
2cd8f56842 | ||
|
|
588b9737bf | ||
|
|
22d540caaa | ||
|
|
2dead0306a | ||
|
|
b77fa9f627 | ||
|
|
6a29eecf8d | ||
|
|
049e9f1a55 | ||
|
|
dcb995c626 | ||
|
|
6200f5fb62 | ||
|
|
cc27c19c66 | ||
|
|
23dc818eac | ||
|
|
311d40a9f1 | ||
|
|
ad4d2831c9 | ||
|
|
ee9c959262 | ||
|
|
b739603a3c | ||
|
|
153701133d | ||
|
|
d8704edc7f | ||
|
|
57f6b2d122 | ||
|
|
21c41fb145 | ||
|
|
12d35a39c7 | ||
|
|
11aa9f7b79 | ||
|
|
23ae3ad8ad | ||
|
|
84d468ad2f | ||
|
|
0459612632 | ||
|
|
7dfa4bcdb5 | ||
|
|
a3e73508f4 | ||
|
|
df120ec4a3 | ||
|
|
6dfa6a3710 | ||
|
|
7ae39a00cb | ||
|
|
0cbcbe3e69 | ||
|
|
47debc0223 | ||
|
|
5953f08495 | ||
|
|
43276582ed | ||
|
|
2c3d7871ff | ||
|
|
112f10a16d | ||
|
|
28beefcbb8 | ||
|
|
edcff1068b | ||
|
|
266f23d1e6 | ||
|
|
c4dfd24782 | ||
|
|
9ae2de6dc1 | ||
|
|
45fd6f89c0 | ||
|
|
b1ba4b505a | ||
|
|
99e6cf4796 | ||
|
|
4df5752df7 | ||
|
|
7a2837b6c9 | ||
|
|
dc08805307 | ||
|
|
2ffebb9c0b | ||
|
|
2553a51408 | ||
|
|
e2a338c3c9 | ||
|
|
795f4cd7a7 | ||
|
|
932fa22701 | ||
|
|
5c746ad3d4 | ||
|
|
d0c8a80e5e | ||
|
|
da40f7ab07 | ||
|
|
f4c42a5d39 | ||
|
|
7b3a752ad9 | ||
|
|
ad861e7da1 | ||
|
|
17e8cf8aaa | ||
|
|
6773f1e152 | ||
|
|
928b95861d | ||
|
|
f274abcc8d | ||
|
|
5a725af1bb | ||
|
|
b0d5c8870a | ||
|
|
fb14a49dd5 | ||
|
|
b6d2ec3bea | ||
|
|
3fd5b77de8 | ||
|
|
b060039a28 | ||
|
|
ba84e8bc33 | ||
|
|
cba111c055 | ||
|
|
a1f4c3506d | ||
|
|
a4e0abf7bc | ||
|
|
7058bb5e12 | ||
|
|
43d4d3cddc | ||
|
|
c4804f427f | ||
|
|
430ef5d1a6 | ||
|
|
d8fb4304b7 | ||
|
|
caf5ee7412 | ||
|
|
2acfbcdce6 | ||
|
|
c687c5df24 | ||
|
|
f63db81268 | ||
|
|
00de9bbbc5 | ||
|
|
825db1158c | ||
|
|
b5bff64cf0 | ||
|
|
c5255872ca | ||
|
|
9920f44a90 | ||
|
|
f5bbc43c87 | ||
|
|
7076809b71 | ||
|
|
34b7cda2ec | ||
|
|
f2cd90a999 | ||
|
|
2c35c63a09 | ||
|
|
7832a6eb6f | ||
|
|
e1c3dda6e0 | ||
|
|
f11c015522 | ||
|
|
9cd23bc02b | ||
|
|
8c0ab4285b | ||
|
|
3cbc5aaf2d | ||
|
|
c43aae15ff | ||
|
|
2fd3ded6e2 | ||
|
|
cb6d727664 | ||
|
|
3be2047c9c | ||
|
|
b3ec9a0900 | ||
|
|
50cf830404 | ||
|
|
72e58a7f0d | ||
|
|
36781c0bc6 | ||
|
|
12ca7d0fe2 | ||
|
|
b85066eb06 | ||
|
|
456705de54 | ||
|
|
31b500cc7f | ||
|
|
03d0011c2f | ||
|
|
101088cadc | ||
|
|
638702728c | ||
|
|
015a0888d4 | ||
|
|
361eaeca07 | ||
|
|
6850c2a9ee | ||
|
|
12af387e50 | ||
|
|
55216be46b | ||
|
|
7630642c56 | ||
|
|
ad8fe7923a | ||
|
|
f06b4f70f9 | ||
|
|
408ecda944 | ||
|
|
95844cd6c0 | ||
|
|
cf4824e588 | ||
|
|
c99aaf763d | ||
|
|
1156027587 | ||
|
|
46c6d43556 | ||
|
|
07fccd0479 | ||
|
|
10e4fe7a71 | ||
|
|
5f37891eae | ||
|
|
f09644be00 | ||
|
|
96e573b356 | ||
|
|
bed63b55fe | ||
|
|
0a8ac5cb05 | ||
|
|
590d7cc79b | ||
|
|
aeeaa18b28 | ||
|
|
d6a6f1ed51 | ||
|
|
68bf5d5105 | ||
|
|
78d5f6f598 | ||
|
|
fa8c6dfa6f | ||
|
|
15d3bc70d2 | ||
|
|
c37b52645c | ||
|
|
e6f61699d7 | ||
|
|
6cdf61d6cf | ||
|
|
60dee64fa0 | ||
|
|
21f4ba4f3a | ||
|
|
df4777dca4 | ||
|
|
03b8e98cb2 | ||
|
|
fafe2374b7 | ||
|
|
1840fac000 | ||
|
|
ec460ff07a | ||
|
|
b0e68366d4 | ||
|
|
99266e4ea9 | ||
|
|
34025599a0 | ||
|
|
21f34b8039 | ||
|
|
30b3a4c9c7 | ||
|
|
7ca2f7d6b1 | ||
|
|
7a6ac1f6d0 | ||
|
|
e53f0a3191 | ||
|
|
54b28ae356 | ||
|
|
22b7181c40 | ||
|
|
daf6a856c7 | ||
|
|
4e2baa0868 | ||
|
|
6b48084c9c | ||
|
|
1e48959c0a | ||
|
|
088c37d1ea | ||
|
|
18dcc21340 | ||
|
|
e03c1d4c85 | ||
|
|
9fb85f252e | ||
|
|
c7601c9921 | ||
|
|
eab2bd3565 | ||
|
|
4454c6be73 | ||
|
|
0adf8a0a05 | ||
|
|
bdf59c1a5f | ||
|
|
e317926fcb | ||
|
|
1487a0ecd2 | ||
|
|
950d2689c7 | ||
|
|
8687ed6697 | ||
|
|
ab9c0dab04 | ||
|
|
45e2819694 | ||
|
|
0187a0cace | ||
|
|
9d714ba9e0 | ||
|
|
a614434c04 | ||
|
|
0fbfee521f | ||
|
|
d2233acc44 | ||
|
|
4b86741683 | ||
|
|
26bf91e1da | ||
|
|
37eab31b40 | ||
|
|
39aa548586 | ||
|
|
a228b36e8e | ||
|
|
7d33a1572e | ||
|
|
5ccbf0042c | ||
|
|
0313ea636a | ||
|
|
d7a5db3dbb | ||
|
|
82435bf6ff | ||
|
|
e56a4ed9e2 | ||
|
|
52ef16dba5 | ||
|
|
e4713edd75 | ||
|
|
5abe72f7e7 | ||
|
|
fdeb07f82b | ||
|
|
44b59eea58 | ||
|
|
f8bf2f38d3 | ||
|
|
091854a6d0 | ||
|
|
fd55aa61cf | ||
|
|
7bd014f9de | ||
|
|
793ef35c95 | ||
|
|
d8eb8499ef | ||
|
|
ad98339de7 | ||
|
|
d121326382 | ||
|
|
bd9e689885 | ||
|
|
79dcf6d63b | ||
|
|
3390a26588 | ||
|
|
93d1cd3ee7 | ||
|
|
4b3cfc5de1 | ||
|
|
f9d38fdd69 | ||
|
|
628c375b8c | ||
|
|
714c884732 | ||
|
|
f6dffe9845 | ||
|
|
a28b3cc268 | ||
|
|
388dd99986 | ||
|
|
1081b6a1c0 | ||
|
|
80d93b1fc9 | ||
|
|
3980fe5de1 | ||
|
|
b374b1ef7a | ||
|
|
09a7865e7d | ||
|
|
2f9a399d18 | ||
|
|
bbda3955c3 | ||
|
|
ba42932024 | ||
|
|
f7c8bd6d1c | ||
|
|
35479575ec | ||
|
|
23a4aab3c4 | ||
|
|
ec5bd18b67 | ||
|
|
d5750bf329 | ||
|
|
ac55d35b13 | ||
|
|
a1c27049d6 | ||
|
|
8b36b29126 | ||
|
|
c0e75ac6b4 | ||
|
|
897f3a86c5 | ||
|
|
58025d3b01 | ||
|
|
591197422d | ||
|
|
027b1f711c | ||
|
|
5f15a0f555 | ||
|
|
c46238301a | ||
|
|
7c282d28df | ||
|
|
587251e73c | ||
|
|
12dbafd0c9 | ||
|
|
3c822399b1 | ||
|
|
ae7252fbec | ||
|
|
13dfde1862 | ||
|
|
3a0aef3779 | ||
|
|
a82cc8cbd4 | ||
|
|
6e6701a644 | ||
|
|
b6b74e292f | ||
|
|
db0dfdcd59 | ||
|
|
fc49643860 | ||
|
|
7968c1dcd2 | ||
|
|
b9180798ca | ||
|
|
8ed0888ea8 | ||
|
|
e5d941f98b | ||
|
|
62f434f0e0 | ||
|
|
829451486e | ||
|
|
0da1a293e6 | ||
|
|
a51ccad560 | ||
|
|
b8ab30fc22 | ||
|
|
915bc6c7cd | ||
|
|
0bc55a5185 | ||
|
|
07c2973459 | ||
|
|
2bc8722049 | ||
|
|
84259fd9d8 | ||
|
|
31474b581b | ||
|
|
2fc71c762a | ||
|
|
a541e6db1f | ||
|
|
a4aab9f4c2 | ||
|
|
2d6abc088f | ||
|
|
a1f3d42fd0 | ||
|
|
915e72584c | ||
|
|
22ef3c8b2a | ||
|
|
0936793b23 | ||
|
|
8bbdf56cb0 | ||
|
|
25fd939bc6 | ||
|
|
5e4f31fe84 | ||
|
|
5638b4f889 | ||
|
|
2f28a7f3f2 | ||
|
|
9f3137e509 | ||
|
|
32c91f56f3 | ||
|
|
c81284754f | ||
|
|
e300546a32 | ||
|
|
ce0f62d598 | ||
|
|
18e1987a6a | ||
|
|
626c12c8a3 | ||
|
|
8e8fb9cfe8 | ||
|
|
c0c3f2c9ba | ||
|
|
7e4846b83c | ||
|
|
adcd0e2936 | ||
|
|
2a02a2e40b | ||
|
|
8b8953b98c | ||
|
|
05baa544bc | ||
|
|
95aee6eb37 | ||
|
|
d348c0e794 | ||
|
|
bdc25e4fb5 | ||
|
|
f864fba78b | ||
|
|
ec34261674 | ||
|
|
119965a7fb | ||
|
|
24c672ddc9 | ||
|
|
56578c7c0c | ||
|
|
fdc78b5c32 | ||
|
|
3585223827 | ||
|
|
13bdb881c7 | ||
|
|
12c46c794f | ||
|
|
3b839ebd1f | ||
|
|
04d5c98756 | ||
|
|
2cce4bf2a8 | ||
|
|
15560229ce | ||
|
|
20317e5830 | ||
|
|
2bf1de5a43 | ||
|
|
7306ce09b4 | ||
|
|
846bcf3ef5 | ||
|
|
69b69da52a | ||
|
|
7a7be6e454 | ||
|
|
3587e450a3 | ||
|
|
0b8001eac2 | ||
|
|
8235c6d4fc | ||
|
|
aed88bd857 | ||
|
|
8fcca219b4 | ||
|
|
4b16ed6bdd | ||
|
|
3ad7901edb | ||
|
|
a684823f25 | ||
|
|
90a03c5096 | ||
|
|
46f8f3c27e | ||
|
|
3569a85488 | ||
|
|
9a0942e9b2 | ||
|
|
26725bd878 | ||
|
|
ae01148b76 | ||
|
|
1269959265 | ||
|
|
a471d68d6c | ||
|
|
2eb8859080 | ||
|
|
038fe07fd4 | ||
|
|
578b899653 | ||
|
|
32e0151f7d | ||
|
|
43cf02d5b8 | ||
|
|
d60a1193b2 | ||
|
|
806e0b6d7f | ||
|
|
74434e87c5 | ||
|
|
41935d8b48 | ||
|
|
8a93c7472f | ||
|
|
687737f71a | ||
|
|
c4296f0127 | ||
|
|
933e8d4409 | ||
|
|
28950473b2 | ||
|
|
6a478ca315 | ||
|
|
03d4175bea | ||
|
|
25abdef96a | ||
|
|
a01d8548e3 | ||
|
|
c1946e57b7 | ||
|
|
811ed6efe5 | ||
|
|
6855a0afbe | ||
|
|
f9e68a0c9c | ||
|
|
f1ecdfc9df | ||
|
|
01fc9f6130 | ||
|
|
a2c3f74ab2 | ||
|
|
11301d7b63 | ||
|
|
1d2e1d9950 | ||
|
|
47938a2278 | ||
|
|
6922ad04a9 | ||
|
|
cc24e73483 | ||
|
|
59fed5c756 | ||
|
|
f93e7579bc | ||
|
|
a617053d97 | ||
|
|
3ebd5a95d4 | ||
|
|
4f4ecbf819 | ||
|
|
cb81b63524 | ||
|
|
8bd3512bc8 | ||
|
|
7f0d3c89bd | ||
|
|
f4d87458dd | ||
|
|
2c3c80e45c | ||
|
|
1a24193d2c | ||
|
|
92ac40e4da | ||
|
|
fcc316674e | ||
|
|
a0237d4259 | ||
|
|
bf061b9d4f | ||
|
|
6f3b5b1c61 | ||
|
|
1244b6b283 | ||
|
|
b01303f5ae | ||
|
|
3a9d5730e5 | ||
|
|
17a8a5984b | ||
|
|
0cd2c067b6 | ||
|
|
b4342492d5 | ||
|
|
ccbbdd280d | ||
|
|
ada209dc75 | ||
|
|
a602e3c88a | ||
|
|
b507d527e3 | ||
|
|
6d1ce4bca2 | ||
|
|
36eda331d1 | ||
|
|
a2eca89fb8 | ||
|
|
a555ba09f1 | ||
|
|
313104a01b | ||
|
|
744d2a535f | ||
|
|
f08d9d2775 | ||
|
|
224cf9b88d | ||
|
|
5ba06a74a0 | ||
|
|
1f14cc35dd | ||
|
|
4953307e1e | ||
|
|
b33d429212 | ||
|
|
d3a17b64f4 | ||
|
|
5a572b25a0 | ||
|
|
03187804c4 | ||
|
|
99b005f0cc | ||
|
|
7bf5d027bf | ||
|
|
e6f7cc8d74 | ||
|
|
4224c01925 | ||
|
|
ea85d577d8 | ||
|
|
add0e43723 | ||
|
|
e7378cbba0 | ||
|
|
dc58ff19d4 | ||
|
|
7bce331eb1 | ||
|
|
141dc247d6 | ||
|
|
dda8df678a | ||
|
|
e06abbc354 | ||
|
|
26938c245b | ||
|
|
54e9803080 | ||
|
|
bf30c7cb01 | ||
|
|
32f063fd2b | ||
|
|
e4c27a31fa | ||
|
|
365e44e376 | ||
|
|
7e55a8558a | ||
|
|
e38b007743 | ||
|
|
f2dd248200 | ||
|
|
ce8673e7e2 | ||
|
|
aaf4deee2c | ||
|
|
7a0895f872 | ||
|
|
d052c32f7a | ||
|
|
07dbee52cd | ||
|
|
aa8b1f39b3 | ||
|
|
849c550191 | ||
|
|
41cdb4911c | ||
|
|
15c4efcbe4 | ||
|
|
6b776f0b92 | ||
|
|
b8005deaa4 | ||
|
|
2fc35e2543 | ||
|
|
e7fcfff370 | ||
|
|
4bc9033205 | ||
|
|
8673550b69 | ||
|
|
e47ed9c012 | ||
|
|
bdd58a50b1 | ||
|
|
e3d8deba0c | ||
|
|
b386832256 | ||
|
|
26564cfeda | ||
|
|
78e560318d | ||
|
|
7a88044edb | ||
|
|
cc06968c42 | ||
|
|
ae7c89d746 | ||
|
|
0c525a8e52 | ||
|
|
4ac562a55a | ||
|
|
5180673b6d | ||
|
|
f573046107 | ||
|
|
a24878209b | ||
|
|
f12d69a4f6 | ||
|
|
4a1706ede6 | ||
|
|
f5cb34f506 | ||
|
|
2f1e758eb4 | ||
|
|
f825f43528 | ||
|
|
8f1844921e | ||
|
|
1cd887d3ec | ||
|
|
0bb53a73a8 | ||
|
|
6ede5dda6b | ||
|
|
3dbf92bb58 | ||
|
|
f447d7f423 | ||
|
|
a3f6a330e2 | ||
|
|
0c26670bf6 | ||
|
|
97884af83d | ||
|
|
946df5f8d6 | ||
|
|
e98a12c797 | ||
|
|
7444870741 | ||
|
|
2bcf6a5da8 | ||
|
|
b77fa8d57b | ||
|
|
cfd6f063e1 | ||
|
|
a8906da890 | ||
|
|
b63046b20a | ||
|
|
df91e31397 | ||
|
|
b40622c093 | ||
|
|
a925aac1df | ||
|
|
2081b6a4a8 | ||
|
|
7b66f5afb3 | ||
|
|
a14da417a7 | ||
|
|
5af4e1db67 | ||
|
|
e90e0f7d57 | ||
|
|
eac0901af0 | ||
|
|
79f3f69827 | ||
|
|
7c0ca54249 | ||
|
|
d10d4220a8 | ||
|
|
ab8ef25f89 | ||
|
|
8ff60854ac | ||
|
|
41938a5f16 | ||
|
|
10f8a2e807 | ||
|
|
2d8de7009b | ||
|
|
88cc17b530 | ||
|
|
df09d0c8bb | ||
|
|
749aa28b9a | ||
|
|
912ec6a9e9 | ||
|
|
e49957b2b2 | ||
|
|
06e74ffb47 | ||
|
|
4ebbc638da | ||
|
|
757fbbdd88 | ||
|
|
c73965f69a | ||
|
|
2af0f73473 | ||
|
|
305ecf8a7c | ||
|
|
da56090604 | ||
|
|
98eb5640ed | ||
|
|
1e1b1baad5 | ||
|
|
a68103e8ba | ||
|
|
3438addf6c | ||
|
|
6fc7c4e2c0 | ||
|
|
dc7537ac0a | ||
|
|
d7a83f3361 | ||
|
|
5e75b1e7dc | ||
|
|
a11a16a700 | ||
|
|
a3de8281ef | ||
|
|
7960528464 | ||
|
|
a8b067885f | ||
|
|
945fabbdd6 | ||
|
|
c12bf0aead | ||
|
|
12f25ddafd | ||
|
|
55f07e913a | ||
|
|
0bd22281f7 | ||
|
|
72ab62b21b | ||
|
|
796d30d863 | ||
|
|
b191323e2b | ||
|
|
e4ae0988a4 | ||
|
|
238ebdeed8 | ||
|
|
68ebe1a4ff | ||
|
|
8a89be6999 | ||
|
|
0620fc9f17 | ||
|
|
1e95e38505 | ||
|
|
5b4e5f9d1d | ||
|
|
6285fd9f98 | ||
|
|
401d5cab66 | ||
|
|
d7e2df5ca9 | ||
|
|
b38177bb32 | ||
|
|
27b9cbda38 | ||
|
|
a71e08ad2a | ||
|
|
5e0c9165ba | ||
|
|
cb2a6cd3b5 | ||
|
|
81c0e73751 | ||
|
|
6f12594b3e | ||
|
|
5a296b1238 | ||
|
|
249456c916 | ||
|
|
5aa2554584 | ||
|
|
9999ced817 | ||
|
|
6c137b29c2 | ||
|
|
854c070b82 | ||
|
|
6a5a4664e9 | ||
|
|
5aaecd3946 | ||
|
|
425310710f | ||
|
|
af990fb666 | ||
|
|
c0b2669c46 | ||
|
|
edc615f487 | ||
|
|
04b8b8dd5a | ||
|
|
34ef36544e | ||
|
|
4a9deadcf4 | ||
|
|
e1eb1d705a | ||
|
|
ab035a3887 | ||
|
|
c92f0f3edf | ||
|
|
ceb73730c2 | ||
|
|
60e0a731ad | ||
|
|
d9e77284c1 | ||
|
|
4d9c7d0dcb | ||
|
|
936d2e56ea | ||
|
|
4be1923921 | ||
|
|
7bb5866164 | ||
|
|
0f2854fe17 | ||
|
|
548b2f4b77 | ||
|
|
cd776e4b64 | ||
|
|
aeca4c0f9c | ||
|
|
d96b1bb9f8 | ||
|
|
944bdd5bba | ||
|
|
e61550841b | ||
|
|
ff5e171d4a | ||
|
|
b5bb92459d | ||
|
|
b9ea94e9be | ||
|
|
f42186f7c9 | ||
|
|
b510bff195 | ||
|
|
c1b85c0d21 | ||
|
|
08f84bdc07 | ||
|
|
187c93377f | ||
|
|
eb4b85dc79 | ||
|
|
36d7bf77e3 | ||
|
|
2a47e5f32c | ||
|
|
b522abffb5 | ||
|
|
ba272061b7 | ||
|
|
142542da1e | ||
|
|
c79c4d265c | ||
|
|
95289f1715 | ||
|
|
a35d5c4c3a | ||
|
|
c6fd36b75d | ||
|
|
985eb69c50 | ||
|
|
17912ebffe | ||
|
|
a9b41d4a21 | ||
|
|
0b020ce1ac | ||
|
|
580532aeca | ||
|
|
8c43047c95 | ||
|
|
05aeef0ea0 | ||
|
|
ced9493069 | ||
|
|
76ab3fd1ab | ||
|
|
7d6fcda03e | ||
|
|
a7d2c1137c | ||
|
|
033ad18779 | ||
|
|
404706a3db | ||
|
|
2c3bf06740 | ||
|
|
a132b58227 | ||
|
|
8d91141d6a | ||
|
|
a8ac895998 | ||
|
|
ee8aa1d9c6 | ||
|
|
206e45214f | ||
|
|
ba2aef0468 | ||
|
|
7642b522f9 | ||
|
|
b8960c4549 | ||
|
|
358b823e00 | ||
|
|
aa3a95f528 | ||
|
|
00a1eebf60 | ||
|
|
b6587da081 | ||
|
|
bcd6e6767a | ||
|
|
7d21772f87 | ||
|
|
949d706eaa | ||
|
|
c8445b9b5f | ||
|
|
d3c901678c | ||
|
|
1549affd5c | ||
|
|
f9e875a7cc | ||
|
|
5b65279a0a | ||
|
|
ccd58d2909 | ||
|
|
714f56c17c | ||
|
|
a820a96996 | ||
|
|
1d77523e41 | ||
|
|
107c1529ff | ||
|
|
a7f80ef144 | ||
|
|
9274864a83 | ||
|
|
f51bbd8a39 | ||
|
|
1534e1a1ee | ||
|
|
0c9c176223 | ||
|
|
e58ed7a3dc | ||
|
|
adde65f757 | ||
|
|
b45939ed26 | ||
|
|
3de4920385 | ||
|
|
0ab4df99b7 | ||
|
|
adaabcb8e5 | ||
|
|
68403ee142 | ||
|
|
1eb0040126 | ||
|
|
6cca2fd991 | ||
|
|
f276ab830a | ||
|
|
2d3f45bad5 | ||
|
|
30259c4360 | ||
|
|
cfa091dbc4 | ||
|
|
eb18f474c8 | ||
|
|
6554a027d7 | ||
|
|
0e83f0b217 | ||
|
|
b45d6945b1 | ||
|
|
c2e32c0bf2 | ||
|
|
926b9b1d1a | ||
|
|
57b51cec9c | ||
|
|
ebfcc2e23a | ||
|
|
980b3234d5 | ||
|
|
a25b914085 | ||
|
|
c936000d62 | ||
|
|
e1f3adafb7 | ||
|
|
4745eb190a | ||
|
|
d78784e45e | ||
|
|
6e60ff2062 | ||
|
|
b8c1c1ef1e | ||
|
|
d918f0fb03 | ||
|
|
91d6880218 | ||
|
|
ea30075602 | ||
|
|
a00ca647f5 | ||
|
|
f6260087c3 | ||
|
|
81e1d86047 | ||
|
|
988ac8e60b | ||
|
|
cc624f9ed2 | ||
|
|
8d2984c572 | ||
|
|
29d4396956 | ||
|
|
0ba0023099 | ||
|
|
2ef26e9681 | ||
|
|
3be6b6966b | ||
|
|
415aeb1ef5 | ||
|
|
2fc25e9b13 | ||
|
|
00a032e6b0 | ||
|
|
04ab95ab76 | ||
|
|
2f3c7eb550 | ||
|
|
dce6d50350 | ||
|
|
6ac63436f7 | ||
|
|
03979d8665 | ||
|
|
8991232681 | ||
|
|
31a0604341 | ||
|
|
8b6ac9c736 | ||
|
|
ac5279fa70 | ||
|
|
ed2ea88cb5 | ||
|
|
f2a7706bdf | ||
|
|
b88d2fe111 | ||
|
|
9b9b4d4bdf | ||
|
|
41037eb425 | ||
|
|
ba126f1f1a | ||
|
|
88894a6d54 | ||
|
|
61cb276b94 | ||
|
|
f83f5455c2 | ||
|
|
09e409cb79 | ||
|
|
39e3cba80e | ||
|
|
8246f1c990 | ||
|
|
10c32381d4 | ||
|
|
5b6efbbb5f | ||
|
|
5edb5276f8 | ||
|
|
b1109780ed | ||
|
|
62070c50ff | ||
|
|
8332dc188a | ||
|
|
3e28fd69b3 | ||
|
|
4cf6f7bd7c | ||
|
|
a2b0a57971 | ||
|
|
df7d5c6075 | ||
|
|
e6f9811162 | ||
|
|
7625c75dc7 | ||
|
|
07ab79d8dd | ||
|
|
54f8550229 | ||
|
|
f6ae7587ea | ||
|
|
2d78d04d52 | ||
|
|
5a26ee2ca9 | ||
|
|
8971d7b876 | ||
|
|
158894c7cc | ||
|
|
589f98bcc2 | ||
|
|
9b250b0dda | ||
|
|
ebe147ee34 | ||
|
|
4cd0334ed1 | ||
|
|
c49506e588 | ||
|
|
238f5a9af3 | ||
|
|
5d81d0e640 | ||
|
|
4baa0b102d | ||
|
|
0cd17f15d7 | ||
|
|
1fa08bbbc3 | ||
|
|
9e06242c1d | ||
|
|
5b7006d695 | ||
|
|
cd3273bb51 | ||
|
|
917ad5f750 | ||
|
|
29ee22f6cc | ||
|
|
4ad8157ba0 | ||
|
|
69a8bd1761 | ||
|
|
2bdeae0ddb | ||
|
|
0fb1eec3cd | ||
|
|
243d6ebd2c | ||
|
|
6b2882fe47 | ||
|
|
6ad8dc7f3e | ||
|
|
fcedab74c0 | ||
|
|
7404c642e3 | ||
|
|
d922961112 | ||
|
|
c679970832 | ||
|
|
8393cd4b86 | ||
|
|
42125c756e | ||
|
|
447df0af17 | ||
|
|
38d5646975 | ||
|
|
b16656bd23 | ||
|
|
0f987916b7 | ||
|
|
21e419ff8a | ||
|
|
d2acc351a2 | ||
|
|
faa076c1e9 | ||
|
|
1eac28a145 | ||
|
|
df7791a3e7 | ||
|
|
176a23fe97 | ||
|
|
548ff068fd | ||
|
|
50ce433bcb | ||
|
|
d8ada8c9d3 | ||
|
|
f04972a902 | ||
|
|
0b2ec35324 | ||
|
|
77278e77eb | ||
|
|
c6f2c8a3f5 | ||
|
|
e037972dbb | ||
|
|
ba24c55d41 | ||
|
|
034a24dfe3 | ||
|
|
9f7851a178 | ||
|
|
7ea2d7d1ab | ||
|
|
8ecfb872b6 | ||
|
|
2a91ab07b9 | ||
|
|
111d11a71b | ||
|
|
6aeee05e8a | ||
|
|
472586e772 | ||
|
|
4f15322cec | ||
|
|
0e46ff2b6d | ||
|
|
fcf90a053a | ||
|
|
b9e19e84d4 | ||
|
|
1fc60cf410 | ||
|
|
21bc1fd5a6 | ||
|
|
3989f0c332 | ||
|
|
23ffef8943 | ||
|
|
c3105fa66f | ||
|
|
8b09b2cdba | ||
|
|
315426a4b6 | ||
|
|
51d948fc29 | ||
|
|
68f4f011b7 | ||
|
|
ebdd6c5a4d | ||
|
|
deda8dcd97 | ||
|
|
f19f29a4bd | ||
|
|
0677a8a21a | ||
|
|
b3c12c33b7 | ||
|
|
09f57d3bb6 | ||
|
|
6b9b249e22 | ||
|
|
78327f648d | ||
|
|
df32c1c5d5 | ||
|
|
e93f13f6b0 | ||
|
|
02d2b89a4d | ||
|
|
34ff64b103 | ||
|
|
827dc3da8b | ||
|
|
1cd9c8f817 | ||
|
|
e8a9035e68 | ||
|
|
a288c8d7fb | ||
|
|
88e8c2ba33 | ||
|
|
252ec6fe59 | ||
|
|
e664ab18ee | ||
|
|
b78c5b32c6 | ||
|
|
4ddc8f950e | ||
|
|
0260a33678 | ||
|
|
358c3ab0c3 | ||
|
|
a658599406 | ||
|
|
d0b1bde521 | ||
|
|
b24075ca1c | ||
|
|
88fb4051a4 | ||
|
|
0c7cff5602 | ||
|
|
f872f17d39 | ||
|
|
70917c19d1 | ||
|
|
4353e997fc | ||
|
|
e5bf8a8e75 | ||
|
|
d3928b30de | ||
|
|
ec2bc5e8cb | ||
|
|
b74e3d389b | ||
|
|
e567668346 | ||
|
|
6e31480ed9 | ||
|
|
d35b65c9d2 | ||
|
|
0f27299586 | ||
|
|
baff716ef6 | ||
|
|
1141676223 | ||
|
|
a6ce80d39b | ||
|
|
6d3e0eaa22 | ||
|
|
18c1333496 | ||
|
|
ab00d73d7a | ||
|
|
5bc574025d | ||
|
|
71e7d92d75 | ||
|
|
723c7a97fc | ||
|
|
16a3b88db5 | ||
|
|
19ed31a2c2 | ||
|
|
93fd430863 | ||
|
|
c1ac810ff2 | ||
|
|
e785085d0d | ||
|
|
334133ea61 | ||
|
|
82b801498a | ||
|
|
83c74cf9e1 | ||
|
|
3dc4dcf874 | ||
|
|
aaf184ddb3 | ||
|
|
21e9e64b3d | ||
|
|
48c431c0a9 | ||
|
|
8992b4a284 | ||
|
|
c9d7da5951 | ||
|
|
f76744fc98 | ||
|
|
b624874768 | ||
|
|
ed84727938 | ||
|
|
10f8318883 | ||
|
|
7dd7f1a32c | ||
|
|
a06fa75419 | ||
|
|
7e0ca09bf7 | ||
|
|
cae3d7b321 | ||
|
|
1c30a93da1 | ||
|
|
03d30d7f99 | ||
|
|
6e4aecb3dc | ||
|
|
660d01c59a | ||
|
|
81cccadf80 | ||
|
|
e0ea5af18e | ||
|
|
4544759cff | ||
|
|
6a466fcb12 | ||
|
|
a07c09b3d4 | ||
|
|
2c3bee16c9 | ||
|
|
9a397c1ff8 | ||
|
|
c627363fca | ||
|
|
219899fc9b | ||
|
|
d987d99913 | ||
|
|
985c32510c | ||
|
|
01ab19a263 | ||
|
|
0ba6d5de28 | ||
|
|
e6031addf5 | ||
|
|
8845babb28 | ||
|
|
ed34a59a0c | ||
|
|
767cd877b8 | ||
|
|
fd7c4a0653 | ||
|
|
26f08a59ad | ||
|
|
841b6f68dd | ||
|
|
dbe835912a | ||
|
|
6b9182645d | ||
|
|
16c1ca0bba | ||
|
|
181aea9aec | ||
|
|
422971d229 | ||
|
|
2010a3169d | ||
|
|
397b538c9d | ||
|
|
1d1d843dc7 | ||
|
|
abd6fe9f2d | ||
|
|
f5db3c08e3 | ||
|
|
0b568b2d28 | ||
|
|
42885a3df0 | ||
|
|
cd820c2dbe | ||
|
|
0944ed331b | ||
|
|
f45b9a3757 | ||
|
|
d52c552721 | ||
|
|
2a5bdbcbdc | ||
|
|
2606f7196e | ||
|
|
09a672561d | ||
|
|
cbabdf02de | ||
|
|
a65d7cdc15 | ||
|
|
1a17efcf8e | ||
|
|
9f60d63a6b | ||
|
|
4426166f1d | ||
|
|
d97ceeaa6c | ||
|
|
a7ac615bb2 | ||
|
|
90fc23205c | ||
|
|
c233fec9b9 | ||
|
|
a8df726bff | ||
|
|
ff3f26f935 | ||
|
|
a882a5f346 | ||
|
|
1b318154c2 | ||
|
|
390cf44a88 | ||
|
|
3e71253ffb | ||
|
|
748e2a81ad | ||
|
|
d3ebe43cbd | ||
|
|
7a13b9c4b7 | ||
|
|
15f9aabaf0 | ||
|
|
c617a8f354 | ||
|
|
6ac2cd4686 | ||
|
|
2833da3b2d | ||
|
|
8058a79ed0 | ||
|
|
93755a62aa | ||
|
|
d4c7e00a19 | ||
|
|
70deb7b388 | ||
|
|
c229439dec | ||
|
|
cb2dda8421 | ||
|
|
4558321ef7 | ||
|
|
9376f048be | ||
|
|
d038227941 | ||
|
|
2c885cb347 | ||
|
|
01bf13189c | ||
|
|
f92d433a3e | ||
|
|
25476f2973 | ||
|
|
1d4bff1add | ||
|
|
30864a16a2 | ||
|
|
7b492fe7ed | ||
|
|
7186c9a3a0 | ||
|
|
a5760a7462 | ||
|
|
aa5c6283a7 | ||
|
|
280955801c | ||
|
|
adc3f6d184 | ||
|
|
c9ebb6da00 | ||
|
|
a8f04a1ba5 | ||
|
|
d478e4b1f4 | ||
|
|
ac9b2e8ba4 | ||
|
|
770ee6aaec | ||
|
|
003a6ef4d2 | ||
|
|
f9e43fae29 | ||
|
|
7e1eb5a970 | ||
|
|
f231218a69 | ||
|
|
e21c9cb8f0 | ||
|
|
8597808a61 | ||
|
|
1871eed0ab | ||
|
|
8f2685b335 | ||
|
|
cd85b54dd7 | ||
|
|
6dd04142b3 | ||
|
|
0618054968 | ||
|
|
e11673d15c | ||
|
|
066a4de15f | ||
|
|
5ffac12f5b | ||
|
|
b24631345b | ||
|
|
ab3332ed8f | ||
|
|
58084c6a65 | ||
|
|
6664733650 | ||
|
|
f7a537ab91 | ||
|
|
0506d47a4f | ||
|
|
e06bcab62b | ||
|
|
90061a4b25 | ||
|
|
5a17fa53cd | ||
|
|
88c284dbf1 | ||
|
|
dd98fdbee1 | ||
|
|
af43079e33 | ||
|
|
aa6097dff8 | ||
|
|
7fa4346cd1 | ||
|
|
d286041e04 | ||
|
|
bf0f9e1fa2 | ||
|
|
d4c0dd824b | ||
|
|
528ce8c9de | ||
|
|
7c4ff7677d | ||
|
|
cb36991cb2 | ||
|
|
f15a4df79e | ||
|
|
901b7a0f12 | ||
|
|
687bcc3469 | ||
|
|
a239e435a6 | ||
|
|
75728418af | ||
|
|
893714c968 | ||
|
|
5cb4044408 | ||
|
|
4966ce447f | ||
|
|
8213bf5b6d | ||
|
|
280d90cdc4 | ||
|
|
df5a327da4 | ||
|
|
e736923312 | ||
|
|
fe4f932be4 | ||
|
|
fe7e39776b | ||
|
|
da33e480c3 | ||
|
|
19a0a7098d | ||
|
|
74d46f201a | ||
|
|
0eec061d01 | ||
|
|
7c1ad9abab | ||
|
|
3ad99011f2 | ||
|
|
cb8331f213 | ||
|
|
ffa2858d82 | ||
|
|
1cf20da416 | ||
|
|
30bc7e4f6c | ||
|
|
9f406c6725 | ||
|
|
b1ff790e43 | ||
|
|
90f304a881 | ||
|
|
99cbfa13cb | ||
|
|
ce7736a4b8 | ||
|
|
c36ed7b660 | ||
|
|
d6c4705626 | ||
|
|
9df4455f07 | ||
|
|
5e4923b5bc | ||
|
|
9d00189ac0 | ||
|
|
3af2d7c0df | ||
|
|
521222ad19 | ||
|
|
e0f5a1c1a1 | ||
|
|
fa393a53b2 | ||
|
|
43e81781a3 | ||
|
|
b03e9922a4 | ||
|
|
7206e46377 | ||
|
|
554b9a03b5 | ||
|
|
20278d23e1 | ||
|
|
81607da632 | ||
|
|
c1ec74a5b7 | ||
|
|
eaed0c098b | ||
|
|
886fb6b5a1 | ||
|
|
9fe92bc669 | ||
|
|
098e9fee8c | ||
|
|
1d0f670100 | ||
|
|
ee7f505cde | ||
|
|
4581850b05 | ||
|
|
bc757016af | ||
|
|
d3259a8430 | ||
|
|
d57107ca2a | ||
|
|
2cf606bdbd | ||
|
|
32cd559379 | ||
|
|
ad8551b746 | ||
|
|
a26bef8813 | ||
|
|
34dad07393 | ||
|
|
5453aec1d0 | ||
|
|
03a5671bb0 | ||
|
|
37c16fbb48 | ||
|
|
92431f20d7 | ||
|
|
9b6b66d22d | ||
|
|
83477c67d7 | ||
|
|
ac31392b90 | ||
|
|
201485eed6 | ||
|
|
87992f9e75 | ||
|
|
0b24721b4a | ||
|
|
8d540751e1 | ||
|
|
fc8b2ee679 | ||
|
|
bc512e775c | ||
|
|
7b9d54183c | ||
|
|
85d640c4f8 | ||
|
|
a0275aa413 | ||
|
|
7d1c4a9991 | ||
|
|
ade05d5d1b | ||
|
|
6e259f9a0e | ||
|
|
02a21b8050 | ||
|
|
5fe7c5d888 | ||
|
|
1ee4437970 | ||
|
|
a8cebfe06c | ||
|
|
0b73275933 | ||
|
|
04fec2c2f0 | ||
|
|
ccd560cbc6 | ||
|
|
43df7f18be | ||
|
|
2f18d1ff8b | ||
|
|
6c816bfdeb | ||
|
|
afa8cfce5e | ||
|
|
49ad4bdb26 | ||
|
|
e76e8b1404 | ||
|
|
9794b72607 | ||
|
|
997a29e70b | ||
|
|
a478a1c888 | ||
|
|
5db11aa49a | ||
|
|
24a650f562 | ||
|
|
a1d9bf297f | ||
|
|
92682cb11f | ||
|
|
b51b02b1d3 | ||
|
|
df410d2444 | ||
|
|
ec07380055 | ||
|
|
3a766cd826 | ||
|
|
eef7fa5b40 | ||
|
|
eb726e47c3 | ||
|
|
5378cd07bf | ||
|
|
d8b935369b | ||
|
|
4e2f396b4a | ||
|
|
34c43a2bbe | ||
|
|
f7fddbc162 | ||
|
|
4c2a53ac26 | ||
|
|
ffe1021c2a | ||
|
|
3fcbcb9455 | ||
|
|
19fbce4479 | ||
|
|
b2e0874efa | ||
|
|
ca81422c4b | ||
|
|
6bdf433e95 | ||
|
|
daba5b2102 | ||
|
|
9dbf992c40 | ||
|
|
7772749e88 | ||
|
|
0c0fd48700 | ||
|
|
41f2cdc6e6 | ||
|
|
cf572ea931 | ||
|
|
da372fbb93 | ||
|
|
92e1336db0 | ||
|
|
a9d3dffd3c | ||
|
|
5fac4abc07 | ||
|
|
28a795eddb | ||
|
|
06b824928b | ||
|
|
5b57707b86 | ||
|
|
a348febf3e | ||
|
|
7f8a7ac628 | ||
|
|
a5fab4e0f6 | ||
|
|
2724e90981 | ||
|
|
26fc80213e | ||
|
|
47890fa74e | ||
|
|
49b35a9216 | ||
|
|
a08bbbad29 | ||
|
|
3b93cf8e28 | ||
|
|
75258afb6c | ||
|
|
fca37601dd | ||
|
|
55301efa3e | ||
|
|
82052848ee | ||
|
|
25dd52fdda | ||
|
|
c891c3cff8 | ||
|
|
917e75050e | ||
|
|
a46b3aa816 | ||
|
|
60fafd399f | ||
|
|
f3d3eb43dc | ||
|
|
5ff030607e | ||
|
|
71492c5d37 | ||
|
|
f553f2d2b0 | ||
|
|
5fdff2dc6f | ||
|
|
4185de77e0 | ||
|
|
aa51a6c54e | ||
|
|
092509b3c3 | ||
|
|
695279e784 | ||
|
|
5c6bccd7b3 | ||
|
|
45c8b48b0a | ||
|
|
51130c354b | ||
|
|
79d1845266 | ||
|
|
4f1173e609 | ||
|
|
23178a2727 | ||
|
|
60ab73d8a4 | ||
|
|
2a39120b38 | ||
|
|
c5bc699c26 | ||
|
|
9cc225dede | ||
|
|
5f743f4cad | ||
|
|
a7266e38c4 | ||
|
|
ea2f202e4d | ||
|
|
c1169f0d2c | ||
|
|
37d7c178f5 | ||
|
|
c34d64b3bb | ||
|
|
8934596527 | ||
|
|
c13ac87a5b | ||
|
|
09ea2dcd10 | ||
|
|
1dd6707070 | ||
|
|
d5367fc2b2 | ||
|
|
0333406fbc | ||
|
|
6f779faa05 | ||
|
|
82fa559962 | ||
|
|
eca93cb43f | ||
|
|
04e648b3f9 | ||
|
|
6de0debb49 | ||
|
|
84929771be | ||
|
|
3b00230580 | ||
|
|
959b11d19e | ||
|
|
2ad59f1aa5 | ||
|
|
494682c2af | ||
|
|
d48d0e621f | ||
|
|
1a3382aa24 | ||
|
|
5c065d3f8a | ||
|
|
4799957d08 | ||
|
|
307f43ce12 | ||
|
|
b13fc99797 | ||
|
|
1f30f8dcf3 | ||
|
|
fbb40e1232 | ||
|
|
1d5999e50b | ||
|
|
04713d9652 | ||
|
|
050f432c10 | ||
|
|
1201f4e008 | ||
|
|
5614f57f43 | ||
|
|
f9d82b8ead | ||
|
|
fba181bfea | ||
|
|
10d20748ad | ||
|
|
25fc832ae5 | ||
|
|
fe5ef03bc8 | ||
|
|
fe158d20ed | ||
|
|
95cb311f6c | ||
|
|
e1bb98ec94 | ||
|
|
d7e0e44de0 | ||
|
|
8a54e4cd76 | ||
|
|
b89c4f95e8 | ||
|
|
087a1a1af5 | ||
|
|
db86ceca0e | ||
|
|
a54b0389ae | ||
|
|
6c826b6ecf | ||
|
|
8e864b9df4 | ||
|
|
6e0837325c | ||
|
|
b237df4b6d | ||
|
|
96f8a57f44 | ||
|
|
f5575510f5 | ||
|
|
745a72a0c4 | ||
|
|
c34b9e77a1 | ||
|
|
7e8a47cd92 | ||
|
|
a0ecab10ac | ||
|
|
185c2575b6 | ||
|
|
565f627429 | ||
|
|
ef4f483a9e | ||
|
|
92538de969 | ||
|
|
88fe1cae08 | ||
|
|
fbb59d2d6c | ||
|
|
3b9688eb2f | ||
|
|
03debbf434 | ||
|
|
f3bc909a02 | ||
|
|
c3c20acb80 | ||
|
|
eccb4530a1 | ||
|
|
3dd81071a5 | ||
|
|
d95f98f67d | ||
|
|
94797986a9 | ||
|
|
ac5e7e8973 | ||
|
|
2684c4a735 | ||
|
|
bd67f86769 | ||
|
|
e2765a3fd6 | ||
|
|
73714933d7 | ||
|
|
d3da0bf860 | ||
|
|
dc011d522f | ||
|
|
3d1ecc1881 | ||
|
|
7676f10e0c | ||
|
|
c83bdfa810 | ||
|
|
282677b8fc | ||
|
|
b2d0080637 | ||
|
|
5f1be7c815 | ||
|
|
d5e2d6b88b | ||
|
|
39a2efbcd9 | ||
|
|
063b367951 | ||
|
|
37ce59af6e | ||
|
|
2d0cd5d186 | ||
|
|
dbbded56cf | ||
|
|
67d6ac1760 | ||
|
|
48d2ce5a98 | ||
|
|
96a8a0f1fa | ||
|
|
4253a46282 | ||
|
|
660c255532 | ||
|
|
3956f1d183 | ||
|
|
234e1e6810 | ||
|
|
e9e2d0bf10 | ||
|
|
5d8a380f86 | ||
|
|
a9a06a0652 | ||
|
|
9f4b03c14f | ||
|
|
a8f93a5a9c | ||
|
|
4c52d51aa2 | ||
|
|
663b89a4a5 | ||
|
|
0a4779ed8c | ||
|
|
c09463e529 | ||
|
|
f93b029b82 | ||
|
|
929122934e | ||
|
|
dfd38150f2 | ||
|
|
11bb86a8ed | ||
|
|
05dad7e0d6 | ||
|
|
541316cd89 | ||
|
|
08c75a2d06 | ||
|
|
15a4aa3d1b | ||
|
|
acb46d3e86 | ||
|
|
000bd1b200 | ||
|
|
baf87f837a | ||
|
|
0bcc8639c1 | ||
|
|
e75b25c0c1 | ||
|
|
2cc6d17014 | ||
|
|
404bb0eafd | ||
|
|
284f0e7ccb | ||
|
|
081df4cad9 | ||
|
|
13d25939ec | ||
|
|
9b6c05ca04 | ||
|
|
8b9e78e158 | ||
|
|
a974f311d9 | ||
|
|
b034137516 | ||
|
|
b819271441 | ||
|
|
b898391124 | ||
|
|
4c57436fe8 | ||
|
|
f0479a656a | ||
|
|
41e0537eca | ||
|
|
dd04990143 | ||
|
|
d0d9344c8a | ||
|
|
64ee2ef045 | ||
|
|
061d444a8f | ||
|
|
d4cb690b8b | ||
|
|
bd50f1ce59 | ||
|
|
944cae53de | ||
|
|
17b43d021a | ||
|
|
059af3a621 | ||
|
|
524701caad | ||
|
|
34111df889 | ||
|
|
5dfca74327 | ||
|
|
12cfdac1b0 | ||
|
|
5ccf66bd9b | ||
|
|
4f344ab1a6 | ||
|
|
624ac5b81c | ||
|
|
7c2fb3506c | ||
|
|
dc4ac5568c | ||
|
|
460cfd05c6 | ||
|
|
40525d9bcf | ||
|
|
8dbf8c92cf | ||
|
|
92d417dc0c | ||
|
|
43e9a63210 | ||
|
|
4483d748e9 | ||
|
|
48f2581d07 | ||
|
|
f074f1ab36 | ||
|
|
42bea06b93 | ||
|
|
6550454d1e | ||
|
|
0a80316d09 | ||
|
|
64b98a8330 | ||
|
|
992c63480d | ||
|
|
6566f3f83d | ||
|
|
973da2de61 | ||
|
|
bf7fdd68f2 | ||
|
|
1136d367c7 | ||
|
|
e7b1c9b7cd | ||
|
|
9a03e0866b | ||
|
|
a5d26bdc81 | ||
|
|
e9cca9657f | ||
|
|
8498dd927f | ||
|
|
ccc8d2ba33 | ||
|
|
1098b0254e | ||
|
|
9eda86eb29 | ||
|
|
2d126010bc | ||
|
|
30f4744199 | ||
|
|
e26892ad90 | ||
|
|
4976b7e648 | ||
|
|
a539b629e7 | ||
|
|
8bd22b545c | ||
|
|
8d3796324d | ||
|
|
af53fe8e79 | ||
|
|
4bcff181c7 | ||
|
|
783da0c45d | ||
|
|
6ef4a6eb08 | ||
|
|
9e52513138 | ||
|
|
e9043d1e93 | ||
|
|
3dd821a975 | ||
|
|
18ba7ed086 | ||
|
|
0128385195 | ||
|
|
4c3efab946 | ||
|
|
858d427690 | ||
|
|
486666279d | ||
|
|
24d2ddada7 | ||
|
|
023d757964 | ||
|
|
e4b12d6a2d | ||
|
|
d67625a966 | ||
|
|
608f671c48 | ||
|
|
9ef1c70eb2 | ||
|
|
b7e236a693 | ||
|
|
d519a92719 | ||
|
|
a83d7c6140 | ||
|
|
d74a8636b3 | ||
|
|
d010271f5d | ||
|
|
f868d3eead | ||
|
|
166ae08465 | ||
|
|
15f3450f8c | ||
|
|
b2bc2700b3 | ||
|
|
8183f57b85 | ||
|
|
79ffb7b9b8 | ||
|
|
af108e1ac9 | ||
|
|
627bca09c0 | ||
|
|
08de2cc920 | ||
|
|
f1c87b6604 | ||
|
|
9f6c5ccccb | ||
|
|
41fab091d0 | ||
|
|
484d5a5968 | ||
|
|
eabacfafb2 | ||
|
|
2ec2e85679 | ||
|
|
e0bb6d106c | ||
|
|
20a16de9de | ||
|
|
e3d8c06ad0 | ||
|
|
7e3563f64b | ||
|
|
f188db2dab | ||
|
|
0473d232ed | ||
|
|
861e43a25b | ||
|
|
3e0fcc4b87 | ||
|
|
a355892ce5 | ||
|
|
52c0f31578 | ||
|
|
e132b54c9f | ||
|
|
dc942c5734 | ||
|
|
a7038a9eaf | ||
|
|
7664e0b187 | ||
|
|
e8ccc48815 | ||
|
|
eda40621c4 | ||
|
|
5b4c6b62a7 | ||
|
|
b7bab76232 | ||
|
|
bd3c39eaaf | ||
|
|
2fb1d6f731 | ||
|
|
ef299acbe8 | ||
|
|
005c4ded24 | ||
|
|
cfceabb4ec | ||
|
|
06095ec343 | ||
|
|
a753a654ca | ||
|
|
2dfd6c79c0 | ||
|
|
abbf0cd856 | ||
|
|
83ec50e4ab | ||
|
|
d51b6fd61d | ||
|
|
894bb05cba | ||
|
|
669720c6dc | ||
|
|
fdcbc2db86 | ||
|
|
37f0e4af3e | ||
|
|
7c14e63fef | ||
|
|
7b5088b921 | ||
|
|
66fe22d716 | ||
|
|
d2339cc7c2 | ||
|
|
d53c7f5d2d | ||
|
|
efdc6053ff | ||
|
|
ab3ec443d2 | ||
|
|
f5873ae0e4 | ||
|
|
e9197817f5 | ||
|
|
c04c8ef815 | ||
|
|
c5d1181d72 | ||
|
|
4b479ad327 | ||
|
|
be4497f768 | ||
|
|
6ad79b12a6 | ||
|
|
24fe6b3c4d | ||
|
|
f4d5f1c584 | ||
|
|
9a18ab44a6 | ||
|
|
a97530bde8 | ||
|
|
ec176bbec5 | ||
|
|
76e194ab1a | ||
|
|
460e1c87d9 | ||
|
|
66db3fd6d6 | ||
|
|
15ec342519 | ||
|
|
136d262d4c | ||
|
|
582dafd50d | ||
|
|
a827a1b105 | ||
|
|
50a62edbaf | ||
|
|
4924b39f93 | ||
|
|
afe2c9db2f | ||
|
|
d18b30da10 | ||
|
|
d6b07185ae | ||
|
|
1a32753ce9 | ||
|
|
0bab743936 | ||
|
|
6f82912701 | ||
|
|
827ffa88fe | ||
|
|
83534e2848 | ||
|
|
a7dcbea8ef | ||
|
|
36a35ef303 | ||
|
|
91eced4b26 | ||
|
|
ec5f33179a | ||
|
|
e180ae4cbd | ||
|
|
98bc81cdd5 | ||
|
|
2b549c358d | ||
|
|
d170b0d0e1 | ||
|
|
5fbdd03acb | ||
|
|
3e3ba6e7ed | ||
|
|
ea929a78e0 | ||
|
|
c845c19477 | ||
|
|
ef0d2c6234 | ||
|
|
8af5f54767 | ||
|
|
fb601ee80f | ||
|
|
72fa9d1a4a | ||
|
|
d1b21708e6 | ||
|
|
703aa07407 | ||
|
|
6e2ed61743 | ||
|
|
c9ce98c5d5 | ||
|
|
f0c23b7244 | ||
|
|
00e49e76be | ||
|
|
05eb7b35f8 | ||
|
|
f6df412350 | ||
|
|
f952b9bbcb | ||
|
|
9160021442 | ||
|
|
77e245aec3 | ||
|
|
eaf8193d37 | ||
|
|
8257b05c8f | ||
|
|
0912139fc5 | ||
|
|
4592566748 | ||
|
|
22851dd9e8 | ||
|
|
87bab96097 | ||
|
|
81ed566467 | ||
|
|
336220d998 | ||
|
|
859e71d976 | ||
|
|
deb25d916d | ||
|
|
c412a01fa6 | ||
|
|
2a9be8a28c | ||
|
|
310704e0c5 | ||
|
|
03f89c9131 | ||
|
|
8ed39f43b4 | ||
|
|
84292beef9 | ||
|
|
d612b86d7f | ||
|
|
93180d6843 | ||
|
|
644ec3caec | ||
|
|
bb5aa47d7b | ||
|
|
b9338b31bc | ||
|
|
5ed3b39219 | ||
|
|
ee55afe8c0 | ||
|
|
6bfab3d04a | ||
|
|
5f84f1378b | ||
|
|
18a63504ed | ||
|
|
44f80dc385 | ||
|
|
fe5af8308c | ||
|
|
197fc48d92 | ||
|
|
293268a004 | ||
|
|
c558d8fcaa | ||
|
|
b13ad57ea5 | ||
|
|
eba839b58e | ||
|
|
36a480a5fc | ||
|
|
68c83ea156 | ||
|
|
9102c94db2 | ||
|
|
26d6330771 | ||
|
|
c123d27b89 | ||
|
|
8aa5324892 | ||
|
|
fb448e27ad | ||
|
|
b24c872b52 | ||
|
|
fdb31f37ba | ||
|
|
87733729b1 | ||
|
|
09cbbb4570 | ||
|
|
cc2489e4ed | ||
|
|
82d71b637d | ||
|
|
c4c0e67407 | ||
|
|
d0c5e98366 | ||
|
|
83c5afdd2d | ||
|
|
c46663007b | ||
|
|
df748e5e75 | ||
|
|
e98685b6cc | ||
|
|
2374c67975 | ||
|
|
30f288a6b9 | ||
|
|
aea7609e0b | ||
|
|
700b256cad | ||
|
|
64b4372a18 | ||
|
|
32461d221a | ||
|
|
b9190e116a | ||
|
|
2d6247d48a | ||
|
|
4aaf001885 | ||
|
|
cc5726577e | ||
|
|
626ae53057 | ||
|
|
ff69f6fdfc | ||
|
|
3178af0074 | ||
|
|
98a93346fc | ||
|
|
01eea12f4e | ||
|
|
1b78881f78 | ||
|
|
a0b5f87b7d | ||
|
|
557fbc21ef | ||
|
|
7de27389aa | ||
|
|
049148305f | ||
|
|
90f468c329 | ||
|
|
cd7acbc4ce | ||
|
|
907f020bf6 | ||
|
|
a6af89755d | ||
|
|
e3ee49a868 | ||
|
|
af538c4feb | ||
|
|
4e5d5aac8c | ||
|
|
5c8526d197 | ||
|
|
4f13055a45 | ||
|
|
2d7a035297 | ||
|
|
cc6f2c00df | ||
|
|
3293a33f38 | ||
|
|
5e6dd56933 | ||
|
|
6104d6193c | ||
|
|
b45c711483 | ||
|
|
bebcefddcc | ||
|
|
68a9089d14 | ||
|
|
c6f96906ca | ||
|
|
9733fb22fd | ||
|
|
e6010e334a | ||
|
|
4f427601d4 | ||
|
|
a716a5788d | ||
|
|
a308ffebeb | ||
|
|
649667a403 | ||
|
|
97f9805afa | ||
|
|
6d0cdcd20b | ||
|
|
a8e85f2c41 | ||
|
|
2e11551bd7 | ||
|
|
ea7aae603d | ||
|
|
6c3976e657 | ||
|
|
09abd1e5cd | ||
|
|
d5d467192d | ||
|
|
d455e50a27 | ||
|
|
f7d9970842 | ||
|
|
b4a7ba239c | ||
|
|
86e3fc7075 | ||
|
|
be2ef28fad | ||
|
|
97fcdf9ce6 | ||
|
|
b9f7ea187d | ||
|
|
c8f5f1ae1d | ||
|
|
92b8b00a49 | ||
|
|
eeddb32ab6 | ||
|
|
c1a59a015c | ||
|
|
bc3b13d719 | ||
|
|
29dcbaeaa3 | ||
|
|
46f6e6d1ea | ||
|
|
c76b7a8b77 | ||
|
|
8514513af3 | ||
|
|
dc2ee92404 | ||
|
|
7cd5b881b2 | ||
|
|
63545c1f08 | ||
|
|
171862097e | ||
|
|
ab69f64957 | ||
|
|
91bf2a85d0 | ||
|
|
6315aad0bc | ||
|
|
613a0386bd | ||
|
|
a79565bb65 | ||
|
|
63213d7f10 | ||
|
|
218d7a7f15 | ||
|
|
4f5e87b1e1 | ||
|
|
8ef27ccbf6 | ||
|
|
b1e3aaf399 | ||
|
|
1af1c84132 | ||
|
|
c6a00d0e45 | ||
|
|
319556daec | ||
|
|
c096736e2b | ||
|
|
afea1c4175 | ||
|
|
f00dda7f43 | ||
|
|
8bc52b29e7 | ||
|
|
967b10311e | ||
|
|
09a600d955 | ||
|
|
a99e064c28 | ||
|
|
01f1043e1a | ||
|
|
c3316346ac | ||
|
|
19da676caf | ||
|
|
39a14d6528 | ||
|
|
198c4c7b5a | ||
|
|
698f3b4fad | ||
|
|
f3bee9e85f | ||
|
|
75f1b045c9 | ||
|
|
24bcee02c1 | ||
|
|
2b159dfb02 | ||
|
|
67f79f20dc | ||
|
|
a992871cb9 | ||
|
|
802e67d8ba | ||
|
|
5169ba8798 | ||
|
|
f41f9c2d87 | ||
|
|
d720433880 | ||
|
|
11747f43ee | ||
|
|
66b0163f7b | ||
|
|
e7006a9ac4 | ||
|
|
9ace4d7cc6 | ||
|
|
d3d8641053 | ||
|
|
2de46d7038 | ||
|
|
d1062ec050 | ||
|
|
079ba05b88 | ||
|
|
a47fef9d19 | ||
|
|
adbca4ba1a | ||
|
|
41ac9563ef | ||
|
|
9a48bcc013 | ||
|
|
aba08042ed | ||
|
|
9f9804c8a3 | ||
|
|
1f1ac06c91 | ||
|
|
d2f3f9d1b5 | ||
|
|
111688ff18 | ||
|
|
a81a29c952 | ||
|
|
9c3e677e0c | ||
|
|
02ce13c858 | ||
|
|
523d111ec6 | ||
|
|
dd6d186a08 | ||
|
|
9b8aae29dd | ||
|
|
cf406c280d | ||
|
|
7917343593 | ||
|
|
588e0c9bbc | ||
|
|
f054a0f4fd | ||
|
|
dac5b6cae8 | ||
|
|
4c1fe51786 | ||
|
|
bcafd3c9b9 | ||
|
|
318a485a92 | ||
|
|
1a46f37e92 | ||
|
|
f9484c1ba5 | ||
|
|
6f3a3c9514 | ||
|
|
2e9b009aa5 | ||
|
|
4458ebd03e | ||
|
|
84e5e488a9 | ||
|
|
1df41fbd29 | ||
|
|
b5d95fda22 | ||
|
|
3c5e144493 | ||
|
|
b1e467d34f | ||
|
|
390bc93e54 | ||
|
|
a7b2a1ed70 | ||
|
|
7e7fd97075 | ||
|
|
4bf97204d1 | ||
|
|
b9b2b179e1 | ||
|
|
e3ef424a41 | ||
|
|
387e7bc2f5 | ||
|
|
328d21e526 | ||
|
|
85579403e9 | ||
|
|
08358a52a7 | ||
|
|
6d1c190a13 | ||
|
|
4208c9f2ff | ||
|
|
a14c3a2a60 | ||
|
|
c8afca6485 | ||
|
|
eecaa2a394 | ||
|
|
62a37ac1f4 | ||
|
|
a8dd424211 | ||
|
|
9e9fafcc5c | ||
|
|
78dc8c3188 | ||
|
|
6ddcc74697 | ||
|
|
79c34eb6d2 | ||
|
|
cdf08821bb | ||
|
|
e54e9068dc | ||
|
|
2af32c76eb | ||
|
|
ae8ffeabc9 | ||
|
|
e818d40c2a | ||
|
|
e52a01abbe | ||
|
|
b81f57f1c9 | ||
|
|
8221ff520c | ||
|
|
b68f1e278e | ||
|
|
18b996e5bd | ||
|
|
50cc857a3a | ||
|
|
ea04588865 | ||
|
|
47d1202e57 | ||
|
|
1ab5b8ed9c | ||
|
|
61f944fdaa | ||
|
|
5d2ee3140e | ||
|
|
ba461c7e98 | ||
|
|
389ddefc1d | ||
|
|
2a2421896d | ||
|
|
b3c0d021fd | ||
|
|
f21ddc0f7f | ||
|
|
2e4dec741a | ||
|
|
2fc1253836 | ||
|
|
479308637d | ||
|
|
eb513e87d2 | ||
|
|
96ead6d1c6 | ||
|
|
a9db99c569 | ||
|
|
42084e1302 | ||
|
|
3e75af7c14 | ||
|
|
c7ad60522d | ||
|
|
7d8834027d | ||
|
|
7a64719708 | ||
|
|
228c36d164 | ||
|
|
085a542b4b | ||
|
|
db6546a959 | ||
|
|
d47f443a25 | ||
|
|
4c261ff49e | ||
|
|
02d11108de | ||
|
|
3534325d7c | ||
|
|
ce48a29499 | ||
|
|
4a34a610fe | ||
|
|
840e2b6b0b | ||
|
|
f95b058b99 | ||
|
|
cafe8b5953 | ||
|
|
dbce44fe24 | ||
|
|
04289d5233 | ||
|
|
67afe993a7 | ||
|
|
fadfa11ea1 | ||
|
|
decfcad2af | ||
|
|
bb29f633c5 | ||
|
|
5fd2212278 | ||
|
|
6f4a29e6f8 | ||
|
|
517552fed8 | ||
|
|
9427c89456 | ||
|
|
758663c3a1 | ||
|
|
7364d99b6b | ||
|
|
694c38dc62 | ||
|
|
164a751f3e | ||
|
|
4f8042a96b | ||
|
|
1fcc8c764f | ||
|
|
eeb3580d42 | ||
|
|
3165c2904b | ||
|
|
3b7bbdcc7d | ||
|
|
80024875ca | ||
|
|
4ff679af11 | ||
|
|
e3a52f8c00 | ||
|
|
4ac7dcf5b0 | ||
|
|
6808b50e94 | ||
|
|
5d229373e6 | ||
|
|
d710e96f85 | ||
|
|
bd5be629e8 | ||
|
|
a5b25fadd5 | ||
|
|
06e2f3e5f8 | ||
|
|
c5923eef6a | ||
|
|
6b344b8566 | ||
|
|
953cea1318 | ||
|
|
c870ac47c2 | ||
|
|
2dfd1925f3 | ||
|
|
36fc5c85f8 | ||
|
|
b285c3e74c | ||
|
|
1bb553d0c1 | ||
|
|
95c122f50d | ||
|
|
2242b4d117 | ||
|
|
955199c238 | ||
|
|
72dde7eb2f | ||
|
|
dcccbcfab2 | ||
|
|
97f3161256 | ||
|
|
e0df528e0f | ||
|
|
de0d2487ab | ||
|
|
71f306ebe3 | ||
|
|
cd99c661fa | ||
|
|
bc132769e3 | ||
|
|
6bd8f79399 | ||
|
|
fce55c836c | ||
|
|
58a1118bfc | ||
|
|
d23fd9d2c1 | ||
|
|
b9fd23912d | ||
|
|
122195156a | ||
|
|
15b3809a50 | ||
|
|
e0031ddc42 | ||
|
|
526e065e7d | ||
|
|
5ac0eda8a6 | ||
|
|
19336609d3 | ||
|
|
1fee42bee9 | ||
|
|
5acc3cd03f | ||
|
|
c84521edf8 | ||
|
|
648dbf7e25 | ||
|
|
20f3ab8e2c | ||
|
|
d7a1c89b7d | ||
|
|
52897e5888 | ||
|
|
07652429a3 | ||
|
|
fff402f2b1 | ||
|
|
0091de918b | ||
|
|
d18d2a5921 | ||
|
|
44a7c8589c | ||
|
|
b6fd50c9cd | ||
|
|
b2ee415fba | ||
|
|
f863a263b7 | ||
|
|
2cbfa16e53 | ||
|
|
0d5bed389f | ||
|
|
e78191714a | ||
|
|
375f169020 | ||
|
|
ee81249c79 | ||
|
|
b7a17b05e9 | ||
|
|
b7a7cd953e | ||
|
|
3d4ee9ee53 | ||
|
|
63a6ef021a | ||
|
|
cfb987e7e3 | ||
|
|
9aa629d36e | ||
|
|
29b0de2210 | ||
|
|
49b30eb290 | ||
|
|
de9d8e65bb | ||
|
|
cdc102de70 | ||
|
|
fd1067b41f | ||
|
|
06031d1c79 | ||
|
|
ecd0a36721 | ||
|
|
e400d49ac9 | ||
|
|
c9da10c9cb | ||
|
|
6600b52cf2 | ||
|
|
cfb19d4ad7 | ||
|
|
4c37ad1f9f | ||
|
|
1b99b50262 | ||
|
|
544796917e | ||
|
|
03b89ea78f | ||
|
|
44dddd28ef | ||
|
|
d74cf435ed | ||
|
|
056eb22c7a | ||
|
|
15a65cfe93 | ||
|
|
eeb00ce467 | ||
|
|
10ac19db72 | ||
|
|
48eff16ac7 | ||
|
|
bb7fe8cd7d | ||
|
|
5d73bffd28 | ||
|
|
bb46b9c652 | ||
|
|
dafae3dfd3 | ||
|
|
1db2d6f5d0 | ||
|
|
0ed1bbf53c | ||
|
|
63f2c2a3aa | ||
|
|
0808a10b03 | ||
|
|
ba0e505d78 | ||
|
|
43a33a8303 | ||
|
|
10fc730230 | ||
|
|
18b01ca0c5 | ||
|
|
48ad154079 | ||
|
|
24668267e8 | ||
|
|
d6cf23ab78 | ||
|
|
e5009af67e | ||
|
|
75e2edb471 | ||
|
|
ff8b580d17 | ||
|
|
0c68765e2d | ||
|
|
3a7adaa247 | ||
|
|
247d8a75f7 | ||
|
|
b60daca055 | ||
|
|
fc3b175100 | ||
|
|
8d54b587d0 | ||
|
|
a4c811dc43 | ||
|
|
4004d53da4 | ||
|
|
8465332598 | ||
|
|
9a2b7cbefc | ||
|
|
09c599cc62 | ||
|
|
17aa9350c5 | ||
|
|
f2481989c7 | ||
|
|
adbddf3299 | ||
|
|
94e4fa42bf | ||
|
|
0ae37db4ec | ||
|
|
8237ec8a2a | ||
|
|
9396982fa7 | ||
|
|
aff72de4e1 | ||
|
|
755fb1f4b6 | ||
|
|
070f4276de | ||
|
|
d9626faaec | ||
|
|
8cdacf3899 | ||
|
|
d8140b87d7 | ||
|
|
1cdc111e31 | ||
|
|
567d912bf7 | ||
|
|
2c482dab31 | ||
|
|
11c6af9d82 | ||
|
|
d4e5dcea70 | ||
|
|
438129689c | ||
|
|
8a5109c0fd | ||
|
|
9cc0faee2f | ||
|
|
25935e0323 | ||
|
|
8f4840b564 | ||
|
|
6e9276b55d | ||
|
|
122f4c835a | ||
|
|
49025734aa | ||
|
|
06a3fa8338 | ||
|
|
02b6f0ac10 | ||
|
|
e1e4dd0524 | ||
|
|
b85b958127 | ||
|
|
b5190d1eff | ||
|
|
03edc362a9 | ||
|
|
783fb7ff1a | ||
|
|
c13d1a5d63 | ||
|
|
1997f9ab9e | ||
|
|
f55a8eb82f | ||
|
|
598fff8429 | ||
|
|
69834ef930 | ||
|
|
316ab93660 | ||
|
|
55c056c52c | ||
|
|
ea07cba3fb | ||
|
|
49b80a4f71 | ||
|
|
fe0bd6a0c0 | ||
|
|
889b15a967 | ||
|
|
cdf960ff66 | ||
|
|
f0b80c72a5 | ||
|
|
b359543cdb | ||
|
|
e6d8c715e4 | ||
|
|
10337967ea | ||
|
|
24ad42f0d0 | ||
|
|
d0d2b0b6cc | ||
|
|
4ed057677e | ||
|
|
e28817829c | ||
|
|
841882510e | ||
|
|
5ebf6899b3 | ||
|
|
3ec52fa83d | ||
|
|
46e44131d3 | ||
|
|
3c28277f15 | ||
|
|
2c7334b1c1 | ||
|
|
f055b9ee17 | ||
|
|
307008e9bc | ||
|
|
f08fc31e64 | ||
|
|
85e578f5ae | ||
|
|
7b31e75298 | ||
|
|
ccda6ba9ba | ||
|
|
042163eb58 | ||
|
|
3518b4d2de | ||
|
|
07afc8a130 | ||
|
|
9c7e13fc64 | ||
|
|
45b184b628 | ||
|
|
c589080ef2 | ||
|
|
cc0f76d75b | ||
|
|
bc3be0f1ff | ||
|
|
b3c23c474a | ||
|
|
0e7bee7a79 | ||
|
|
fb8af21c93 | ||
|
|
754c38ced4 | ||
|
|
ae353dc771 | ||
|
|
9417d11d37 | ||
|
|
9ff1915e49 | ||
|
|
7b5415ad0d | ||
|
|
943247187c | ||
|
|
f4def1966b | ||
|
|
f5dc639211 | ||
|
|
58929684d2 | ||
|
|
042c0509d6 | ||
|
|
be4104c5cf | ||
|
|
dc1a16054b | ||
|
|
9f3577b8b9 | ||
|
|
cae8e00083 | ||
|
|
4c03aad795 | ||
|
|
e2eb73e546 | ||
|
|
f44ae2848f | ||
|
|
0bb852a51c | ||
|
|
3b3cb6bdec | ||
|
|
34850a89fa | ||
|
|
469d398988 | ||
|
|
b127e90e93 | ||
|
|
0d49108cb1 | ||
|
|
629a98bbb5 | ||
|
|
7c9d379aba | ||
|
|
a4a8b5c93b | ||
|
|
0cea2b2e3c | ||
|
|
d70f112014 | ||
|
|
a1d21a07a1 | ||
|
|
baed5ce686 | ||
|
|
db73bf9295 | ||
|
|
a336b44ddb | ||
|
|
f8b2fa0cc8 | ||
|
|
63a192ae8e | ||
|
|
16c26c09fb | ||
|
|
d22beae5a2 | ||
|
|
76fc3f896e | ||
|
|
dfe71f0725 | ||
|
|
103d7a94d2 | ||
|
|
fe0b5abee1 | ||
|
|
4f03e5ee70 | ||
|
|
c07f7475ae | ||
|
|
2028c064f1 | ||
|
|
f97cf7c38e | ||
|
|
3c692c59fe | ||
|
|
f7874bd745 | ||
|
|
1345083f58 | ||
|
|
2106d025a5 | ||
|
|
46a767249c | ||
|
|
8f50593aa8 | ||
|
|
8da1812502 | ||
|
|
831dbfbe4e | ||
|
|
a8f98b7880 | ||
|
|
f2b59e06b2 | ||
|
|
a158f63b4d | ||
|
|
82cfefc3d9 | ||
|
|
995d3a4493 | ||
|
|
2fae115531 | ||
|
|
9bf81ef702 | ||
|
|
5ed2d4a1af | ||
|
|
a9792880e8 | ||
|
|
ba5e11cd69 | ||
|
|
6ab51cd207 | ||
|
|
efc1ed4151 | ||
|
|
d2e1670ffc | ||
|
|
b67797879f | ||
|
|
1d63993604 | ||
|
|
a45cc1d6c9 | ||
|
|
1bbf9960da | ||
|
|
c879ded4b4 | ||
|
|
74edabe6ec | ||
|
|
02c4373d08 | ||
|
|
fae1cdae93 | ||
|
|
ca2fa83e80 | ||
|
|
19e55a517c | ||
|
|
8bffc01e76 | ||
|
|
a2728325f9 | ||
|
|
318f5ad737 | ||
|
|
5c64c3d49f | ||
|
|
d7cc7cdf5e | ||
|
|
55e251e74c | ||
|
|
d97f9c79ee | ||
|
|
b0d60cc9da | ||
|
|
b29869e0cd | ||
|
|
56406d6ca5 | ||
|
|
706f936831 | ||
|
|
5d9363a61d | ||
|
|
474b28366b | ||
|
|
f7d4376147 | ||
|
|
0a8111a34d | ||
|
|
a384051942 | ||
|
|
693add8df9 | ||
|
|
2ec05fea85 | ||
|
|
a6a23615b3 | ||
|
|
42178355cb | ||
|
|
4860ae6980 | ||
|
|
6655b28810 | ||
|
|
cb89cde5f4 | ||
|
|
5632e15006 | ||
|
|
38cc0b14ce | ||
|
|
20b68c76fd | ||
|
|
b2eec3cba7 | ||
|
|
7053632a72 | ||
|
|
b85cf92ce7 | ||
|
|
07081edafa | ||
|
|
35183f894c | ||
|
|
373f457b2c | ||
|
|
98cc352856 | ||
|
|
fe2be594be | ||
|
|
88ffcd8c1c | ||
|
|
d74030917a | ||
|
|
5c5397bf50 | ||
|
|
fb829423e7 | ||
|
|
19d2203517 | ||
|
|
f722115cde | ||
|
|
94d1958cae | ||
|
|
1ab1336d6f | ||
|
|
0ddea70420 | ||
|
|
f4d8570b9c | ||
|
|
fa73baea9e | ||
|
|
c83f4e7d88 | ||
|
|
78e4d1349c | ||
|
|
338197ba3f | ||
|
|
c3fdbd694f | ||
|
|
edf6fd8a20 | ||
|
|
20d8b00ccf | ||
|
|
f6f991a2cb | ||
|
|
dd2f11988f | ||
|
|
52b6a2ecf9 | ||
|
|
14a335fc49 | ||
|
|
3d96824174 | ||
|
|
20c524d78c | ||
|
|
5cec72b77c | ||
|
|
9bae2577a2 | ||
|
|
a8560c8fe1 | ||
|
|
01c21d8bb5 | ||
|
|
5c7fa7e85a | ||
|
|
4a3df80ecd | ||
|
|
6714e2bc7b | ||
|
|
8c07d610ec | ||
|
|
ae917885e9 | ||
|
|
52a7947b14 | ||
|
|
9ecba6691b | ||
|
|
4b33b6f75c | ||
|
|
fb21ee098d | ||
|
|
f9f2371487 | ||
|
|
d6fb0d7187 | ||
|
|
9f0b7df490 | ||
|
|
2483385c69 | ||
|
|
569166d836 | ||
|
|
1c9dea9f99 | ||
|
|
c8e66e82b2 | ||
|
|
9454d35d4e | ||
|
|
99b2946dbb | ||
|
|
a1eca43bb2 | ||
|
|
ebef2f0647 | ||
|
|
55ead98e0e | ||
|
|
87ab0f55d8 | ||
|
|
868636f313 | ||
|
|
0345d482b2 | ||
|
|
32bb03f0eb | ||
|
|
75a43f51e0 | ||
|
|
9b8a407763 | ||
|
|
db005ab949 | ||
|
|
68d9e8b472 | ||
|
|
4455bd4f35 | ||
|
|
3e59ff25a4 | ||
|
|
344a5c068d | ||
|
|
81b56daedf | ||
|
|
d328557927 | ||
|
|
c2e3723ce3 | ||
|
|
475d018e07 | ||
|
|
124397624f | ||
|
|
b589949bf4 | ||
|
|
eaa2314d9c | ||
|
|
ddf0b5de70 | ||
|
|
a435be1af2 | ||
|
|
238a918182 | ||
|
|
9ad85cd826 | ||
|
|
ea3ffbcd0b | ||
|
|
ba67031ca0 | ||
|
|
34acb8ad51 | ||
|
|
8159e7ed8c | ||
|
|
a16d1c2e08 | ||
|
|
589647ca20 | ||
|
|
aad3d5efa5 | ||
|
|
9ef16fa008 | ||
|
|
f2a62947f8 | ||
|
|
82eafb859b | ||
|
|
d7233583ed | ||
|
|
f1ac2fe022 | ||
|
|
18ca125d8f | ||
|
|
2dedb7400d | ||
|
|
e6ea48c8c9 | ||
|
|
fa27248aa3 | ||
|
|
5ff53df075 | ||
|
|
27f7085a3a | ||
|
|
7bd21f499e | ||
|
|
5e1d8ee639 | ||
|
|
dce273f714 | ||
|
|
82813f57e1 | ||
|
|
f76cb3bcba | ||
|
|
9321bfa207 | ||
|
|
ea9ac052ee | ||
|
|
585e08b210 | ||
|
|
9697ab0e62 | ||
|
|
d20014c87c | ||
|
|
04d7c2b511 | ||
|
|
055c01c467 | ||
|
|
dcc4b303f9 | ||
|
|
677686b83a | ||
|
|
7fbba23e97 | ||
|
|
5e2290d7c0 | ||
|
|
c630501011 | ||
|
|
ad54ef4793 | ||
|
|
8a222ce032 | ||
|
|
b529b94e57 | ||
|
|
cf1b2fbc2e | ||
|
|
84e7b6b3a9 | ||
|
|
049c576864 | ||
|
|
1fea63a953 | ||
|
|
809947cdd7 | ||
|
|
85f872013b | ||
|
|
0719b2a9ab | ||
|
|
9961146cd0 | ||
|
|
6ecd147aad | ||
|
|
dc24c1faad | ||
|
|
03ce9602ea | ||
|
|
35772ab786 | ||
|
|
a8fc6df210 | ||
|
|
350904ac3b | ||
|
|
618212ea84 | ||
|
|
97a7fad692 | ||
|
|
fb489f65fe | ||
|
|
f8ff42192b | ||
|
|
24615358a0 | ||
|
|
21c3148afb | ||
|
|
eb469de2a3 | ||
|
|
bfe3759423 | ||
|
|
0dad966d26 | ||
|
|
e43bbe79bd | ||
|
|
cec026495f | ||
|
|
0225f481de | ||
|
|
67f00e70a3 | ||
|
|
8146bbca65 | ||
|
|
eeff184daa | ||
|
|
e8f27a7f1a | ||
|
|
bbe9d9a390 | ||
|
|
f8ad2f2f6a | ||
|
|
2bd9bdbf27 | ||
|
|
bfda4c78b3 | ||
|
|
ce41eba996 | ||
|
|
243056a797 | ||
|
|
a7d73217f7 | ||
|
|
e8d5d6a190 | ||
|
|
32f73fb816 | ||
|
|
e0dc84c14a | ||
|
|
65414f2b55 | ||
|
|
2cdc977064 | ||
|
|
715373c086 | ||
|
|
2550366c92 | ||
|
|
ae8e677e7e | ||
|
|
1d80fd5802 | ||
|
|
150e993130 | ||
|
|
dde89eda8c | ||
|
|
bcf9a7e0db | ||
|
|
8f590b73fa | ||
|
|
ebb52d9486 | ||
|
|
97de742043 | ||
|
|
3deedffb77 | ||
|
|
1534ac4828 | ||
|
|
721b38ed7b | ||
|
|
4c984985fa | ||
|
|
1e1f2c5c1f | ||
|
|
4fcf4a8593 | ||
|
|
81dbbb0755 | ||
|
|
6dc96d71ee | ||
|
|
5dc22f6dd7 | ||
|
|
1e097361e1 | ||
|
|
334fb00864 | ||
|
|
d042db7964 | ||
|
|
4cffa15a4b | ||
|
|
f5129d2ab0 | ||
|
|
c5f686683f | ||
|
|
6faf936e6c | ||
|
|
cbec030bc7 | ||
|
|
b3feaf91d4 | ||
|
|
587fc99023 | ||
|
|
e1396673d9 | ||
|
|
c2ba3da429 | ||
|
|
6b75a8e143 | ||
|
|
e29994a131 | ||
|
|
eab6e54862 | ||
|
|
6148a47f61 | ||
|
|
302235138d | ||
|
|
9040110608 | ||
|
|
41c78d5411 | ||
|
|
7a3795acc9 | ||
|
|
7444743ec5 | ||
|
|
3d03b32487 | ||
|
|
b83a19c1fe | ||
|
|
ca1ab4478b | ||
|
|
fd96555a79 | ||
|
|
e5184d23c9 | ||
|
|
aa70017547 | ||
|
|
ec6bfb6280 | ||
|
|
c617b2aae1 | ||
|
|
db11fa7a9b | ||
|
|
de56508914 | ||
|
|
d9dd955d69 | ||
|
|
1a45f2cfc1 | ||
|
|
ce3cee68ec | ||
|
|
b00fcb2476 | ||
|
|
28c2e2d0d3 | ||
|
|
77e8641c32 | ||
|
|
e84a96d343 | ||
|
|
be2ea53bcc | ||
|
|
6b22342bb5 | ||
|
|
a6299e7b9b | ||
|
|
93e7dc8709 | ||
|
|
c490721d6a | ||
|
|
5d937a9d24 | ||
|
|
e33251e351 | ||
|
|
d93c3552c9 | ||
|
|
e106e5f8ec | ||
|
|
5027504d73 | ||
|
|
8fadc40656 | ||
|
|
5ee6ccdf48 | ||
|
|
fe3b5073bc | ||
|
|
833a5af74f | ||
|
|
6555881a79 | ||
|
|
1f3f2d04eb | ||
|
|
de4a86ca50 | ||
|
|
ed80d02ee0 | ||
|
|
1789b38dec | ||
|
|
3081189517 | ||
|
|
2f66dbfe8a | ||
|
|
ca98412dec | ||
|
|
0658f454b3 | ||
|
|
1f0fd28baa | ||
|
|
f6371ac1f6 | ||
|
|
d7c62c3022 | ||
|
|
99a7ac1e13 | ||
|
|
8422ff4e31 | ||
|
|
7bea6d54c9 | ||
|
|
372f698357 | ||
|
|
a10a504558 | ||
|
|
f5b7a05e28 | ||
|
|
b0e9011372 | ||
|
|
6be37b9dc3 | ||
|
|
430c239171 | ||
|
|
99fb649ba7 | ||
|
|
50057ec289 | ||
|
|
e870eceaca | ||
|
|
e0a1691621 | ||
|
|
8891630f69 | ||
|
|
c5913542f0 | ||
|
|
44cdadabca | ||
|
|
2b8875d19d | ||
|
|
2aa64bb2cd | ||
|
|
164ad16328 | ||
|
|
f0c78b02df | ||
|
|
be8608eb47 | ||
|
|
ecb7bfc786 | ||
|
|
c07d9cc8cb | ||
|
|
6c2431912e | ||
|
|
7fc282a2d5 | ||
|
|
7782bcddac | ||
|
|
b67239ef3e | ||
|
|
7f6a14131d | ||
|
|
21fc6938ca | ||
|
|
ed22876b1d | ||
|
|
00fb558db8 | ||
|
|
ccd5971445 | ||
|
|
03facd1765 | ||
|
|
d3ee18fe71 | ||
|
|
592798b40f | ||
|
|
de305f9831 | ||
|
|
75ee0d0ae2 | ||
|
|
05956f8160 | ||
|
|
e9c55f47c6 | ||
|
|
1330726470 | ||
|
|
3033868814 | ||
|
|
9b2bd07074 | ||
|
|
39ff90474c | ||
|
|
cfd5abc1a7 | ||
|
|
03d7d494fa | ||
|
|
52b13da2b3 | ||
|
|
e3b7269f3b | ||
|
|
4e183439b5 | ||
|
|
c4fa174fad | ||
|
|
cc59f62420 | ||
|
|
00b052bddf | ||
|
|
81c22fcbc2 | ||
|
|
0139618f37 | ||
|
|
8ed4f47f82 | ||
|
|
22dd8e1c3a | ||
|
|
a6a0207718 | ||
|
|
b00d0dc083 | ||
|
|
54d0442fe0 | ||
|
|
cf7c774b09 | ||
|
|
eef059736f | ||
|
|
17001129d1 | ||
|
|
434ea9b9ef | ||
|
|
61dd1b9a34 | ||
|
|
2cf0a44d5f | ||
|
|
0853c1c419 | ||
|
|
20734d5162 | ||
|
|
c88440243f | ||
|
|
5a2971fe6f | ||
|
|
bdd28b5cd4 | ||
|
|
bb9117bdb6 | ||
|
|
921c66abf3 | ||
|
|
da525b1856 | ||
|
|
cc237560c6 | ||
|
|
74f39fb080 | ||
|
|
86e4541225 | ||
|
|
9002502163 | ||
|
|
49747c58f1 | ||
|
|
bf48bd6ac2 | ||
|
|
b445471d76 | ||
|
|
d88f402a34 | ||
|
|
6ee5f9201f | ||
|
|
d051785d20 | ||
|
|
719f0d9442 | ||
|
|
2065c6119b | ||
|
|
6c1ee933f7 | ||
|
|
343f6727c6 | ||
|
|
346eb576f7 | ||
|
|
35ea453b06 | ||
|
|
c717c6932c | ||
|
|
0be1117bd0 | ||
|
|
186732fb05 | ||
|
|
54e901f881 | ||
|
|
c3330b85b8 | ||
|
|
843fe39cdc | ||
|
|
8eee7d590d | ||
|
|
7839d2512f | ||
|
|
195dbf518f | ||
|
|
cc1d6a300f | ||
|
|
4c8c9f8432 | ||
|
|
03ab4a29a1 | ||
|
|
6218ed2bac | ||
|
|
3bac806f61 | ||
|
|
ffaa1675e5 | ||
|
|
bed2acc7f1 | ||
|
|
f2a8d91b5d | ||
|
|
999b98e1f0 | ||
|
|
3eeaf8f300 | ||
|
|
5a5a583ac6 | ||
|
|
08eca9d1c2 | ||
|
|
5f0f6745a8 | ||
|
|
2d2c5bcb00 | ||
|
|
824035898b | ||
|
|
2afb2fad56 | ||
|
|
34edc88413 | ||
|
|
5c8d1c2755 | ||
|
|
0b276db586 | ||
|
|
c1f59da49d | ||
|
|
aa5b727cd2 | ||
|
|
6afcc59c05 | ||
|
|
dbaff30da3 | ||
|
|
ce42192334 | ||
|
|
aad7218df6 | ||
|
|
23a9322e5e | ||
|
|
a84014402b | ||
|
|
865431c58a | ||
|
|
6496f271d2 | ||
|
|
32b9971cfa | ||
|
|
c8cf0df6e1 | ||
|
|
c987a0a9af | ||
|
|
7b315f99bd | ||
|
|
0cdeb09ab0 | ||
|
|
a92f1c5c40 | ||
|
|
b179ce2437 | ||
|
|
be0b55ffe7 | ||
|
|
0ada90777a | ||
|
|
3006ee4764 | ||
|
|
2b31a22f09 | ||
|
|
02f852cb89 | ||
|
|
1e3d9f16df | ||
|
|
561ae52422 | ||
|
|
b81a1eb2d7 | ||
|
|
12d786f810 | ||
|
|
c7313e169c | ||
|
|
a3eede4d4e | ||
|
|
13ae1bcdb9 | ||
|
|
7820b82f6a | ||
|
|
f0e57cfa93 | ||
|
|
283d125901 | ||
|
|
f127079c62 | ||
|
|
81fdcba4c9 | ||
|
|
fcacd91f69 | ||
|
|
fe6fa0bb5a | ||
|
|
ea71dbe18b | ||
|
|
e86076c2e6 | ||
|
|
f6e0b94078 | ||
|
|
bbce8a072b | ||
|
|
755327d721 | ||
|
|
48207f17aa | ||
|
|
a0c5f7b65f | ||
|
|
ae462cb4bf | ||
|
|
8e7c040f51 | ||
|
|
d30febc151 | ||
|
|
b7147ba64c | ||
|
|
0f698e1306 | ||
|
|
8844967d5d | ||
|
|
1e1f53a8fc | ||
|
|
1338a12ac6 | ||
|
|
77847d848c | ||
|
|
599f6d8c89 | ||
|
|
c35979a69f | ||
|
|
589e2e77b1 | ||
|
|
efddb39ff5 | ||
|
|
1b4e1e5b51 | ||
|
|
7b81eaea0c | ||
|
|
110a61a92f | ||
|
|
1cfc143618 | ||
|
|
993eaae2f7 | ||
|
|
58cae8f526 | ||
|
|
9086c5b61d | ||
|
|
136a9fe6f6 | ||
|
|
034b8b8a7c | ||
|
|
d358518ab5 | ||
|
|
729ea4c26c | ||
|
|
76548ad6a9 | ||
|
|
356d5e9d39 | ||
|
|
e493b724b4 | ||
|
|
7cd383ab85 | ||
|
|
63cecd884f | ||
|
|
934b2022af | ||
|
|
80827e9ef2 | ||
|
|
50faf8dd64 | ||
|
|
8c3903c086 | ||
|
|
c19800b3ed | ||
|
|
1ca5830e5b | ||
|
|
04553c014f | ||
|
|
25d659de0a | ||
|
|
eac6d4c074 | ||
|
|
ce84b1ee2c | ||
|
|
0f7fcad8ff | ||
|
|
77521d91e5 | ||
|
|
9f444293eb | ||
|
|
96fd4d95cc | ||
|
|
5aae8e9134 | ||
|
|
7e01297be8 | ||
|
|
545118b4d3 | ||
|
|
e75f065191 | ||
|
|
61e877b5c6 | ||
|
|
3e31640a25 | ||
|
|
a87bfe21c8 | ||
|
|
d286d843dc | ||
|
|
033f6dd057 | ||
|
|
0b3380bf78 | ||
|
|
0d957da176 | ||
|
|
6934efd98c | ||
|
|
0123d22812 | ||
|
|
2842a7963d | ||
|
|
eaaa3827c1 | ||
|
|
544b0f8330 | ||
|
|
f3e8517c99 | ||
|
|
bebccdc5b6 | ||
|
|
d221598aec | ||
|
|
2e3bdcc2da | ||
|
|
432ff09eb1 | ||
|
|
8f9f208d14 | ||
|
|
926c0d3845 | ||
|
|
48dcd4a225 | ||
|
|
d5f60ff63a | ||
|
|
e4f10c8beb | ||
|
|
dd75a3a814 | ||
|
|
124c1ae74d | ||
|
|
8575059426 | ||
|
|
58123608de | ||
|
|
42babcb9a4 | ||
|
|
0eb76f8139 | ||
|
|
da01c7533b | ||
|
|
9a8e1c871c | ||
|
|
1e8601aa3b | ||
|
|
bbe6bd0f23 | ||
|
|
a5cd556d3a | ||
|
|
52659c19c0 | ||
|
|
de1e0cc096 | ||
|
|
a6fca14118 | ||
|
|
7f7af0787a | ||
|
|
1fe2dda4df | ||
|
|
35ff37ed92 | ||
|
|
9e50aa8bd3 | ||
|
|
453832ecf5 | ||
|
|
d41c6dccc5 | ||
|
|
cb096d8710 | ||
|
|
7d30fda97e | ||
|
|
381f21ba92 | ||
|
|
d1d678b20c | ||
|
|
863538b67e | ||
|
|
8eff621b0c | ||
|
|
d64b49cf8e | ||
|
|
299e7ef05b | ||
|
|
8914d1ae63 | ||
|
|
e166135d0c | ||
|
|
018f4daca4 | ||
|
|
c0f4aa89db | ||
|
|
6c81b1b6a5 | ||
|
|
a57391df10 | ||
|
|
99ec2a1128 | ||
|
|
2367f1b334 | ||
|
|
9d6bd729d0 | ||
|
|
8cfb739f1b | ||
|
|
2d483ded13 | ||
|
|
3516036bbc | ||
|
|
84f422fdd0 | ||
|
|
c423e50aa6 | ||
|
|
8c3cb94ab5 | ||
|
|
771d790765 | ||
|
|
8879aa562d | ||
|
|
ea034a30e5 | ||
|
|
9c89bc603e | ||
|
|
18306fcd64 | ||
|
|
6d367aaf02 | ||
|
|
16b3919c39 | ||
|
|
7656fadfcc | ||
|
|
8604392c72 | ||
|
|
038e6b2eff | ||
|
|
e08b57efc3 | ||
|
|
04ff5b9fbf | ||
|
|
a027f2e44d | ||
|
|
8afb44cdc0 | ||
|
|
a1848e7594 | ||
|
|
1739b884f4 | ||
|
|
120823739a | ||
|
|
9e41883ee0 | ||
|
|
e8105bf52d | ||
|
|
03fa6fd365 | ||
|
|
f34a75ad5e | ||
|
|
f829a99566 | ||
|
|
4e1866ce29 | ||
|
|
f79bcbb36d | ||
|
|
1f01c5acde | ||
|
|
142b138e50 | ||
|
|
d4a05bf8e0 | ||
|
|
6790a4d6ab | ||
|
|
34f911399a | ||
|
|
da9e16789b | ||
|
|
58956eb748 | ||
|
|
459d28ed20 | ||
|
|
8c22ceadf1 | ||
|
|
adde75386d | ||
|
|
30e4c7b9c8 | ||
|
|
2946088cd0 | ||
|
|
04487d08d4 | ||
|
|
488a830b7c | ||
|
|
3bb1a6ef6f | ||
|
|
bcc651ffa4 | ||
|
|
891b2f793a | ||
|
|
3f15c06a26 | ||
|
|
82655b7571 | ||
|
|
e91dcd8704 | ||
|
|
b5412313b6 | ||
|
|
a75e838912 | ||
|
|
1b6015afbf | ||
|
|
a24c9111f8 | ||
|
|
1785fd83ce | ||
|
|
b07516fb25 | ||
|
|
dd33b844e1 | ||
|
|
be399eb9b0 | ||
|
|
fdd31c4a2a | ||
|
|
77e8837719 | ||
|
|
311cfc60e4 | ||
|
|
dc4821f14a | ||
|
|
40fcbcd680 | ||
|
|
aab146ad23 | ||
|
|
dea86650b0 | ||
|
|
ad57c0146f | ||
|
|
7e3bb73558 | ||
|
|
f135386b90 | ||
|
|
fd63a8ec06 | ||
|
|
c28c4df8c0 | ||
|
|
5c1e320d97 | ||
|
|
990c34e1d9 | ||
|
|
ee87aefb4c | ||
|
|
68281a3b14 | ||
|
|
4140395286 | ||
|
|
aa59b24bb5 | ||
|
|
b7ae2b33ee | ||
|
|
65279460be | ||
|
|
fc59eb10b7 | ||
|
|
ed04c19501 | ||
|
|
a792a3f50f | ||
|
|
24211659d6 | ||
|
|
d2f4068bcc | ||
|
|
5e0ff04f4f | ||
|
|
c563e86eea | ||
|
|
7922f98c49 | ||
|
|
9391cf9d26 | ||
|
|
9d24e0d5ca | ||
|
|
631a6cadd5 | ||
|
|
d546eb2568 | ||
|
|
9c3d9bd876 | ||
|
|
bf131335a2 | ||
|
|
08093b0b6d | ||
|
|
45be286b36 | ||
|
|
65185fb3fd | ||
|
|
ad6bf214a7 | ||
|
|
3d65b3b506 | ||
|
|
aa1bf10428 | ||
|
|
82f26b85bc | ||
|
|
703c121e15 | ||
|
|
fbe1511364 | ||
|
|
e1584cd504 | ||
|
|
e08f3e3bdc | ||
|
|
c9a6c6b274 | ||
|
|
754c8fa0cd | ||
|
|
9c2ef6ad2c | ||
|
|
8d643ae77b | ||
|
|
13b5deb922 | ||
|
|
67e950310c | ||
|
|
4d31b4748d | ||
|
|
bd0a2bae32 | ||
|
|
ce6630585f | ||
|
|
3d21c254e5 | ||
|
|
4a4f259501 | ||
|
|
6451e0ac31 | ||
|
|
b18a58cdd9 | ||
|
|
a650c0e700 | ||
|
|
cdd33201e1 | ||
|
|
4373093301 | ||
|
|
44bff65ab2 | ||
|
|
074b81a1ed | ||
|
|
67e6709f4a | ||
|
|
c200942d2b | ||
|
|
ea2c862b22 | ||
|
|
e5d6dcea4f | ||
|
|
cbb5ec427c | ||
|
|
93bc01c909 | ||
|
|
4d87a40165 | ||
|
|
de358f09fa | ||
|
|
c7bb3f54eb | ||
|
|
dfa5b95284 | ||
|
|
970ef4e660 | ||
|
|
70c12ba99c | ||
|
|
59adc3aace | ||
|
|
f98a736222 | ||
|
|
c6611749ca | ||
|
|
e32d12cb98 | ||
|
|
53ba2e101e | ||
|
|
20aca8c8a5 | ||
|
|
15cf122b29 | ||
|
|
1a640c2f10 | ||
|
|
44179897b8 | ||
|
|
b42b7fd831 | ||
|
|
18fc848051 | ||
|
|
c4ae29eff3 | ||
|
|
cca553062e | ||
|
|
2bd256b53e | ||
|
|
4f26c366b7 | ||
|
|
6579e016e0 | ||
|
|
7bb1f1d685 | ||
|
|
4e20f1faf0 | ||
|
|
b89df62b35 | ||
|
|
df2d4da51d | ||
|
|
d1e7af866d | ||
|
|
c3a705493c | ||
|
|
f869a6cdb9 | ||
|
|
5289492ec6 | ||
|
|
2d3b7cbd73 | ||
|
|
080c73e005 | ||
|
|
781a2eed89 | ||
|
|
f7c3c12ed5 | ||
|
|
d879c790e7 | ||
|
|
f5fc5d802f | ||
|
|
df9f337c1d | ||
|
|
9bcebc3cb8 | ||
|
|
0830bc0657 | ||
|
|
503368569f | ||
|
|
8b6c46bec9 | ||
|
|
1474c41842 | ||
|
|
4069ea4937 | ||
|
|
90d9e8391b | ||
|
|
94408de61b | ||
|
|
f5eb086f96 | ||
|
|
355868359a | ||
|
|
9c6c30571a | ||
|
|
8cc4787995 | ||
|
|
2dfb7ec8ce | ||
|
|
81a00afa8e | ||
|
|
6a4a240a6a | ||
|
|
d0e5c8b115 | ||
|
|
fff3f8203e | ||
|
|
24e2a083e2 | ||
|
|
1e8fd21e0b | ||
|
|
23638c6833 | ||
|
|
e56b4e9b9d | ||
|
|
aa1d3e89b8 | ||
|
|
feca8625ef | ||
|
|
28891e2064 | ||
|
|
c31b71dfef | ||
|
|
8711293b28 | ||
|
|
d0bf7562e1 | ||
|
|
7f5cb6a191 | ||
|
|
d8bb994629 | ||
|
|
c20b195ae4 | ||
|
|
3744c58efe | ||
|
|
829123ec26 | ||
|
|
05c46cc9bf | ||
|
|
10a6f833f9 | ||
|
|
3f4a13814b | ||
|
|
6f5326b38d | ||
|
|
a3e46f53f2 | ||
|
|
d32343e027 | ||
|
|
af1702a973 | ||
|
|
aaf2ee4149 | ||
|
|
f79a2eaa4d | ||
|
|
0d1e15729c | ||
|
|
76483a660f | ||
|
|
53c297cc97 | ||
|
|
87865cbed2 | ||
|
|
6a03778013 | ||
|
|
0b9ec50738 | ||
|
|
7e9c6a86f3 | ||
|
|
7f6b13d304 | ||
|
|
3b491b5a48 | ||
|
|
64619caebc | ||
|
|
5fe299c8c3 | ||
|
|
915e17a81f | ||
|
|
d4ba2863b6 | ||
|
|
e573713b54 | ||
|
|
a85c3bb7d7 | ||
|
|
1bbbc2734e | ||
|
|
4a8f570383 | ||
|
|
a7d269d7d1 | ||
|
|
94634c40da | ||
|
|
3835c6ae5d | ||
|
|
fc8baafd1e | ||
|
|
c6582cd041 | ||
|
|
13953b5404 | ||
|
|
6fcc986e1a | ||
|
|
4b082fa0a0 | ||
|
|
6c996e9413 | ||
|
|
a008e66320 | ||
|
|
edaf4f58ef | ||
|
|
2f6d994ee6 | ||
|
|
b3b41965ab | ||
|
|
64678a12c5 | ||
|
|
992d9b43fa | ||
|
|
179f0da0e6 | ||
|
|
b31138e681 | ||
|
|
eff500c328 | ||
|
|
3a3978ca3b | ||
|
|
188d97e009 | ||
|
|
92d15ed76e | ||
|
|
2011267f00 | ||
|
|
c1fa062b0d | ||
|
|
6dcddedcb4 | ||
|
|
94a505234b | ||
|
|
adb447e81a | ||
|
|
7af1d7e8f2 | ||
|
|
cb0d85cba3 | ||
|
|
ddada6916d | ||
|
|
109f22ef85 | ||
|
|
71836c5a79 | ||
|
|
9e63f37c41 | ||
|
|
6fe4ed9354 | ||
|
|
5c8d01373e | ||
|
|
5e8e9da629 | ||
|
|
1e191994f0 | ||
|
|
a6267a2acb | ||
|
|
bc474ae583 | ||
|
|
06a386fcc4 | ||
|
|
a2f7ccd4fc | ||
|
|
ae910fe8b5 | ||
|
|
8c9fb5eae6 | ||
|
|
a4664a4fcf | ||
|
|
342e70083c | ||
|
|
1c7c2536ca | ||
|
|
16f3c8c9d3 | ||
|
|
fa4c775f07 | ||
|
|
336a85ed56 | ||
|
|
1de7d70eac | ||
|
|
6a62ed6a53 | ||
|
|
4637dd2e3f | ||
|
|
ac9c2e271f | ||
|
|
f78fe0aa0f | ||
|
|
4c0d269dce | ||
|
|
bcdaf4f786 | ||
|
|
42b6ad712f | ||
|
|
3e9cbf6f69 | ||
|
|
5888f8363c | ||
|
|
97e95026e3 | ||
|
|
5545c4c158 | ||
|
|
e7c409c161 | ||
|
|
3ceb8d0294 | ||
|
|
0c7447890e | ||
|
|
3faf1a6ee9 | ||
|
|
05264d4ba9 | ||
|
|
ff9b2c8bda | ||
|
|
8c508ef9a9 | ||
|
|
f2d6eb3a94 | ||
|
|
6dd4db00e9 | ||
|
|
2aa9652b33 | ||
|
|
d11d6fa492 | ||
|
|
6db9ae464c | ||
|
|
ff795bd719 | ||
|
|
44b1ba4210 | ||
|
|
0235d44c43 | ||
|
|
cb1adfcb3f | ||
|
|
7ce38901f9 | ||
|
|
1022309f80 | ||
|
|
3e50763be9 | ||
|
|
bf4b47d341 | ||
|
|
5c13660022 | ||
|
|
fdf7319261 | ||
|
|
8aa5ca0119 | ||
|
|
537d9dd087 | ||
|
|
4e980b51ab | ||
|
|
c927faa6ad | ||
|
|
ba4a729ba9 | ||
|
|
babab885b0 | ||
|
|
bf75db56c5 | ||
|
|
b28f855bd4 | ||
|
|
d61e59cf6f | ||
|
|
052448b2f7 | ||
|
|
c05a2dbab2 | ||
|
|
4f5ebc1605 | ||
|
|
2163daf71d | ||
|
|
c16621568b | ||
|
|
ad6f0f5baf | ||
|
|
1ee1bff566 | ||
|
|
eacd3e9ddf | ||
|
|
d9ce97f0cf | ||
|
|
f064706f05 | ||
|
|
58d781bd1e | ||
|
|
08f3e0173d | ||
|
|
d47901250a | ||
|
|
0cd9a41535 | ||
|
|
d153b5e91b | ||
|
|
5b24b90d58 | ||
|
|
8773a3c621 | ||
|
|
3bf0e375b6 | ||
|
|
70b7c0d76c | ||
|
|
d0cf6cdf8b | ||
|
|
b22a5ccac4 | ||
|
|
acc16d9f32 | ||
|
|
b5cfd60d44 | ||
|
|
af77034c32 | ||
|
|
48e4cb9a0c | ||
|
|
9126c01a40 | ||
|
|
86313968b4 | ||
|
|
5789c93ad8 | ||
|
|
ad2bc3f2e6 | ||
|
|
20eb5b84e7 | ||
|
|
4cd234d634 | ||
|
|
7c934fc77d | ||
|
|
3ec12b0f9b | ||
|
|
7622b100f3 | ||
|
|
e8c7d7d6fd | ||
|
|
49c9636086 | ||
|
|
8b46d27377 | ||
|
|
3fab7b2956 | ||
|
|
f616531964 | ||
|
|
d684d5cb06 | ||
|
|
b1c48572e5 | ||
|
|
2da093baff | ||
|
|
dcbc5ef3f5 | ||
|
|
4b049eefda | ||
|
|
1254f0e91a | ||
|
|
bc2e05668e | ||
|
|
b4e4d21820 | ||
|
|
6a5364ab17 | ||
|
|
7a9446fc20 | ||
|
|
018f76aafa | ||
|
|
c886e4c803 | ||
|
|
2a6fbe6053 | ||
|
|
fd728760ed | ||
|
|
cc26065be7 | ||
|
|
e160355a8e | ||
|
|
2d936037f5 | ||
|
|
4cacbffb4b | ||
|
|
53b3394248 | ||
|
|
918adbe09c | ||
|
|
d74806d036 | ||
|
|
f601b2cba0 | ||
|
|
58678a84d0 | ||
|
|
45931fe890 | ||
|
|
dd64b76571 | ||
|
|
6838baeb8c | ||
|
|
3565350474 | ||
|
|
6f084c9dae | ||
|
|
b0259ffda0 | ||
|
|
0b0a3be658 | ||
|
|
b315c817b4 | ||
|
|
285b9506df | ||
|
|
85a8819d9c | ||
|
|
329039dabd | ||
|
|
67ad4a97e1 | ||
|
|
f21013eb3b | ||
|
|
8f2e477f2a | ||
|
|
ba18e47e18 | ||
|
|
b0bb08a0fa | ||
|
|
22dcafb66f | ||
|
|
05428a5f12 | ||
|
|
d97133000f | ||
|
|
f1eee53ae2 | ||
|
|
855481256c | ||
|
|
a0cceb046d | ||
|
|
15600b7268 | ||
|
|
f61ef5618a | ||
|
|
facb6a53a9 | ||
|
|
9e0a05c810 | ||
|
|
a6916ade9b | ||
|
|
bb1149d429 | ||
|
|
9a2c1c1946 | ||
|
|
0a24e1ba83 | ||
|
|
ec4fd3933e | ||
|
|
8da196b614 | ||
|
|
d26fed9bbd | ||
|
|
af405ee7a2 | ||
|
|
377d0a1031 | ||
|
|
75bb735e98 | ||
|
|
4cbac39dfc | ||
|
|
ac7db33b61 | ||
|
|
cbe9fa69d7 | ||
|
|
c09d5130fb | ||
|
|
2fee6799d0 | ||
|
|
768880ae91 | ||
|
|
1841e2f6e1 | ||
|
|
5a90c16f78 | ||
|
|
47c90b7dcb | ||
|
|
17c81871db | ||
|
|
bc6d4fc759 | ||
|
|
8bc7dbe273 | ||
|
|
a5b542902d | ||
|
|
70c65f436d | ||
|
|
510e18eafc | ||
|
|
f357ffe4ad | ||
|
|
3dd42a3fd8 | ||
|
|
fd0e604641 | ||
|
|
214c9d30cd | ||
|
|
f93e8cc1b9 | ||
|
|
15e4ba3d84 | ||
|
|
a14faf04aa | ||
|
|
09e1b7910c | ||
|
|
162bdff3ee | ||
|
|
8173b31df9 | ||
|
|
9aa68235e6 | ||
|
|
319fe3c643 | ||
|
|
23317b24ad | ||
|
|
971ef41fcf | ||
|
|
4f07acd0a0 | ||
|
|
9ffb69ebfa | ||
|
|
168707d9e4 | ||
|
|
0cc925b557 | ||
|
|
816b4724c0 | ||
|
|
f9a2e36239 | ||
|
|
41d210f7b7 | ||
|
|
d4fc9dfe44 | ||
|
|
538ea89e9a | ||
|
|
636c639b0d | ||
|
|
085ec7f1c0 | ||
|
|
d74b3dd3bc | ||
|
|
079801d99f | ||
|
|
4da1d3aec9 | ||
|
|
6239955e08 | ||
|
|
9ef40dcb4f | ||
|
|
d19e813e54 | ||
|
|
5906469826 | ||
|
|
13906b0ceb | ||
|
|
83f9a98bf5 | ||
|
|
b2f537a876 | ||
|
|
557d4871d0 | ||
|
|
4e08f6ed1b | ||
|
|
53a825fb55 | ||
|
|
f0c82a1016 | ||
|
|
2bbc6152ff | ||
|
|
c6418c4bc1 | ||
|
|
d2d3b658d3 | ||
|
|
110a8e28a8 | ||
|
|
0544fc1f09 | ||
|
|
a8e2cbab44 | ||
|
|
807d3644f5 | ||
|
|
c7678dd3e4 | ||
|
|
421ffde65f | ||
|
|
40d64aaa5e | ||
|
|
6f4bef66ab | ||
|
|
bf8a1cd4da | ||
|
|
570af27698 | ||
|
|
d50e63a787 | ||
|
|
13f38a9823 | ||
|
|
ebf95791ed | ||
|
|
d2d42a2d8b | ||
|
|
cb9eab424b | ||
|
|
997f20af63 | ||
|
|
7d9f86f799 | ||
|
|
29475c321f | ||
|
|
80142c92e7 | ||
|
|
7eccf81221 | ||
|
|
df37b031c8 | ||
|
|
85ac17628c | ||
|
|
76c47ca9aa | ||
|
|
83e5990905 | ||
|
|
1045ea6cc8 | ||
|
|
f937560e1d | ||
|
|
fa15cfb30f | ||
|
|
51293bfce2 | ||
|
|
4029acd906 | ||
|
|
ea26b2e672 | ||
|
|
5bbf9c221b | ||
|
|
5142b0f602 | ||
|
|
ee05d748c6 | ||
|
|
1b20dcf034 | ||
|
|
2dfe3b9d82 | ||
|
|
0fe712e736 | ||
|
|
92ee419caa | ||
|
|
e692e217b0 | ||
|
|
0bb481c93e | ||
|
|
0c8da84ecb | ||
|
|
4796aa1797 | ||
|
|
e2be5beca7 | ||
|
|
6a076fe6c0 | ||
|
|
5501b8a322 | ||
|
|
f3b1471fc4 | ||
|
|
c659849ced | ||
|
|
8f26c44837 | ||
|
|
a0fae45547 | ||
|
|
7490f500ad | ||
|
|
abb88ae2a8 | ||
|
|
236aff297e | ||
|
|
b686e1fe91 | ||
|
|
105b2fea0d | ||
|
|
9abc657f11 | ||
|
|
ce5e141de2 | ||
|
|
862ac11d94 | ||
|
|
6c4794f02c | ||
|
|
02c53e0e2e | ||
|
|
a37de4fb9d | ||
|
|
395634ef6b | ||
|
|
45c1bc7fd1 | ||
|
|
d490b3e161 | ||
|
|
4b4632eca7 | ||
|
|
33f58759f1 | ||
|
|
7d18c59588 | ||
|
|
16e767d2c6 | ||
|
|
d1d66bb61f | ||
|
|
a3639b9c16 | ||
|
|
155a1010a9 | ||
|
|
90f5ceddfa | ||
|
|
f113e26e60 | ||
|
|
ff59dbfb5f | ||
|
|
8035f2535f | ||
|
|
ccc47a2bd6 | ||
|
|
1143b7183c | ||
|
|
e0551e17fc | ||
|
|
695adcacf7 | ||
|
|
2e6f19a09b | ||
|
|
0265798123 | ||
|
|
8102fe097c | ||
|
|
5584ad0e2b | ||
|
|
78c9577b6b | ||
|
|
f3a2e5f243 | ||
|
|
b3e1e9004f | ||
|
|
8dd4e126e2 | ||
|
|
5cbe931bb6 | ||
|
|
ba09afe371 | ||
|
|
6ed8d61380 | ||
|
|
d4a3d110c8 | ||
|
|
b62d432d68 | ||
|
|
032b8d4aa3 | ||
|
|
28d22103e9 | ||
|
|
1d7c67ebdb | ||
|
|
116b1d48a7 | ||
|
|
23bc765756 | ||
|
|
3e591646d5 | ||
|
|
86629d3fed | ||
|
|
68a6eaea61 | ||
|
|
a4b39d7be0 | ||
|
|
e87752d43c | ||
|
|
df78541430 | ||
|
|
8fc4927eb7 | ||
|
|
6211568951 | ||
|
|
bc8d9b71c1 | ||
|
|
2efd6cdb0b | ||
|
|
5cd20df176 | ||
|
|
56e1017065 | ||
|
|
44d766e13e | ||
|
|
ee7c7c80f9 | ||
|
|
a2f7bd67ec | ||
|
|
b5c834ca61 | ||
|
|
51826ecd56 | ||
|
|
f38b509890 | ||
|
|
cb68bb4b2a | ||
|
|
da4bf33a53 | ||
|
|
7516b60d12 | ||
|
|
44bedc8e8d | ||
|
|
ca2ba3e0f5 | ||
|
|
d209e4427a | ||
|
|
a52350f3dc | ||
|
|
d129725e13 | ||
|
|
82bae69c96 | ||
|
|
3e12fbace9 | ||
|
|
2caf0f65b5 | ||
|
|
9e42695a52 | ||
|
|
7c6404d2f1 | ||
|
|
f38052f510 | ||
|
|
6ebc2f441a | ||
|
|
b10d5cdffe | ||
|
|
d89e622ec9 | ||
|
|
8eb990a113 | ||
|
|
36292ce4ef | ||
|
|
79de258598 | ||
|
|
5313dc1895 | ||
|
|
5fda007adc | ||
|
|
8e301c9a6e | ||
|
|
5d71555049 | ||
|
|
5fd80035e0 | ||
|
|
20c72d7ce4 | ||
|
|
c9fb2c5032 | ||
|
|
ccbb687e6a | ||
|
|
91cc575416 | ||
|
|
e9990cdb68 | ||
|
|
b9b2378efd | ||
|
|
3f87a6e409 | ||
|
|
7e7f3de2b5 | ||
|
|
7e8b58d6f5 | ||
|
|
ff616cfcc0 | ||
|
|
6a7611a2ed | ||
|
|
c96c6b960c | ||
|
|
365c5fdab8 | ||
|
|
85ef990854 | ||
|
|
c9a8c81390 | ||
|
|
f891d7d2aa | ||
|
|
7a50dfdbbd | ||
|
|
247b0d21f7 | ||
|
|
ff63bb5b2e | ||
|
|
e87fa1e20c | ||
|
|
86ecea053b | ||
|
|
d6ec22fe55 | ||
|
|
bf2c93f9f7 | ||
|
|
13d1351a81 | ||
|
|
fe547d7128 | ||
|
|
820fd24fd0 | ||
|
|
646be6a957 | ||
|
|
8d28f9bc8f | ||
|
|
ac8a0f50b4 | ||
|
|
9ee0d200ac | ||
|
|
4ec2964ddf | ||
|
|
3a5dbe941b | ||
|
|
9fcf22fb21 | ||
|
|
3d4c86d4ee | ||
|
|
26b2353782 | ||
|
|
b5e5afa01c | ||
|
|
d7383d7428 | ||
|
|
e8c6240e0e | ||
|
|
a06bb63971 | ||
|
|
f3ec29faf2 | ||
|
|
9138d4317c | ||
|
|
7508883527 | ||
|
|
58df4e669f | ||
|
|
7d5533432b | ||
|
|
1f74138a9f | ||
|
|
53671c02b6 | ||
|
|
acf0ca297a | ||
|
|
f2464d992e | ||
|
|
a83aad93ff | ||
|
|
acce232738 | ||
|
|
244629c88e | ||
|
|
f2c4af921d | ||
|
|
cc8bb8be7a | ||
|
|
56818fb208 | ||
|
|
3ea0529483 | ||
|
|
9d5d1eb9b5 | ||
|
|
332eab7cd8 | ||
|
|
4bd1d88e1d | ||
|
|
bac4618978 | ||
|
|
07e6d62df8 | ||
|
|
e36fd2fcb5 | ||
|
|
0aaeaaab04 | ||
|
|
d395493e21 | ||
|
|
e6449b4d6a | ||
|
|
dbc98184aa | ||
|
|
a9404b13ef | ||
|
|
eb18ea8e6a | ||
|
|
25b02b2a54 | ||
|
|
4d2503e8b3 | ||
|
|
0628f04bdb | ||
|
|
7f26931685 | ||
|
|
a4c780d75c | ||
|
|
ae04bdf176 | ||
|
|
74d7f579ef | ||
|
|
22c813e216 | ||
|
|
1f5b414077 | ||
|
|
4c5ee3de85 | ||
|
|
0559aa5edd | ||
|
|
d499d46d76 | ||
|
|
7dbc75d1d1 | ||
|
|
7850e56b25 | ||
|
|
3dbd673503 | ||
|
|
3b739327a9 | ||
|
|
554c22f5a1 | ||
|
|
0a589b94e4 | ||
|
|
0004050774 | ||
|
|
c9f4292a7f | ||
|
|
0b8fea0faf | ||
|
|
5e2acad25e | ||
|
|
d5020ee1f1 | ||
|
|
5f80bbfb0f | ||
|
|
267d63b60e | ||
|
|
1082cbf8dd | ||
|
|
785eeaa5a5 | ||
|
|
ef18f0a4e4 | ||
|
|
439e86dd20 | ||
|
|
5946e07336 | ||
|
|
d2a6345760 | ||
|
|
2fe7c1f514 | ||
|
|
7a1395f954 | ||
|
|
1fe75b6afd | ||
|
|
910a42558e | ||
|
|
2d2640ec12 | ||
|
|
3f5ad3a096 | ||
|
|
ce59484512 | ||
|
|
6282068c8d | ||
|
|
d1a4e63497 | ||
|
|
7b762766f9 | ||
|
|
86453b5a70 | ||
|
|
252f89fe22 | ||
|
|
6c4813990d | ||
|
|
fa7b3cf7b3 | ||
|
|
4a0608c449 | ||
|
|
64a7195bba | ||
|
|
32d5092945 | ||
|
|
c6c2e33359 | ||
|
|
3bbdd22b74 | ||
|
|
35b0cad9a8 | ||
|
|
db13dc4ea8 | ||
|
|
69b0821dac | ||
|
|
b1256e8fa4 | ||
|
|
d76a79d0d6 | ||
|
|
c220b57473 | ||
|
|
8deb6ba624 | ||
|
|
035531403b | ||
|
|
bfacc7266b | ||
|
|
999031d335 | ||
|
|
cb02f7bcf1 | ||
|
|
05c11c6a70 | ||
|
|
e5755c2b1d | ||
|
|
aee04e0b72 | ||
|
|
a8b97276e7 | ||
|
|
bf50d73b1e | ||
|
|
83859643cc | ||
|
|
fcde777a80 | ||
|
|
41f3753d0b | ||
|
|
e073fd3dec | ||
|
|
98dc15ff51 | ||
|
|
ca9c2f64de | ||
|
|
f77c95d5e6 | ||
|
|
bea95264a8 | ||
|
|
5e0385dba9 | ||
|
|
7ffea8b541 | ||
|
|
727c3d64ae | ||
|
|
41c62835d9 | ||
|
|
caace8755e | ||
|
|
7393b8f333 | ||
|
|
59402b0a58 | ||
|
|
d9e80201b7 | ||
|
|
23661a68a1 | ||
|
|
b4dd1ee718 | ||
|
|
8e8f31605c | ||
|
|
643b31c3e0 | ||
|
|
de2ac5132c | ||
|
|
3175608a50 | ||
|
|
2aa5eaee5c | ||
|
|
f512706531 | ||
|
|
b60892be3e | ||
|
|
2dec12ed99 | ||
|
|
e79fcb04ed | ||
|
|
6c2f8cacab | ||
|
|
29ef1b70d5 | ||
|
|
5e14604945 | ||
|
|
222b20e55d | ||
|
|
ec4be8755d | ||
|
|
cdd310d6cc | ||
|
|
d3a73b90e4 | ||
|
|
5488666d20 | ||
|
|
a5ec286c71 | ||
|
|
6f57c83059 | ||
|
|
e1f0f0138f | ||
|
|
d3482f9921 | ||
|
|
c8f4cf8a27 | ||
|
|
fb84cb2064 | ||
|
|
281dd51c22 | ||
|
|
6b5d853f4a | ||
|
|
c0aea7d566 | ||
|
|
1eb5c2c9c1 | ||
|
|
be35124b9a | ||
|
|
58954e6ec7 | ||
|
|
dbd671dbe8 | ||
|
|
9c9f715c61 | ||
|
|
7229b931ab | ||
|
|
a61503ce17 | ||
|
|
231996f6ee | ||
|
|
c467e0158b | ||
|
|
b55130fa97 | ||
|
|
145728a9f9 | ||
|
|
0430df07e4 | ||
|
|
15be3bbc1c | ||
|
|
ed94a0eac1 | ||
|
|
000ec45dff | ||
|
|
d2581c7c14 | ||
|
|
f4c4d97048 | ||
|
|
2e17c812b3 | ||
|
|
c9e4bf9a51 | ||
|
|
8fe9b0b073 | ||
|
|
dc8ce79aae | ||
|
|
3dd08dd803 | ||
|
|
ce272d7d81 | ||
|
|
9ab12e7922 | ||
|
|
c7d8d1fabb | ||
|
|
554ed9fcd5 | ||
|
|
bd5d2c58fc | ||
|
|
4314e30ed9 | ||
|
|
08a712e4e7 | ||
|
|
d685954951 | ||
|
|
9f33822732 | ||
|
|
4003c9c2d7 | ||
|
|
b90382f3c5 | ||
|
|
a9ea939968 | ||
|
|
ae3a0490ee | ||
|
|
eba8c97bec | ||
|
|
c0a7ce71f4 | ||
|
|
764f0a33a2 | ||
|
|
741114b683 | ||
|
|
74eb81ca2d | ||
|
|
5aa1d28ded | ||
|
|
6b7b30b2ec | ||
|
|
73529a4fcc | ||
|
|
514ca15c84 | ||
|
|
0bc9d35f01 | ||
|
|
f92e8868ed | ||
|
|
eda6650c97 | ||
|
|
a061702eae | ||
|
|
5dd7f6d770 | ||
|
|
1a0738d348 | ||
|
|
58d90ea75b | ||
|
|
515bd3112c | ||
|
|
cf6408b09c | ||
|
|
5334dcd769 | ||
|
|
beea0299fa | ||
|
|
24e55d97a4 | ||
|
|
e3148d1bae | ||
|
|
9e9eced691 | ||
|
|
979026616e | ||
|
|
ecc2d87cd0 | ||
|
|
64425e2ab4 | ||
|
|
3789dbd329 | ||
|
|
3079dcd5a6 | ||
|
|
94f062aff6 | ||
|
|
c0a3ec2c56 | ||
|
|
e983df7895 | ||
|
|
d92603eb24 | ||
|
|
e55f139fe4 | ||
|
|
4604ce497c | ||
|
|
808b08e94a | ||
|
|
8b07b09733 | ||
|
|
30d56a9276 | ||
|
|
c34fbe58cc | ||
|
|
a4370d483f | ||
|
|
fca48e848c | ||
|
|
2155fafd16 | ||
|
|
11d5600324 | ||
|
|
6ec750bf57 | ||
|
|
802acec36d | ||
|
|
24ec634ca7 | ||
|
|
7c711f0ae6 | ||
|
|
a3a0fa39f7 | ||
|
|
82141f7701 | ||
|
|
22334f4ed2 | ||
|
|
25b651cbaa | ||
|
|
009fe01e58 | ||
|
|
a9215023e4 | ||
|
|
8f8ab97733 | ||
|
|
1f77e27d8a | ||
|
|
8b954cb380 | ||
|
|
4887eaabb8 | ||
|
|
360d09951a | ||
|
|
d2a9df7288 | ||
|
|
173768bb03 | ||
|
|
b11e617635 | ||
|
|
9e043d9277 | ||
|
|
f00a505858 | ||
|
|
03fc691a68 | ||
|
|
27c54002b6 | ||
|
|
b1596bcc0a |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'xcpretty'
|
||||
gem 'xcpretty-travis-formatter'
|
||||
+17
-3
@@ -93,7 +93,21 @@ xcuserdata
|
||||
*.hmap
|
||||
*.ipa
|
||||
|
||||
# Performance test baselines
|
||||
*.xcbaseline
|
||||
|
||||
##
|
||||
GRDB Tests/Carthage/Carthage
|
||||
GRDB Tests/Carthage/Cartfile.resolved
|
||||
# GRDBCustomSQLite USER configuration files
|
||||
SQLiteCustom/GRDBCustomSQLite-USER.h
|
||||
SQLiteCustom/GRDBCustomSQLite-USER.xcconfig
|
||||
|
||||
# CocoaPods test
|
||||
Podfile.lock
|
||||
Pods
|
||||
|
||||
# SPM
|
||||
.build
|
||||
Package.pins
|
||||
Tests/SPM/Packages
|
||||
|
||||
# Ruby
|
||||
.ruby-version
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
[submodule "Tests/Performance/fmdb"]
|
||||
path = Tests/Performance/fmdb
|
||||
url = https://github.com/ccgus/fmdb.git
|
||||
[submodule "Tests/Performance/SQLite.swift"]
|
||||
path = Tests/Performance/SQLite.swift
|
||||
url = https://github.com/stephencelis/SQLite.swift.git
|
||||
[submodule "Tests/Performance/Realm"]
|
||||
path = Tests/Performance/Realm
|
||||
url = https://github.com/realm/realm-cocoa.git
|
||||
[submodule "SQLCipher/src"]
|
||||
path = SQLCipher/src
|
||||
url = https://github.com/groue/sqlcipher.git
|
||||
[submodule "SQLiteCustom/src"]
|
||||
path = SQLiteCustom/src
|
||||
url = https://github.com/swiftlyfalling/SQLiteLib
|
||||
@@ -0,0 +1 @@
|
||||
3.1
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
language: objective-c
|
||||
xcode_project: GRDB.xcodeproj
|
||||
|
||||
# Disable the default Travis-CI submodule logic
|
||||
# The various make commands ensure that the appropriate submodules are retrieved
|
||||
git:
|
||||
submodules: false
|
||||
|
||||
jobs:
|
||||
include:
|
||||
|
||||
###########################################
|
||||
## Test GRDB
|
||||
|
||||
# Test GRDBOSX (Xcode 8.3)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBOSX (Xcode 8.3, macOS 10.12)
|
||||
script: make test_framework_GRDBOSX
|
||||
|
||||
# Test GRDBWatchOS (Xcode 8.3)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBWatchOS (Xcode 8.3, watchOS)
|
||||
script: make test_framework_GRDBWatchOS
|
||||
|
||||
# Test GRDBiOS (Xcode 8.3, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBiOS (Xcode 8.3, iOS <MAX>)
|
||||
script: make test_framework_GRDBiOS_maxTarget
|
||||
|
||||
# Test GRDBiOS (Xcode 8.3, iOS <MINIMUM VERSION>))
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBiOS (Xcode 8.3, iOS <MIN>)
|
||||
script: make test_framework_GRDBiOS_minTarget
|
||||
|
||||
# Test GRDB [SPM] (Xcode 8.3, macOS 10.12)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDB [SPM] (Xcode 8.3, macOS 10.12)
|
||||
script: make test_SPM
|
||||
|
||||
###########################################
|
||||
## Test GRDB (Custom SQLite)
|
||||
|
||||
# Test GRDBCustomSQLiteOSX (Xcode 8.3)
|
||||
- stage: Test GRDB + Custom SQLite
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBCustomSQLiteOSX (Xcode 8.3, macOS 10.12)
|
||||
script: make test_framework_GRDBCustomSQLiteOSX
|
||||
|
||||
# Test GRDBCustomSQLiteiOS (Xcode 8.3, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB + Custom SQLite
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBCustomSQLiteiOS (Xcode 8.3, iOS <MAX>)
|
||||
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget
|
||||
|
||||
# Test GRDBCustomSQLiteiOS (Xcode 8.3, iOS <MINIMUM VERSION>))
|
||||
- stage: Test GRDB + Custom SQLite
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBCustomSQLiteiOS (Xcode 8.3, iOS <MIN>)
|
||||
script: make test_framework_GRDBCustomSQLiteiOS_minTarget
|
||||
|
||||
###########################################
|
||||
## Test GRDB (SQLCipher)
|
||||
|
||||
# Test GRDBCipherOSX (Xcode 8.3)
|
||||
- stage: Test GRDB + SQLCipher
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBCipherOSX (Xcode 8.3, macOS 10.12)
|
||||
script: make test_framework_GRDBCipherOSX
|
||||
|
||||
# Test GRDBCipheriOS (Xcode 8.3, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB + SQLCipher
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBCipheriOS (Xcode 8.3, iOS <MAX>)
|
||||
script: make test_framework_GRDBCipheriOS_maxTarget
|
||||
|
||||
# Test GRDBCipheriOS (Xcode 8.3, iOS <MINIMUM VERSION>))
|
||||
- stage: Test GRDB + SQLCipher
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=GRDBCipheriOS (Xcode 8.3, iOS <MIN>)
|
||||
script: make test_framework_GRDBCipheriOS_minTarget
|
||||
|
||||
###########################################
|
||||
## Test Installation Methods
|
||||
|
||||
# Manual Install
|
||||
- stage: Test Installation
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=Manual Install
|
||||
script: make test_install_manual
|
||||
|
||||
# Manual Install (GRDBCipher)
|
||||
- stage: Test Installation
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=Manual Install (GRDBCipher)
|
||||
script: make test_install_GRDBCipher
|
||||
|
||||
# Cocoapods Lint
|
||||
- stage: Test Installation
|
||||
osx_image: xcode8.3
|
||||
install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
env:
|
||||
- TID=Cocoapods
|
||||
script: make test_CocoaPodsLint
|
||||
|
||||
# SPM Install
|
||||
- stage: Test Installation
|
||||
osx_image: xcode8.3
|
||||
env:
|
||||
- TID=SPM
|
||||
script: make test_install_SPM
|
||||
|
||||
## The following doesn’t work, as `make test_CarthageBuild` does not yet work.
|
||||
## Carthage Build
|
||||
#- stage: Carthage
|
||||
# osx_image: xcode8.3
|
||||
# before_install:
|
||||
# - brew update
|
||||
# - brew outdated carthage || brew upgrade carthage
|
||||
# script: make test_CarthageBuild
|
||||
+3257
File diff suppressed because it is too large.
Load diff
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"screenWidth" : "{130,145}",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"screenWidth" : "{146,165}",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"assets" : [
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"filename" : "Circular.imageset",
|
||||
"role" : "circular"
|
||||
},
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"filename" : "Extra Large.imageset",
|
||||
"role" : "extra-large"
|
||||
},
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"filename" : "Modular.imageset",
|
||||
"role" : "modular"
|
||||
},
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"filename" : "Utilitarian.imageset",
|
||||
"role" : "utilitarian"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"screenWidth" : "{130,145}",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"screenWidth" : "{146,165}",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"screenWidth" : "{130,145}",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"screenWidth" : "{146,165}",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"screenWidth" : "{130,145}",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "watch",
|
||||
"screenWidth" : "{146,165}",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// ExtensionDelegate.swift
|
||||
// GRDBDemoWatchOS Extension
|
||||
//
|
||||
// Created by Gwendal Roué on 03/04/2017.
|
||||
// Copyright © 2017 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import WatchKit
|
||||
|
||||
class ExtensionDelegate: NSObject, WKExtensionDelegate {
|
||||
|
||||
func applicationDidFinishLaunching() {
|
||||
// Perform any final initialization of your application.
|
||||
}
|
||||
|
||||
func applicationDidBecomeActive() {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
func applicationWillResignActive() {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, etc.
|
||||
}
|
||||
|
||||
func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) {
|
||||
// Sent when the system needs to launch the application in the background to process tasks. Tasks arrive in a set, so loop through and process each one.
|
||||
for task in backgroundTasks {
|
||||
// Use a switch statement to check the task type
|
||||
switch task {
|
||||
case let backgroundTask as WKApplicationRefreshBackgroundTask:
|
||||
// Be sure to complete the background task once you’re done.
|
||||
backgroundTask.setTaskCompleted()
|
||||
case let snapshotTask as WKSnapshotRefreshBackgroundTask:
|
||||
// Snapshot tasks have a unique completion call, make sure to set your expiration date
|
||||
snapshotTask.setTaskCompleted(restoredDefaultState: true, estimatedSnapshotExpiration: Date.distantFuture, userInfo: nil)
|
||||
case let connectivityTask as WKWatchConnectivityRefreshBackgroundTask:
|
||||
// Be sure to complete the connectivity task once you’re done.
|
||||
connectivityTask.setTaskCompleted()
|
||||
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
|
||||
// Be sure to complete the URL session task once you’re done.
|
||||
urlSessionTask.setTaskCompleted()
|
||||
default:
|
||||
// make sure to complete unhandled task types
|
||||
task.setTaskCompleted()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+15
-3
@@ -4,6 +4,8 @@
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>GRDBDemoWatchOS Extension</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
@@ -13,12 +15,22 @@
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>WKAppBundleIdentifier</key>
|
||||
<string>com.github.groue.GRDBDemoiOS.watchkitapp</string>
|
||||
</dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.watchkit</string>
|
||||
</dict>
|
||||
<key>WKExtensionDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).ExtensionDelegate</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// InterfaceController.swift
|
||||
// GRDBDemoWatchOS Extension
|
||||
//
|
||||
// Created by Gwendal Roué on 03/04/2017.
|
||||
// Copyright © 2017 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import WatchKit
|
||||
import Foundation
|
||||
import GRDB
|
||||
|
||||
class InterfaceController: WKInterfaceController {
|
||||
|
||||
@IBOutlet var versionLabel: WKInterfaceLabel!
|
||||
|
||||
override func awake(withContext context: Any?) {
|
||||
super.awake(withContext: context)
|
||||
|
||||
let sqliteVersion = String(cString: sqlite3_libversion(), encoding: .utf8)
|
||||
versionLabel.setText(sqliteVersion)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "24x24",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "notificationCenter",
|
||||
"subtype" : "38mm"
|
||||
},
|
||||
{
|
||||
"size" : "27.5x27.5",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "notificationCenter",
|
||||
"subtype" : "42mm"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "watch",
|
||||
"role" : "companionSettings",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "watch",
|
||||
"role" : "companionSettings",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "appLauncher",
|
||||
"subtype" : "38mm"
|
||||
},
|
||||
{
|
||||
"size" : "86x86",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "quickLook",
|
||||
"subtype" : "38mm"
|
||||
},
|
||||
{
|
||||
"size" : "98x98",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "quickLook",
|
||||
"subtype" : "42mm"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
|
||||
<device id="watch38" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="watchOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="12029"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Interface Controller-->
|
||||
<scene sceneID="aou-V4-d1y">
|
||||
<objects>
|
||||
<controller id="AgC-eL-Hgc" customClass="InterfaceController" customModule="GRDBDemoWatchOS" customModuleProvider="target">
|
||||
<items>
|
||||
<group width="1" alignment="left" verticalAlignment="center" layout="vertical" id="tkk-aG-QQF">
|
||||
<items>
|
||||
<label alignment="center" text="SQLite version" id="dGA-xX-x8V"/>
|
||||
<label alignment="center" text="Label" id="whi-N6-h8U"/>
|
||||
</items>
|
||||
</group>
|
||||
</items>
|
||||
<connections>
|
||||
<outlet property="versionLabel" destination="whi-N6-h8U" id="5xN-Gj-yNt"/>
|
||||
</connections>
|
||||
</controller>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
+12
-3
@@ -4,6 +4,8 @@
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>GRDBDemoiOS</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
@@ -13,12 +15,19 @@
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>WKCompanionAppBundleIdentifier</key>
|
||||
<string>com.github.groue.GRDBDemoiOS</string>
|
||||
<key>WKWatchKitApp</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
File diff suppressed because it is too large.
Load diff
+141
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "568E5FBE1E926430002582E0"
|
||||
BuildableName = "GRDBDemoWatchOS.app"
|
||||
BlueprintName = "GRDBDemoWatchOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
|
||||
BuildableName = "GRDBDemoiOS.app"
|
||||
BlueprintName = "GRDBDemoiOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "568E5FCA1E926430002582E0"
|
||||
BuildableName = "GRDBDemoWatchOS Extension.appex"
|
||||
BlueprintName = "GRDBDemoWatchOS Extension"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "568E5FBE1E926430002582E0"
|
||||
BuildableName = "GRDBDemoWatchOS.app"
|
||||
BlueprintName = "GRDBDemoWatchOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<RemoteRunnable
|
||||
runnableDebuggingMode = "2"
|
||||
BundleIdentifier = "com.apple.carousel"
|
||||
RemotePath = "/GRDBDemoiOS">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "568E5FBE1E926430002582E0"
|
||||
BuildableName = "GRDBDemoWatchOS.app"
|
||||
BlueprintName = "GRDBDemoWatchOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</RemoteRunnable>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "568E5FBE1E926430002582E0"
|
||||
BuildableName = "GRDBDemoWatchOS.app"
|
||||
BlueprintName = "GRDBDemoWatchOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<RemoteRunnable
|
||||
runnableDebuggingMode = "2"
|
||||
BundleIdentifier = "com.apple.carousel"
|
||||
RemotePath = "/GRDBDemoiOS">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "568E5FBE1E926430002582E0"
|
||||
BuildableName = "GRDBDemoWatchOS.app"
|
||||
BlueprintName = "GRDBDemoWatchOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</RemoteRunnable>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "568E5FBE1E926430002582E0"
|
||||
BuildableName = "GRDBDemoWatchOS.app"
|
||||
BlueprintName = "GRDBDemoWatchOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0830"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
|
||||
BuildableName = "GRDBDemoiOS.app"
|
||||
BlueprintName = "GRDBDemoiOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
|
||||
BuildableName = "GRDBDemoiOS.app"
|
||||
BlueprintName = "GRDBDemoiOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
|
||||
BuildableName = "GRDBDemoiOS.app"
|
||||
BlueprintName = "GRDBDemoiOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
|
||||
BuildableName = "GRDBDemoiOS.app"
|
||||
BlueprintName = "GRDBDemoiOS"
|
||||
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,56 +1,11 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// iOS
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import GRDB
|
||||
|
||||
var dbQueue: DatabaseQueue!
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
|
||||
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
let splitViewController = self.window!.rootViewController as! UISplitViewController
|
||||
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
|
||||
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
|
||||
splitViewController.delegate = self
|
||||
|
||||
// Database
|
||||
dbQueue = DatabaseQueue()
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute("CREATE TABLE persons (id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT)")
|
||||
}
|
||||
migrator.registerMigration("addPersons") { db in
|
||||
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
|
||||
try Person(firstName: "Barbara", lastName: "Streisand").insert(db)
|
||||
try Person(firstName: "Cinderella").insert(db)
|
||||
}
|
||||
try! migrator.migrate(dbQueue)
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
|
||||
try! setupDatabase(application)
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: - Split view
|
||||
|
||||
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController:UIViewController, ontoPrimaryViewController primaryViewController:UIViewController) -> Bool {
|
||||
guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
|
||||
guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false }
|
||||
if topAsDetailController.person == nil {
|
||||
// Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
@@ -21,15 +31,27 @@
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-60@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-60@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "20x20",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "29x29",
|
||||
@@ -59,6 +81,11 @@
|
||||
"idiom" : "ipad",
|
||||
"size" : "76x76",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "83.5x83.5",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8076" systemVersion="14D121" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8063"/>
|
||||
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
@@ -16,29 +15,8 @@
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright © 2015 Gwendal Roué. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
|
||||
<rect key="frame" x="20" y="559" width="560" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="GRDBDemoiOS" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
|
||||
<rect key="frame" x="20" y="180" width="560" height="43"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<animations/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
|
||||
<constraint firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
|
||||
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
|
||||
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
|
||||
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
|
||||
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
||||
@@ -1,135 +1,310 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="H1p-Uh-vWS">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11129.15" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="UAh-8N-CM8">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11103.10"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Master-->
|
||||
<scene sceneID="pY4-Hu-kfo">
|
||||
<!--Hall Of Fame-->
|
||||
<scene sceneID="8jG-C9-QsI">
|
||||
<objects>
|
||||
<navigationController title="Master" id="RMx-3f-FxP" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="Pmd-2v-anx">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="7bK-jq-Zjz" kind="relationship" relationship="rootViewController" id="tsl-Nk-0bq"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="8fS-aE-onr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-38" y="-630"/>
|
||||
</scene>
|
||||
<!--Detail-->
|
||||
<scene sceneID="yUG-lL-AsK">
|
||||
<objects>
|
||||
<viewController title="Detail" id="JEX-9P-axG" customClass="DetailViewController" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="SYR-Wa-9uf"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="GAO-Cl-Wes"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="svH-Pt-448">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<tableViewController id="cyv-nk-Plb" customClass="SimplePersonsViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="oON-zg-8kO">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Detail view content goes here" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="0XM-y9-sOw">
|
||||
<rect key="frame" x="20" y="292" width="560" height="17"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" size="system"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="0XM-y9-sOw" firstAttribute="leading" secondItem="svH-Pt-448" secondAttribute="leading" constant="20" symbolic="YES" id="Tsc-yG-G1q"/>
|
||||
<constraint firstItem="0XM-y9-sOw" firstAttribute="centerY" secondItem="svH-Pt-448" secondAttribute="centerY" id="jWN-iV-94e"/>
|
||||
<constraint firstAttribute="trailing" secondItem="0XM-y9-sOw" secondAttribute="trailing" constant="20" symbolic="YES" id="tHV-ZD-HQj"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<toolbarItems/>
|
||||
<navigationItem key="navigationItem" title="Detail" id="mOI-FS-AaM"/>
|
||||
<connections>
|
||||
<outlet property="detailDescriptionLabel" destination="0XM-y9-sOw" id="deQ-Na-JPF"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="FJe-Yq-33r" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="709" y="129"/>
|
||||
</scene>
|
||||
<!--Split View Controller-->
|
||||
<scene sceneID="Nki-YV-4Qg">
|
||||
<objects>
|
||||
<splitViewController id="H1p-Uh-vWS" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<connections>
|
||||
<segue destination="RMx-3f-FxP" kind="relationship" relationship="masterViewController" id="BlO-5A-QYV"/>
|
||||
<segue destination="vC3-pB-5Vb" kind="relationship" relationship="detailViewController" id="Tll-UG-LXB"/>
|
||||
</connections>
|
||||
</splitViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="cZU-Oi-B1e" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-856" y="-330"/>
|
||||
</scene>
|
||||
<!--Master-->
|
||||
<scene sceneID="smW-Zh-WAh">
|
||||
<objects>
|
||||
<tableViewController title="Master" clearsSelectionOnViewWillAppear="NO" id="7bK-jq-Zjz" customClass="MasterViewController" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="r7i-6Z-zg0">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="Arm-wq-HPj" style="IBUITableViewCellStyleDefault" id="WCw-Qf-5nD">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Person" textLabel="XIE-DF-pSO" detailTextLabel="vyz-CH-eMb" style="IBUITableViewCellStyleValue1" id="V5t-oJ-KD9">
|
||||
<frame key="frameInset" minY="92" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WCw-Qf-5nD" id="37f-cq-3Eg">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="V5t-oJ-KD9" id="Coo-th-ywF">
|
||||
<frame key="frameInset" width="342" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Arm-wq-HPj">
|
||||
<rect key="frame" x="15" y="0.0" width="290" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="XIE-DF-pSO">
|
||||
<frame key="frameInset" minX="15" minY="12" width="31.5" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="vyz-CH-eMb">
|
||||
<frame key="frameInset" minX="298.5" minY="12" width="41.5" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
<segue destination="vC3-pB-5Vb" kind="showDetail" identifier="showDetail" id="6S0-TO-JiA"/>
|
||||
<segue destination="iNr-Oe-muq" kind="show" identifier="EditPerson" id="czF-1h-sYn"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<sections/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="7bK-jq-Zjz" id="Gho-Na-rnu"/>
|
||||
<outlet property="delegate" destination="7bK-jq-Zjz" id="RA6-mI-bju"/>
|
||||
<outlet property="dataSource" destination="cyv-nk-Plb" id="uBb-Bn-Lhg"/>
|
||||
<outlet property="delegate" destination="cyv-nk-Plb" id="nLb-Ak-ZXS"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Master" id="Zdf-7t-Un8"/>
|
||||
<toolbarItems/>
|
||||
<navigationItem key="navigationItem" title="Hall Of Fame" id="YLU-iz-PGw"/>
|
||||
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
|
||||
<connections>
|
||||
<segue destination="ein-Sr-i8w" kind="presentation" identifier="NewPerson" id="zii-bJ-cOA"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Rux-fX-hf1" sceneMemberID="firstResponder"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="PrM-ex-2C8" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="709" y="-630"/>
|
||||
<point key="canvasLocation" x="630" y="640"/>
|
||||
</scene>
|
||||
<!--Person Edition View Controller-->
|
||||
<scene sceneID="Juk-Ad-tZ2">
|
||||
<objects>
|
||||
<tableViewController id="iNr-Oe-muq" customClass="PersonEditionViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="vlV-lc-eQA">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<sections>
|
||||
<tableViewSection id="Nzq-eO-jT3">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="2gb-gB-918">
|
||||
<rect key="frame" x="0.0" y="64" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2gb-gB-918" id="iyM-TJ-JB4">
|
||||
<frame key="frameInset" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Name" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="m5m-Zs-j0z">
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no" returnKeyType="next"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="iNr-Oe-muq" id="K2p-7d-teD"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="m5m-Zs-j0z" firstAttribute="leading" secondItem="iyM-TJ-JB4" secondAttribute="leadingMargin" constant="10" id="9cK-nj-70V"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="m5m-Zs-j0z" secondAttribute="trailing" id="JsE-8v-XAS"/>
|
||||
<constraint firstItem="m5m-Zs-j0z" firstAttribute="centerY" secondItem="iyM-TJ-JB4" secondAttribute="centerY" id="psG-tW-QrM"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="vp3-Ft-Gth">
|
||||
<rect key="frame" x="0.0" y="108" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vp3-Ft-Gth" id="ccO-0O-u72">
|
||||
<frame key="frameInset" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Score" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="rZ9-Fa-cyr">
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="numberPad" returnKeyType="done"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="rZ9-Fa-cyr" secondAttribute="trailing" id="Gso-FU-Ct1"/>
|
||||
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="centerY" secondItem="ccO-0O-u72" secondAttribute="centerY" id="UqA-ea-emb"/>
|
||||
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="leading" secondItem="ccO-0O-u72" secondAttribute="leadingMargin" constant="10" id="WrY-St-72v"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="iNr-Oe-muq" id="67O-XE-MeV"/>
|
||||
<outlet property="delegate" destination="iNr-Oe-muq" id="vLD-QQ-zR2"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<toolbarItems/>
|
||||
<navigationItem key="navigationItem" id="U4g-xG-W8b">
|
||||
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="VIN-Hi-Twt">
|
||||
<connections>
|
||||
<segue destination="lTz-K0-aRY" kind="unwind" unwindAction="cancelPersonEdition:" id="fOs-ol-qJL"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem key="rightBarButtonItem" systemItem="done" id="2um-u5-BhV">
|
||||
<connections>
|
||||
<segue destination="lTz-K0-aRY" kind="unwind" identifier="" unwindAction="commitPersonEdition:" id="Y1E-dI-wcl"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
|
||||
<connections>
|
||||
<outlet property="cancelBarButtonItem" destination="VIN-Hi-Twt" id="dET-mF-ZXe"/>
|
||||
<outlet property="commitBarButtonItem" destination="2um-u5-BhV" id="Jym-us-zdP"/>
|
||||
<outlet property="nameCell" destination="2gb-gB-918" id="ch2-MB-uRm"/>
|
||||
<outlet property="nameTextField" destination="m5m-Zs-j0z" id="A6a-pw-q8s"/>
|
||||
<outlet property="scoreCell" destination="vp3-Ft-Gth" id="b8A-42-8Dw"/>
|
||||
<outlet property="scoreTextField" destination="rZ9-Fa-cyr" id="4kw-gV-uih"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="fNC-Ls-uRw" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
<exit id="lTz-K0-aRY" userLabel="Exit" sceneMemberID="exit"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1450" y="1435"/>
|
||||
</scene>
|
||||
<!--GRDB Demo-->
|
||||
<scene sceneID="XjB-aQ-v94">
|
||||
<objects>
|
||||
<tableViewController id="9kw-c5-KTk" customClass="DemoViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="f4Y-o2-7VW">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<sections>
|
||||
<tableViewSection id="dCg-qU-h2X">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="clL-nG-zPX" style="IBUITableViewCellStyleDefault" id="kJB-sX-YAb">
|
||||
<rect key="frame" x="0.0" y="64" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="kJB-sX-YAb" id="f5l-ob-3DG">
|
||||
<frame key="frameInset" width="342" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Simple TableView" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="clL-nG-zPX">
|
||||
<frame key="frameInset" minX="15" width="325" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="cyv-nk-Plb" kind="show" id="Bgq-9t-jRc"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="I78-c5-0kp" style="IBUITableViewCellStyleDefault" id="q4C-mT-5mi">
|
||||
<rect key="frame" x="0.0" y="108" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="q4C-mT-5mi" id="2Cu-K1-hiz">
|
||||
<frame key="frameInset" width="342" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="FetchedRecordsController" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="I78-c5-0kp">
|
||||
<frame key="frameInset" minX="15" width="325" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="PJp-Eq-ZjA" kind="show" id="1fk-ZR-6XN"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="9kw-c5-KTk" id="IK7-Os-Odc"/>
|
||||
<outlet property="delegate" destination="9kw-c5-KTk" id="U7E-yB-s8d"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="GRDB Demo" id="z0z-02-Ucy"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="OhY-4B-BcJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-190" y="1435"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="r7l-gg-dq7">
|
||||
<scene sceneID="2KX-IU-Z5Q">
|
||||
<objects>
|
||||
<navigationController id="vC3-pB-5Vb" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="DjV-YW-jjY">
|
||||
<navigationController id="ein-Sr-i8w" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="zIT-dB-Mfo">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="JEX-9P-axG" kind="relationship" relationship="rootViewController" id="GKi-kA-LjT"/>
|
||||
<segue destination="iNr-Oe-muq" kind="relationship" relationship="rootViewController" id="e5b-3U-9Vz"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="SLD-UC-DBI" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="kNr-vk-I5l" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-45" y="129"/>
|
||||
<point key="canvasLocation" x="630" y="1435"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="N1X-4j-Re4">
|
||||
<objects>
|
||||
<navigationController id="UAh-8N-CM8" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="U7d-1C-GnL">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="9kw-c5-KTk" kind="relationship" relationship="rootViewController" id="qDW-qI-Hyg"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="sVt-e9-ghQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-1006" y="1435"/>
|
||||
</scene>
|
||||
<!--Hall Of Fame-->
|
||||
<scene sceneID="9su-ms-vdJ">
|
||||
<objects>
|
||||
<tableViewController id="PJp-Eq-ZjA" customClass="PersonsViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="tX0-ON-WSI">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Person" textLabel="G8y-VE-YRu" detailTextLabel="NNc-J4-xiE" style="IBUITableViewCellStyleValue1" id="bFj-Hd-fwd">
|
||||
<frame key="frameInset" minY="92" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bFj-Hd-fwd" id="kDf-TZ-xhb">
|
||||
<frame key="frameInset" width="342" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="G8y-VE-YRu">
|
||||
<frame key="frameInset" minX="15" minY="12" width="31.5" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="NNc-J4-xiE">
|
||||
<frame key="frameInset" minX="298.5" minY="12" width="41.5" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.5568627451" green="0.5568627451" blue="0.57647058819999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="iNr-Oe-muq" kind="show" identifier="EditPerson" id="Lgu-Yd-HSy"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="PJp-Eq-ZjA" id="MkQ-WQ-sTh"/>
|
||||
<outlet property="delegate" destination="PJp-Eq-ZjA" id="quj-Sp-DuL"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<toolbarItems>
|
||||
<barButtonItem title="Item" id="hMF-Rv-dAe"/>
|
||||
</toolbarItems>
|
||||
<navigationItem key="navigationItem" title="Hall Of Fame" id="QIv-M6-kT1">
|
||||
<barButtonItem key="rightBarButtonItem" systemItem="add" id="2bK-Fl-55Q"/>
|
||||
</navigationItem>
|
||||
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
|
||||
<connections>
|
||||
<segue destination="ein-Sr-i8w" kind="presentation" identifier="NewPerson" id="7PC-xN-zD4"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="af5-Qo-AkD" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="630" y="2254"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="6S0-TO-JiA"/>
|
||||
<segue reference="7PC-xN-zD4"/>
|
||||
<segue reference="czF-1h-sYn"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
||||
@@ -0,0 +1,56 @@
|
||||
import GRDB
|
||||
import UIKit
|
||||
|
||||
// The shared database queue
|
||||
var dbQueue: DatabaseQueue!
|
||||
|
||||
func setupDatabase(_ application: UIApplication) throws {
|
||||
|
||||
// Connect to the database
|
||||
// See https://github.com/groue/GRDB.swift/#database-connections
|
||||
|
||||
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! as NSString
|
||||
let databasePath = documentsPath.appendingPathComponent("db.sqlite")
|
||||
dbQueue = try DatabaseQueue(path: databasePath)
|
||||
|
||||
|
||||
// Be a nice iOS citizen, and don't consume too much memory
|
||||
// See https://github.com/groue/GRDB.swift/#memory-management
|
||||
|
||||
dbQueue.setupMemoryManagement(in: application)
|
||||
|
||||
|
||||
// Use DatabaseMigrator to setup the database
|
||||
// See https://github.com/groue/GRDB.swift/#migrations
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
|
||||
// Create a table
|
||||
// See https://github.com/groue/GRDB.swift#create-tables
|
||||
|
||||
try db.create(table: "persons") { t in
|
||||
// An integer primary key auto-generates unique IDs
|
||||
t.column("id", .integer).primaryKey()
|
||||
|
||||
// Sort person names in a localized case insensitive fashion by default
|
||||
// See https://github.com/groue/GRDB.swift/#unicode
|
||||
t.column("name", .text).notNull().collate(.localizedCaseInsensitiveCompare)
|
||||
|
||||
t.column("score", .integer).notNull()
|
||||
}
|
||||
|
||||
// Populate the persons table with random data
|
||||
for _ in 0..<8 {
|
||||
try Person(name: Person.randomName(), score: Person.randomScore()).insert(db)
|
||||
}
|
||||
}
|
||||
|
||||
// // Migrations for future application versions will be inserted here:
|
||||
// migrator.registerMigration(...) { db in
|
||||
// ...
|
||||
// }
|
||||
|
||||
try migrator.migrate(dbQueue)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import UIKit
|
||||
|
||||
class DemoViewController: UITableViewController {
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(true)
|
||||
navigationController?.isToolbarHidden = true
|
||||
navigationItem.backBarButtonItem = UIBarButtonItem(title: "Demo", style: .plain, target: nil, action: nil)
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// DetailViewController.swift
|
||||
// iOS
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class DetailViewController: UIViewController {
|
||||
|
||||
@IBOutlet weak var detailDescriptionLabel: UILabel!
|
||||
|
||||
var person: Person? {
|
||||
didSet {
|
||||
self.configureView()
|
||||
}
|
||||
}
|
||||
|
||||
func configureView() {
|
||||
if let person = self.person {
|
||||
if let label = self.detailDescriptionLabel {
|
||||
label.text = person.fullName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.configureView()
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -4,6 +4,8 @@
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>GRDB Demo</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
@@ -16,8 +18,6 @@
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
@@ -30,28 +30,9 @@
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UIStatusBarTintParameters</key>
|
||||
<dict>
|
||||
<key>UINavigationBar</key>
|
||||
<dict>
|
||||
<key>Style</key>
|
||||
<string>UIBarStyleDefault</string>
|
||||
<key>Translucent</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// MasterViewController.swift
|
||||
// iOS
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class MasterViewController: UITableViewController {
|
||||
|
||||
var detailViewController: DetailViewController? = nil
|
||||
var persons = [Person]()
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
self.navigationItem.leftBarButtonItem = self.editButtonItem()
|
||||
|
||||
if let split = self.splitViewController {
|
||||
let controllers = split.viewControllers
|
||||
self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
persons = dbQueue.inDatabase { db in
|
||||
db.fetchAll(Person.self, "SELECT * FROM persons ORDER BY firstName, lastName")
|
||||
}
|
||||
self.clearsSelectionOnViewWillAppear = self.splitViewController!.collapsed
|
||||
super.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
// MARK: - Segues
|
||||
|
||||
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
|
||||
if segue.identifier == "showDetail" {
|
||||
if let indexPath = self.tableView.indexPathForSelectedRow {
|
||||
let person = persons[indexPath.row]
|
||||
let controller = (segue.destinationViewController as! UINavigationController).topViewController as! DetailViewController
|
||||
controller.person = person
|
||||
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
|
||||
controller.navigationItem.leftItemsSupplementBackButton = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Table View
|
||||
|
||||
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return persons.count
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
|
||||
|
||||
let person = persons[indexPath.row]
|
||||
cell.textLabel!.text = person.fullName
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
|
||||
let person = persons[indexPath.row]
|
||||
try! dbQueue.inTransaction { db in
|
||||
try person.delete(db)
|
||||
return .Commit
|
||||
}
|
||||
persons.removeAtIndex(indexPath.row)
|
||||
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,51 +1,49 @@
|
||||
//
|
||||
// Person.swift
|
||||
// iOS
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import GRDB
|
||||
|
||||
class Person : RowModel {
|
||||
var id: Int64!
|
||||
var firstName: String?
|
||||
var lastName: String?
|
||||
var fullName: String {
|
||||
return " ".join([firstName, lastName].filter { $0 != nil }.map { $0! })
|
||||
}
|
||||
class Person: Record {
|
||||
var id: Int64?
|
||||
var name: String
|
||||
var score: Int
|
||||
|
||||
init(firstName: String? = nil, lastName: String? = nil) {
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
init(name: String, score: Int) {
|
||||
self.name = name
|
||||
self.score = score
|
||||
super.init()
|
||||
}
|
||||
|
||||
// MARK: - RowModel
|
||||
// MARK: Record overrides
|
||||
|
||||
override class var databaseTable: Table? {
|
||||
return Table(named: "persons", primaryKey: .RowID("id"))
|
||||
override class var databaseTableName: String {
|
||||
return "persons"
|
||||
}
|
||||
|
||||
override func setDatabaseValue(dbv: DatabaseValue, forColumn column: String) {
|
||||
switch column {
|
||||
case "id": id = dbv.value()
|
||||
case "firstName": firstName = dbv.value()
|
||||
case "lastName": lastName = dbv.value()
|
||||
default: super.setDatabaseValue(dbv, forColumn: column)
|
||||
}
|
||||
}
|
||||
|
||||
override var storedDatabaseDictionary: [String: DatabaseValueConvertible?] {
|
||||
return [
|
||||
"id": id,
|
||||
"firstName": firstName,
|
||||
"lastName": lastName]
|
||||
}
|
||||
|
||||
required init(row: Row) {
|
||||
id = row.value(named: "id")
|
||||
name = row.value(named: "name")
|
||||
score = row.value(named: "score")
|
||||
super.init(row: row)
|
||||
}
|
||||
|
||||
override func encode(to container: inout PersistenceContainer) {
|
||||
container["id"] = id
|
||||
container["name"] = name
|
||||
container["score"] = score
|
||||
}
|
||||
|
||||
override func didInsert(with rowID: Int64, for column: String?) {
|
||||
id = rowID
|
||||
}
|
||||
|
||||
// MARK: Random
|
||||
|
||||
private static let names = ["Arthur", "Anita", "Barbara", "Bernard", "Craig", "Chiara", "David", "Dean", "Éric", "Elena", "Fatima", "Frederik", "Gilbert", "Georgette", "Henriette", "Hassan", "Ignacio", "Irene", "Julie", "Jack", "Karl", "Kristel", "Louis", "Liz", "Masashi", "Mary", "Noam", "Nicole", "Ophelie", "Oleg", "Pascal", "Patricia", "Quentin", "Quinn", "Raoul", "Rachel", "Stephan", "Susie", "Tristan", "Tatiana", "Ursule", "Urbain", "Victor", "Violette", "Wilfried", "Wilhelmina", "Yvon", "Yann", "Zazie", "Zoé"]
|
||||
|
||||
class func randomName() -> String {
|
||||
return names[Int(arc4random_uniform(UInt32(names.count)))]
|
||||
}
|
||||
|
||||
class func randomScore() -> Int {
|
||||
return 10 * Int(arc4random_uniform(101))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import UIKit
|
||||
|
||||
protocol PersonEditionViewControllerDelegate: class {
|
||||
func personEditionControllerDidComplete(_ controller: PersonEditionViewController)
|
||||
}
|
||||
|
||||
class PersonEditionViewController: UITableViewController {
|
||||
weak var delegate: PersonEditionViewControllerDelegate?
|
||||
var person: Person! { didSet { configureView() } }
|
||||
var cancelButtonHidden: Bool = false { didSet { configureView() } }
|
||||
var commitButtonHidden: Bool = false { didSet { configureView() } }
|
||||
|
||||
@IBOutlet fileprivate weak var cancelBarButtonItem: UIBarButtonItem!
|
||||
@IBOutlet fileprivate weak var commitBarButtonItem: UIBarButtonItem!
|
||||
@IBOutlet fileprivate weak var nameCell: UITableViewCell!
|
||||
@IBOutlet fileprivate weak var nameTextField: UITextField!
|
||||
@IBOutlet fileprivate weak var scoreCell: UITableViewCell!
|
||||
@IBOutlet fileprivate weak var scoreTextField: UITextField!
|
||||
|
||||
func applyChanges() {
|
||||
if let name = nameTextField.text, !name.isEmpty {
|
||||
person.name = name
|
||||
}
|
||||
person.score = scoreTextField.text.flatMap { Int($0) } ?? 0
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
configureView()
|
||||
}
|
||||
|
||||
private func configureView() {
|
||||
guard isViewLoaded else { return }
|
||||
|
||||
nameTextField.text = person.name
|
||||
if person.score == 0 && person.id == nil {
|
||||
scoreTextField.text = ""
|
||||
} else {
|
||||
scoreTextField.text = "\(person.score)"
|
||||
}
|
||||
|
||||
if cancelButtonHidden {
|
||||
navigationItem.leftBarButtonItem = nil
|
||||
} else {
|
||||
navigationItem.leftBarButtonItem = cancelBarButtonItem
|
||||
}
|
||||
|
||||
if cancelButtonHidden {
|
||||
navigationItem.rightBarButtonItem = nil
|
||||
} else {
|
||||
navigationItem.rightBarButtonItem = commitBarButtonItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Navigation
|
||||
|
||||
extension PersonEditionViewController {
|
||||
|
||||
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
|
||||
// Force keyboard to dismiss early
|
||||
view.endEditing(true)
|
||||
return true
|
||||
}
|
||||
|
||||
override func willMove(toParentViewController parent: UIViewController?) {
|
||||
super.willMove(toParentViewController: parent)
|
||||
|
||||
if parent == nil {
|
||||
// Self is popping from its navigation controller
|
||||
delegate?.personEditionControllerDidComplete(self)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Form
|
||||
|
||||
extension PersonEditionViewController: UITextFieldDelegate {
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
nameTextField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
tableView.deselectRow(at: indexPath, animated: false)
|
||||
let cell = tableView.cellForRow(at: indexPath)
|
||||
if cell === nameCell {
|
||||
nameTextField.becomeFirstResponder()
|
||||
} else if cell === scoreCell {
|
||||
scoreTextField.becomeFirstResponder()
|
||||
}
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
if textField == nameTextField {
|
||||
scoreTextField.becomeFirstResponder()
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
import UIKit
|
||||
import GRDB
|
||||
|
||||
class PersonsViewController: UITableViewController {
|
||||
var personsController: FetchedRecordsController<Person>!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
navigationItem.rightBarButtonItems = [
|
||||
UIBarButtonItem(barButtonSystemItem: .add, target: self, action: .addPerson),
|
||||
editButtonItem
|
||||
]
|
||||
|
||||
personsController = try! FetchedRecordsController(dbQueue, request: personsSortedByScore)
|
||||
personsController.trackChanges(
|
||||
willChange: { [unowned self] _ in
|
||||
self.tableView.beginUpdates()
|
||||
},
|
||||
onChange: { [unowned self] (controller, record, change) in
|
||||
switch change {
|
||||
case .insertion(let indexPath):
|
||||
self.tableView.insertRows(at: [indexPath], with: .fade)
|
||||
|
||||
case .deletion(let indexPath):
|
||||
self.tableView.deleteRows(at: [indexPath], with: .fade)
|
||||
|
||||
case .update(let indexPath, _):
|
||||
if let cell = self.tableView.cellForRow(at: indexPath) {
|
||||
self.configure(cell, at: indexPath)
|
||||
}
|
||||
|
||||
case .move(let indexPath, let newIndexPath, _):
|
||||
// Actually move cells around for more demo effect :-)
|
||||
let cell = self.tableView.cellForRow(at: indexPath)
|
||||
self.tableView.moveRow(at: indexPath, to: newIndexPath)
|
||||
if let cell = cell {
|
||||
self.configure(cell, at: newIndexPath)
|
||||
}
|
||||
|
||||
// A quieter animation:
|
||||
// self.tableView.deleteRows(at: [indexPath], with: .fade)
|
||||
// self.tableView.insertRows(at: [newIndexPath], with: .fade)
|
||||
}
|
||||
},
|
||||
didChange: { [unowned self] _ in
|
||||
self.tableView.endUpdates()
|
||||
})
|
||||
try! personsController.performFetch()
|
||||
|
||||
configureToolbar()
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
navigationController?.isToolbarHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Navigation
|
||||
|
||||
extension PersonsViewController : PersonEditionViewControllerDelegate {
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
if segue.identifier == "EditPerson" {
|
||||
let person = personsController.record(at: tableView.indexPathForSelectedRow!)
|
||||
let controller = segue.destination as! PersonEditionViewController
|
||||
controller.title = person.name
|
||||
controller.person = person
|
||||
controller.delegate = self // we will save person when back button is tapped
|
||||
controller.cancelButtonHidden = true
|
||||
controller.commitButtonHidden = true
|
||||
}
|
||||
else if segue.identifier == "NewPerson" {
|
||||
setEditing(false, animated: true)
|
||||
let navigationController = segue.destination as! UINavigationController
|
||||
let controller = navigationController.viewControllers.first as! PersonEditionViewController
|
||||
controller.title = "New Person"
|
||||
controller.person = Person(name: "", score: 0)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func addPerson(_ sender: AnyObject?) {
|
||||
performSegue(withIdentifier: "NewPerson", sender: sender)
|
||||
}
|
||||
|
||||
@IBAction func cancelPersonEdition(_ segue: UIStoryboardSegue) {
|
||||
// Person creation: cancel button was tapped
|
||||
}
|
||||
|
||||
@IBAction func commitPersonEdition(_ segue: UIStoryboardSegue) {
|
||||
// Person creation: commit button was tapped
|
||||
let controller = segue.source as! PersonEditionViewController
|
||||
controller.applyChanges()
|
||||
let person = controller.person!
|
||||
if !person.name.isEmpty {
|
||||
try! dbQueue.inDatabase { db in
|
||||
try person.save(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func personEditionControllerDidComplete(_ controller: PersonEditionViewController) {
|
||||
// Person edition: back button was tapped
|
||||
controller.applyChanges()
|
||||
let person = controller.person!
|
||||
if !person.name.isEmpty {
|
||||
try! dbQueue.inDatabase { db in
|
||||
try person.save(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
||||
extension PersonsViewController {
|
||||
func configure(_ cell: UITableViewCell, at indexPath: IndexPath) {
|
||||
let person = personsController.record(at: indexPath)
|
||||
cell.textLabel?.text = person.name
|
||||
cell.detailTextLabel?.text = abs(person.score) > 1 ? "\(person.score) points" : "0 point"
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return personsController.sections.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return personsController.sections[section].numberOfRecords
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "Person", for: indexPath)
|
||||
configure(cell, at: indexPath)
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
|
||||
// Delete the person
|
||||
let person = personsController.record(at: indexPath)
|
||||
try! dbQueue.inDatabase { db in
|
||||
_ = try person.delete(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - FetchedRecordsController Demo
|
||||
|
||||
extension PersonsViewController {
|
||||
|
||||
fileprivate func configureToolbar() {
|
||||
toolbarItems = [
|
||||
UIBarButtonItem(title: "Name ⬆︎", style: .plain, target: self, action: .sortByName),
|
||||
UIBarButtonItem(title: "Score ⬇︎", style: .plain, target: self, action: .sortByScore),
|
||||
UIBarButtonItem(title: "Randomize", style: .plain, target: self, action: .randomizeScores),
|
||||
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
|
||||
UIBarButtonItem(title: "💣", style: .plain, target: self, action: .stressTest)
|
||||
]
|
||||
}
|
||||
|
||||
@IBAction func sortByName() {
|
||||
setEditing(false, animated: true)
|
||||
try! personsController.setRequest(personsSortedByName)
|
||||
}
|
||||
|
||||
@IBAction func sortByScore() {
|
||||
setEditing(false, animated: true)
|
||||
try! personsController.setRequest(personsSortedByScore)
|
||||
}
|
||||
|
||||
@IBAction func randomizeScores() {
|
||||
setEditing(false, animated: true)
|
||||
|
||||
try! dbQueue.inTransaction { db in
|
||||
for person in try Person.fetchAll(db) {
|
||||
person.score = Person.randomScore()
|
||||
try person.update(db)
|
||||
}
|
||||
return .commit
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func stressTest() {
|
||||
setEditing(false, animated: true)
|
||||
|
||||
for _ in 0..<50 {
|
||||
DispatchQueue.global().async {
|
||||
try! dbQueue.inTransaction { db in
|
||||
if try Person.fetchCount(db) == 0 {
|
||||
// Insert persons
|
||||
for _ in 0..<8 {
|
||||
try Person(name: Person.randomName(), score: Person.randomScore()).insert(db)
|
||||
}
|
||||
} else {
|
||||
// Insert a person
|
||||
if arc4random_uniform(2) == 0 {
|
||||
let person = Person(name: Person.randomName(), score: Person.randomScore())
|
||||
try person.insert(db)
|
||||
}
|
||||
// Delete a person
|
||||
if arc4random_uniform(2) == 0 {
|
||||
if let person = try Person.order(sql: "RANDOM()").fetchOne(db) {
|
||||
try person.delete(db)
|
||||
}
|
||||
}
|
||||
// Update some persons
|
||||
for person in try Person.fetchAll(db) {
|
||||
if arc4random_uniform(2) == 0 {
|
||||
person.score = Person.randomScore()
|
||||
try person.update(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
return .commit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://medium.com/swift-programming/swift-selector-syntax-sugar-81c8a8b10df3
|
||||
private extension Selector {
|
||||
static let addPerson = #selector(PersonsViewController.addPerson(_:))
|
||||
static let sortByName = #selector(PersonsViewController.sortByName)
|
||||
static let sortByScore = #selector(PersonsViewController.sortByScore)
|
||||
static let randomizeScores = #selector(PersonsViewController.randomizeScores)
|
||||
static let stressTest = #selector(PersonsViewController.stressTest)
|
||||
}
|
||||
|
||||
private let personsSortedByName = Person.order(Column("name"))
|
||||
private let personsSortedByScore = Person.order(Column("score").desc, Column("name"))
|
||||
@@ -0,0 +1,114 @@
|
||||
import UIKit
|
||||
import GRDB
|
||||
|
||||
class SimplePersonsViewController: UITableViewController {
|
||||
var persons: [Person]!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
navigationItem.rightBarButtonItems = [
|
||||
UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(SimplePersonsViewController.addPerson(_:))),
|
||||
editButtonItem
|
||||
]
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
loadPersons()
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
private func loadPersons() {
|
||||
persons = try! dbQueue.inDatabase { db in
|
||||
try Person.order(Column("score").desc, Column("name")).fetchAll(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Navigation
|
||||
|
||||
extension SimplePersonsViewController : PersonEditionViewControllerDelegate {
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
if segue.identifier == "EditPerson" {
|
||||
let person = persons[tableView.indexPathForSelectedRow!.row]
|
||||
let controller = segue.destination as! PersonEditionViewController
|
||||
controller.title = person.name
|
||||
controller.person = person
|
||||
controller.delegate = self // we will save person when back button is tapped
|
||||
controller.cancelButtonHidden = true
|
||||
controller.commitButtonHidden = true
|
||||
}
|
||||
else if segue.identifier == "NewPerson" {
|
||||
setEditing(false, animated: true)
|
||||
let navigationController = segue.destination as! UINavigationController
|
||||
let controller = navigationController.viewControllers.first as! PersonEditionViewController
|
||||
controller.title = "New Person"
|
||||
controller.person = Person(name: "", score: 0)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func addPerson(_ sender: AnyObject?) {
|
||||
performSegue(withIdentifier: "NewPerson", sender: sender)
|
||||
}
|
||||
|
||||
@IBAction func cancelPersonEdition(_ segue: UIStoryboardSegue) {
|
||||
// Person creation: cancel button was tapped
|
||||
}
|
||||
|
||||
@IBAction func commitPersonEdition(_ segue: UIStoryboardSegue) {
|
||||
// Person creation: commit button was tapped
|
||||
let controller = segue.source as! PersonEditionViewController
|
||||
controller.applyChanges()
|
||||
let person = controller.person!
|
||||
if !person.name.isEmpty {
|
||||
try! dbQueue.inDatabase { db in
|
||||
try person.save(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func personEditionControllerDidComplete(_ controller: PersonEditionViewController) {
|
||||
// Person edition: back button was tapped
|
||||
controller.applyChanges()
|
||||
let person = controller.person!
|
||||
if !person.name.isEmpty {
|
||||
try! dbQueue.inDatabase { db in
|
||||
try person.save(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
||||
extension SimplePersonsViewController {
|
||||
func configure(_ cell: UITableViewCell, at indexPath: IndexPath) {
|
||||
let person = persons[indexPath.row]
|
||||
cell.textLabel?.text = person.name
|
||||
cell.detailTextLabel?.text = abs(person.score) > 1 ? "\(person.score) points" : "0 point"
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return persons.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "Person", for: indexPath)
|
||||
configure(cell, at: indexPath)
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
|
||||
// Delete the person
|
||||
let person = persons[indexPath.row]
|
||||
try! dbQueue.inDatabase { db in
|
||||
_ = try person.delete(db)
|
||||
}
|
||||
persons.remove(at: indexPath.row)
|
||||
tableView.deleteRows(at: [indexPath], with: .fade)
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// GRDBDemoiOSTests.swift
|
||||
// GRDBDemoiOSTests
|
||||
//
|
||||
// Created by Gwendal Roué on 09/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class GRDBDemoiOSTests: XCTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testExample() {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
func testPerformanceExample() {
|
||||
// This is an example of a performance test case.
|
||||
self.measureBlock() {
|
||||
// Put the code you want to measure the time of here.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// GRDBDemoiOSUITests.swift
|
||||
// GRDBDemoiOSUITests
|
||||
//
|
||||
// Created by Gwendal Roué on 09/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
class GRDBDemoiOSUITests: XCTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
|
||||
// In UI tests it is usually best to stop immediately when a failure occurs.
|
||||
continueAfterFailure = false
|
||||
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
|
||||
XCUIApplication().launch()
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testExample() {
|
||||
// Use recording to get started writing UI tests.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
Custom SQLite Builds
|
||||
====================
|
||||
|
||||
By default, GRDB uses the version of SQLite that ships with the target operating system.
|
||||
|
||||
**You can build GRDB with a custom build of [SQLite 3.19.2](https://www.sqlite.org/changes.html).**
|
||||
|
||||
A custom SQLite build can activate extra SQLite features, and extra GRDB features as well, such as support for the [FTS5 full-text search engine](../../../#full-text-search), and [SQLite Pre-Update Hooks](../../../#support-for-sqlite-pre-update-hooks).
|
||||
|
||||
GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfalling/SQLiteLib), which uses the same SQLite configuration as the one used by Apple in its operating systems, and lets you add extra compilation options that leverage the features you need.
|
||||
|
||||
**To install GRDB with a custom SQLite build:**
|
||||
|
||||
1. Clone the GRDB.swift git repository, checkout the latest tagged version, and download SQLite sources:
|
||||
|
||||
```sh
|
||||
cd [GRDB.swift directory]
|
||||
git checkout v1.2
|
||||
git submodule update --init SQLiteCustom/src
|
||||
````
|
||||
|
||||
2. Choose your [extra compilation options](https://www.sqlite.org/compile.html). For example, `SQLITE_ENABLE_FTS5` and `SQLITE_ENABLE_PREUPDATE_HOOK`.
|
||||
|
||||
3. Create a folder named `GRDBCustomSQLite` somewhere in your project directory.
|
||||
|
||||
4. Create four files in the `GRDBCustomSQLite` folder:
|
||||
|
||||
- `SQLiteLib-USER.xcconfig`: this file sets the extra SQLite compilation flags.
|
||||
|
||||
```xcconfig
|
||||
// As many -D options as there are custom SQLite compilation options
|
||||
// Note: there is no space between -D and the option name.
|
||||
CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_PREUPDATE_HOOK
|
||||
```
|
||||
|
||||
- `GRDBCustomSQLite-USER.xcconfig`: this file lets GRDB know about extra compilation flags, and enables extra GRDB APIs.
|
||||
|
||||
```xcconfig
|
||||
// As many -D options as there are custom SQLite compilation options
|
||||
// Note: there is one space between -D and the option name.
|
||||
CUSTOM_OTHER_SWIFT_FLAGS = -D SQLITE_ENABLE_FTS5 -D SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
```
|
||||
|
||||
- `GRDBCustomSQLite-USER.h`: this file lets your application know about extra compilation flags.
|
||||
|
||||
```c
|
||||
// As many #define as there are custom SQLite compilation options
|
||||
#define SQLITE_ENABLE_FTS5
|
||||
#define SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
```
|
||||
|
||||
- `GRDBCustomSQLite-INSTALL.sh`: this file installs the three other files.
|
||||
|
||||
```sh
|
||||
# License: MIT License
|
||||
# https://github.com/swiftlyfalling/SQLiteLib/blob/master/LICENSE
|
||||
#
|
||||
#######################################################
|
||||
# PROJECT PATHS
|
||||
# !! MODIFY THESE TO MATCH YOUR PROJECT HIERARCHY !!
|
||||
#######################################################
|
||||
|
||||
# The path to the folder containing GRDB.xcodeproj:
|
||||
GRDB_SOURCE_PATH="${PROJECT_DIR}/GRDB"
|
||||
|
||||
# The path to your custom "SQLiteLib-USER.xcconfig":
|
||||
SQLITELIB_XCCONFIG_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/SQLiteLib-USER.xcconfig"
|
||||
|
||||
# The path to your custom "GRDBCustomSQLite-USER.xcconfig":
|
||||
CUSTOMSQLITE_XCCONFIG_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-USER.xcconfig"
|
||||
|
||||
# The path to your custom "GRDBCustomSQLite-USER.h":
|
||||
CUSTOMSQLITE_H_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-USER.h"
|
||||
|
||||
#######################################################
|
||||
#
|
||||
#######################################################
|
||||
|
||||
|
||||
if [ ! -d "$GRDB_SOURCE_PATH" ];
|
||||
then
|
||||
echo "error: Path to GRDB source (GRDB_SOURCE_PATH) missing/incorrect: $GRDB_SOURCE_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SyncFileChanges () {
|
||||
SOURCE=$1
|
||||
DESTINATIONPATH=$2
|
||||
DESTINATIONFILENAME=$3
|
||||
DESTINATION="${DESTINATIONPATH}/${DESTINATIONFILENAME}"
|
||||
|
||||
if [ ! -f "$SOURCE" ];
|
||||
then
|
||||
echo "error: Source file missing: $SOURCE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rsync -a "$SOURCE" "$DESTINATION"
|
||||
}
|
||||
|
||||
SyncFileChanges $SQLITELIB_XCCONFIG_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom/src" "SQLiteLib-USER.xcconfig"
|
||||
SyncFileChanges $CUSTOMSQLITE_XCCONFIG_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom" "GRDBCustomSQLite-USER.xcconfig"
|
||||
SyncFileChanges $CUSTOMSQLITE_H_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom" "GRDBCustomSQLite-USER.h"
|
||||
|
||||
echo "Finished syncing"
|
||||
```
|
||||
|
||||
Modify the top of `GRDBCustomSQLite-INSTALL.sh` file so that it contains correct paths.
|
||||
|
||||
5. Embed the `GRDB.xcodeproj` project in your own project.
|
||||
|
||||
6. Add the `GRDBCustomSQLiteOSX` or `GRDBCustomSQLiteiOS` target in the **Target Dependencies** section of the **Build Phases** tab of your **application target**.
|
||||
|
||||
7. Add the `GRDBCustomSQLite.framework` from the targetted platform to the **Embedded Binaries** section of the **General** tab of your **application target**.
|
||||
|
||||
8. Add a Run Script phase for your target in the **Pre-actions** section of the **Build** tab of your **application scheme**:
|
||||
|
||||
```sh
|
||||
source "${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-INSTALL.sh"
|
||||
```
|
||||
|
||||
The path should be the path to your `GRDBCustomSQLite-INSTALL.sh` file.
|
||||
|
||||
9. Check the "Shared" checkbox of your application scheme (this lets you commit the pre-action in your Version Control System).
|
||||
|
||||
Now you can use GRDB with your custom SQLite build:
|
||||
|
||||
```swift
|
||||
import GRDBCustomSQLite
|
||||
|
||||
let dbQueue = try DatabaseQueue(...)
|
||||
```
|
||||
@@ -0,0 +1,591 @@
|
||||
GRDB Extension Guide
|
||||
====================
|
||||
|
||||
**Some parts of GRDB are extensible, so that you can make it better fit your needs.**
|
||||
|
||||
This guide is a step-by-step tour of GRDB extensibility, around a few topics:
|
||||
|
||||
- **[Add a value type](#add-a-value-type)**
|
||||
|
||||
You'll learn how to turn UIColor into a value type that you can store, fetch, and use in your records:
|
||||
|
||||
```swift
|
||||
let rows = try Row.fetchCursor(db, "SELECT name, color FROM clothes")
|
||||
while let row = try rows.next() {
|
||||
let name: String = row.value(named: "name")
|
||||
let color: UIColor = row.value(named: "color") // <-- New! UIColor as value
|
||||
}
|
||||
```
|
||||
|
||||
- **[Add an SQLite function or operator](#add-an-sqlite-function-or-operator)**
|
||||
|
||||
You'll learn how to add support for the [STRFTIME](https://www.sqlite.org/lang_datefunc.html) function, and the [GLOB](https://www.sqlite.org/lang_expr.html#like) operator:
|
||||
|
||||
```swift
|
||||
Books.select(strftime("%Y", Column("publishedDate"))) // <-- New! strftime function
|
||||
Books.filter(Column("body").glob("*Moby-Dick*")) // <-- New! glob method
|
||||
```
|
||||
|
||||
- **[Add a new kind of SQLite expression](#add-a-new-kind-of-sqlite-expression)**
|
||||
|
||||
You'll learn how to add support for [CAST expressions](https://www.sqlite.org/lang_expr.html#castexpr):
|
||||
|
||||
```swift
|
||||
let jsonString = Column("jsonString")
|
||||
let request = Books.select(cast(jsonString, as: .blob)) // <-- New! cast function
|
||||
let rows = try Row.fetchCursor(db, request)
|
||||
while let row = try rows.next() {
|
||||
let data = row.dataNoCopy(atIndex: 0)
|
||||
}
|
||||
```
|
||||
|
||||
- **Extend the query interface requests**
|
||||
|
||||
You may need to extend the [query interface requests](../../../#requests) so that their SELECT queries could embed recursive clauses, table joins, etc.
|
||||
|
||||
Pull requests are welcome. Open issues if you have questions.
|
||||
|
||||
Meanwhile, you can build your own [custom requests](../../../#custom-requests).
|
||||
|
||||
- **[Add a custom FTS5 full-text tokenizer](FTS5Tokenizers.md)**
|
||||
|
||||
Custom tokenizers can leverage extra full-text features such as synonyms or stop words.
|
||||
|
||||
- **Support a new kind of SQL query**
|
||||
|
||||
For example, you may need to generate SQL triggers, or create specific kinds of virtual tables.
|
||||
|
||||
Pull requests are welcome. Open issues if you have questions.
|
||||
|
||||
|
||||
## Add a Value Type
|
||||
|
||||
**All value types adopt the [DatabaseValueConvertible protocol](../../../#custom-value-types).**
|
||||
|
||||
```swift
|
||||
protocol DatabaseValueConvertible {
|
||||
/// Returns a value that can be stored in the database.
|
||||
var databaseValue: DatabaseValue { get }
|
||||
|
||||
/// Returns a value initialized from databaseValue, if possible.
|
||||
static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self?
|
||||
}
|
||||
```
|
||||
|
||||
The `databaseValue` property returns [DatabaseValue](../../../#databasevalue), a type that wraps the five values supported by SQLite: NULL, Int64, Double, String and Data. Since DatabaseValue has no public initializer, use `DatabaseValue.null`, or another type that already adopts the protocol: `1.databaseValue`, `"foo".databaseValue`, etc. Conversion to DatabaseValue *must not* fail.
|
||||
|
||||
The `fromDatabaseValue()` factory method returns an instance of your custom type if the databaseValue contains a suitable value. If the databaseValue does not contain a suitable value, such as "foo" for Date, `fromDatabaseValue` *must* return nil (GRDB will interpret this nil result as a conversion error, and react accordingly).
|
||||
|
||||
**What does the DatabaseValueConvertible protocol bring to a type like UIColor?**
|
||||
|
||||
Well, you will be able to use UIColor like all other [value types](../../../#values) (Bool, Int, String, Date, Swift enums, etc.):
|
||||
|
||||
- Use UIColor as [statement arguments](../../../#executing-updates):
|
||||
|
||||
```swift
|
||||
try db.execute(
|
||||
"INSERT INTO clothes (name, color) VALUES (?, ?)",
|
||||
arguments: ["Shirt", UIColor.red])
|
||||
```
|
||||
|
||||
- UIColor can be [extracted from rows](../../../#column-values):
|
||||
|
||||
```swift
|
||||
let rows = try Row.fetchCursor(db, "SELECT * FROM clothes")
|
||||
while let row = try rows.next() {
|
||||
let name: String = row.value(named: "name")
|
||||
let color: UIColor = row.value(named: "color")
|
||||
}
|
||||
```
|
||||
|
||||
- UIColor can be [directly fetched](../../../#value-queries):
|
||||
|
||||
```swift
|
||||
let colors = try UIColor.fetchAll(db, "SELECT DISTINCT color FROM clothes") // [UIColor]
|
||||
```
|
||||
|
||||
- Use UIColor in [Records](../../../#records):
|
||||
|
||||
```swift
|
||||
class ClothingItem : Record {
|
||||
var name: String
|
||||
var color: UIColor
|
||||
|
||||
required init(row: Row) {
|
||||
name = row.value(named: "name")
|
||||
color = row.value(named: "color")
|
||||
super.init(row: row)
|
||||
}
|
||||
|
||||
override func encode(to container: inout PersistenceContainer) {
|
||||
container["name"] = name
|
||||
container["color"] = color
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- Use UIColor in the [query interface](../../../#the-query-interface):
|
||||
|
||||
```swift
|
||||
let redClothes = try ClothingItem.filter(colorColumn == UIColor.red).fetchAll(db)
|
||||
```
|
||||
|
||||
**Let's have UIColor adopt DatabaseValueConvertible**
|
||||
|
||||
In order to preserve as most information as possible, we'll archive UIColor as a data blob using the NSCoding protocol. But YMMV.
|
||||
|
||||
```swift
|
||||
extension UIColor : DatabaseValueConvertible {
|
||||
|
||||
/// Encode UIColor as a data blob
|
||||
var databaseValue: DatabaseValue {
|
||||
// Use NSKeyedArchiver to build Data
|
||||
let data = NSKeyedArchiver.archivedData(withRootObject: self)
|
||||
|
||||
// Data is already DatabaseValueConvertible
|
||||
return data.databaseValue
|
||||
}
|
||||
|
||||
/// Returns a UIColor if databaseValue contains suitable data, and
|
||||
/// nil otherwise.
|
||||
static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? {
|
||||
// Only Data blobs can contain a UIColor
|
||||
guard let data = Data.fromDatabaseValue(databaseValue) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// We're looking for an archived object
|
||||
guard let color = NSKeyedUnarchiver.unarchiveObject(with: data) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// The cast function will return nil if the unarchived object doesn't
|
||||
// have the correct type
|
||||
return cast(color) // Converts Any to Self?
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Use the `cast` utility function when you want *non-final classes* to implement DatabaseValueConvertible. It avoids compiler errors that are not easy to deal with. Note that final classes and value types won't need it.
|
||||
|
||||
```swift
|
||||
// Workaround Swift inconvenience around factories methods of non-final classes
|
||||
func cast<T, U>(_ value: T) -> U? {
|
||||
return value as? U
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Add an SQLite Function or Operator
|
||||
|
||||
**When an SQLite [function](https://www.sqlite.org/lang_corefunc.html) or [operator](https://www.sqlite.org/lang_expr.html) is missing from GRDB**, this usually means that there hasn't been a [feature request](http://github.com/groue/GRDB.swift/issues) yet.
|
||||
|
||||
But you don't have to wait: you can extend GRDB and the query interface to add support for the missing syntax element (and eventually submit a pull request later).
|
||||
|
||||
Let's remind our goal: we'll add the [STRFTIME](https://www.sqlite.org/lang_datefunc.html) function, and the [GLOB](https://www.sqlite.org/lang_expr.html#like) operator.
|
||||
|
||||
Their SQL usage is the following:
|
||||
|
||||
```sql
|
||||
-- Publication years of books
|
||||
SELECT STRFTIME('%Y', publishedOn) FROM books;
|
||||
-- Books that talk about Moby Dick
|
||||
SELECT * FROM books WHERE body GLOB '*Moby-Dick*';
|
||||
```
|
||||
|
||||
Translated in the query interface, this gives:
|
||||
|
||||
```swift
|
||||
Books.select(strftime("%Y", Column("publishedDate")))
|
||||
Books.filter(Column("body").glob("*Moby-Dick*"))
|
||||
```
|
||||
|
||||
`strftime` is a top-level Swift function because this is how GRDB usually imports SQLite functions which do not have matching standard Swift counterpart, like AVG, LEGNTH, SUM. It helps the Swift code looking like SQL when it is relevant.
|
||||
|
||||
In the same fashion, we expose the GLOB SQL operator as the `glob` Swift method, just because `value.glob(pattern)` reads like `value GLOB pattern`.
|
||||
|
||||
Whenever you import a SQL feature to Swift, you'll have to decide: should you preserve the SQL look and feel, or adopt a well-established swiftism? It's really up to you.
|
||||
|
||||
|
||||
### STRFTIME
|
||||
|
||||
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
|
||||
The [STRFTIME](https://www.sqlite.org/lang_datefunc.html) SQL function accepts many arguments. We'll simplify it to `strftime(format, date)`, so that we can write:
|
||||
|
||||
```sql
|
||||
// Publication years of books
|
||||
// SELECT STRFTIME('%Y', publishedOn) FROM books
|
||||
Books.select(strftime("%Y", Column("publishedDate")))
|
||||
```
|
||||
|
||||
The signature of the Swift `strftime` function is:
|
||||
|
||||
```swift
|
||||
func strftime(_ format: String, _ date: SQLSpecificExpressible) -> SQLExpression
|
||||
```
|
||||
|
||||
SQLSpecificExpressible and SQLExpression are types of the [query interface](../../../#the-query-interface) that you do not usually see. We have moved down one floor, closer to the SQL guts of GRDB. We'll see more new types and protocols below.
|
||||
|
||||
The return value is SQLExpression. All GRDB functions and operators that build [query interface expressions](../../../#expressions) return values of this type. It represents actual [SQLite expressions](https://www.sqlite.org/lang_expr.html).
|
||||
|
||||
SQLExpression is a protocol, so that you can build your own [custom expressions](#add-a-new-kind-of-sqlite-expression). But GRDB ships with a variety of [built-in expressions](#built-in-expressions) that are ready-made, and here we'll use SQLExpressionFunction that is dedicated to function calls:
|
||||
|
||||
```swift
|
||||
struct SQLExpressionFunction : SQLExpression {
|
||||
/// Creates an SQL function call
|
||||
///
|
||||
/// // ABS(-1)
|
||||
/// SQLExpressionFunction(.abs, arguments: -1)
|
||||
init(_ functionName: SQLFunctionName, arguments: SQLExpressible...)
|
||||
}
|
||||
```
|
||||
|
||||
So here is the code that defines our `strftime` function:
|
||||
|
||||
```swift
|
||||
// Add a SQLFunctionName just like we add NSNotification.Name since
|
||||
// the release of Swift 3.
|
||||
extension SQLFunctionName {
|
||||
/// The `STRFTIME` SQL function
|
||||
static let strftime = SQLFunctionName("STRFTIME")
|
||||
}
|
||||
|
||||
/// Returns an expression that evaluates the `STRFTIME` SQL function.
|
||||
///
|
||||
/// // STRFTIME('%Y', date)
|
||||
/// strftime("%Y", Column("date"))
|
||||
func strftime(_ format: String, _ date: SQLSpecificExpressible) -> SQLExpression {
|
||||
return SQLExpressionFunction(.strftime, arguments: format, date)
|
||||
}
|
||||
```
|
||||
|
||||
The `strftime` function is now complete, ready to be used. We haven't yet described the SQLSpecificExpressible type of the `date` argument:
|
||||
|
||||
SQLSpecificExpressible is the protocol for all types that can be turned into a SQL expression, but types like Int, Date, or UIColor that exist outside of GRDB and the query interface. Having `strftime` accept a SQLSpecificExpressible date prevents it from polluting the global space. It is *specific* to GRDB:
|
||||
|
||||
```swift
|
||||
strftime("%Y", Date()) // Compiler error
|
||||
strftime("%Y", Column("date")) // SQLExpression: STRFTIME('%Y', date)
|
||||
```
|
||||
|
||||
You may want to compare it to another protocol, SQLExpressible, which will be described [below](#add-a-new-kind-of-sqlite-expression), when we add support for CAST SQL expressions.
|
||||
|
||||
> :point_up: **Note**: whenever you extend GRDB with a Swift function, method, or operator, you should generally make sure that its signature contains at least one GRDB-specific type. In the `strftime` function, it is the SQLSpecificExpressible protocol.
|
||||
|
||||
|
||||
### GLOB
|
||||
|
||||
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
|
||||
For the [GLOB](https://www.sqlite.org/lang_expr.html#like) operator, we want to define the glob Swift method:
|
||||
|
||||
```swift
|
||||
// Books that talk about Moby Dick
|
||||
// SELECT * FROM books WHERE body GLOB '*Moby-Dick*'
|
||||
Books.filter(Column("body").glob("*Moby-Dick*"))
|
||||
```
|
||||
|
||||
This time we can't use the SQLExpressionFunction type, because it can't generate the SQL for a binary operator. Instead, we'll use another [built-in expression](#built-in-expressions), SQLExpressionBinary:
|
||||
|
||||
```swift
|
||||
struct SQLExpressionBinary : SQLExpression {
|
||||
/// Creates an expression made of two expressions joined with a binary operator.
|
||||
///
|
||||
/// // length * width
|
||||
/// SQLExpressionBinary(.multiply, Column("length"), Column("width"))
|
||||
init(_ op: SQLBinaryOperator, _ lhs: SQLExpressible, _ rhs: SQLExpressible)
|
||||
}
|
||||
```
|
||||
|
||||
Now we have to find the signature of our Swift method. The GLOB operator accepts any value on both sides. However, what kind of Swift code should we accept?
|
||||
|
||||
```swift
|
||||
// 1) body GLOB '*Moby-Dick*' -- Yes, of course
|
||||
Column("body").glob("*Moby-Dick*")
|
||||
// 2) body GLOB pattern -- Sure, why not?
|
||||
Column("body").glob(Column("pattern"))
|
||||
// 3) 'Some Swift String' GLOB pattern - Not sure, but OK
|
||||
"Some Swift String".glob(Column("pattern"))
|
||||
// 4) 'Some Swift String' GLOB 'Another Swift String' -- NO
|
||||
"Some Swift String".glob("Another Swift String")
|
||||
```
|
||||
|
||||
We don't want the form 4, because this is an unacceptable pollution of the Swift global namespace. A good GRDB extension limits its scope to database-related code.
|
||||
|
||||
We thus have two overloaded definitions of the `glob` method:
|
||||
|
||||
```swift
|
||||
extension SQLSpecificExpressible {
|
||||
func glob(_ pattern: SQLExpressible) -> SQLExpression
|
||||
}
|
||||
extension SQLExpressible {
|
||||
func glob(_ pattern: SQLSpecificExpressible) -> SQLExpression
|
||||
}
|
||||
```
|
||||
|
||||
SQLExpressible is the protocol for all types that can be turned into a SQL expression. This includes all expressions, and all [value types](../../../#values) (including String).
|
||||
|
||||
SQLSpecificExpressible is a sub protocol of SQLExpressible protocol, restricted to all types that can be turned into a SQL expression, but types like Int, Date, or String that exist outside of GRDB and the query interface.
|
||||
|
||||
By extending both, we can define the GLOB operators for any pair that contains at least one type that is specific to GRDB - and leave the global Swift space clean.
|
||||
|
||||
The final implementation follows:
|
||||
|
||||
```swift
|
||||
// Add a SQLBinaryOperator just like we add NSNotification.Name since
|
||||
// the release of Swift 3.
|
||||
extension SQLBinaryOperator {
|
||||
/// The `GLOB` binary operator
|
||||
static let glob = SQLBinaryOperator("GLOB")
|
||||
}
|
||||
|
||||
extension SQLSpecificExpressible {
|
||||
/// Returns an SQL `GLOB` expression.
|
||||
///
|
||||
/// // body GLOB '*Moby-Dick*'
|
||||
/// Column("body").glob("*Moby-Dick*")
|
||||
func glob(_ pattern: SQLExpressible) -> SQLExpression {
|
||||
return SQLExpressionBinary(.glob, self, pattern)
|
||||
}
|
||||
}
|
||||
|
||||
extension SQLExpressible {
|
||||
/// Returns an SQL `GLOB` expression.
|
||||
///
|
||||
/// // 'Some Swift String' GLOB pattern
|
||||
/// "Some Swift String".glob(Column("pattern"))
|
||||
func glob(_ pattern: SQLSpecificExpressible) -> SQLExpression {
|
||||
return SQLExpressionBinary(.glob, self, pattern)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Built-in Expressions
|
||||
|
||||
When you extend GRDB with a new function, method, or operator that generates an [SQL expression](https://www.sqlite.org/lang_expr.html), you have to return a value the adopts the SQLExpression protocol.
|
||||
|
||||
We have already seen in our [previous](#strftime) [examples](#glob) two concrete types that generate SQL function calls and binary operators: SQLExpressionFunction and SQLExpressionBinary.
|
||||
|
||||
This section of the documentation lists all built-in expressions. Adding a custom SQLExpression type will be documented [below](#add-a-new-kind-of-sqlite-expression).
|
||||
|
||||
|
||||
#### Column and DatabaseValue
|
||||
|
||||
The [Column](../../../#the-query-interface) type from the query interface, and [DatabaseValue](../../../#databasevalue), the type that wraps the five values supported by SQLite (NULL, Int64, Double, String and Data) are expressions. They are rather trivial, and it is unlikely that you use them in your GRDB extensions.
|
||||
|
||||
|
||||
#### SQLExpressionLiteral
|
||||
|
||||
Use SQLExpressionLiteral when you need to go fast:
|
||||
|
||||
```swift
|
||||
struct SQLExpressionLiteral : SQLExpression {
|
||||
/// Creates an SQL literal expression.
|
||||
///
|
||||
/// SQLExpressionLiteral("1 + 2")
|
||||
/// SQLExpressionLiteral("? + ?", arguments: [1, 2])
|
||||
init(_ sql: String, arguments: StatementArguments? = nil)
|
||||
}
|
||||
```
|
||||
|
||||
For an example of use, see the [Add a new kind of SQLite expression](#add-a-new-kind-of-sqlite-expression) chapter.
|
||||
|
||||
|
||||
#### SQLExpressionUnary
|
||||
|
||||
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
|
||||
SQLExpressionUnary builds an expression by prefixing another expression with an unary operator:
|
||||
|
||||
```swift
|
||||
struct SQLExpressionUnary : SQLExpression {
|
||||
/// Creates an expression made of an unary operator and
|
||||
/// an operand expression.
|
||||
///
|
||||
/// // NOT favorite
|
||||
/// SQLExpressionUnary(.not, Column("favorite"))
|
||||
init(_ op: SQLUnaryOperator, _ value: SQLExpressible)
|
||||
}
|
||||
```
|
||||
|
||||
You add missing SQLite unary operators by extending SQLUnaryOperator:
|
||||
|
||||
```swift
|
||||
extension SQLUnaryOperator {
|
||||
/// The `+` unary operator
|
||||
static let plus = SQLUnaryOperator("+", needsRightSpace: false)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### SQLExpressionBinary
|
||||
|
||||
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
|
||||
SQLExpressionBinary builds an expression by joining two expressions with a binary operator:
|
||||
|
||||
```swift
|
||||
struct SQLExpressionBinary : SQLExpression {
|
||||
/// Creates an expression made of two expressions joined with a binary operator.
|
||||
///
|
||||
/// // length * width
|
||||
/// SQLExpressionBinary(.multiply, Column("length"), Column("width"))
|
||||
init(_ op: SQLBinaryOperator, _ lhs: SQLExpressible, _ rhs: SQLExpressible)
|
||||
}
|
||||
```
|
||||
|
||||
You add missing SQLite binary operators by extending SQLBinaryOperator:
|
||||
|
||||
```swift
|
||||
extension SQLBinaryOperator {
|
||||
/// The `GLOB` binary operator
|
||||
static let glob = SQLBinaryOperator("GLOB")
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### SQLExpressionFunction
|
||||
|
||||
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
|
||||
SQLExpressionFunction builds an SQL function call:
|
||||
|
||||
```swift
|
||||
struct SQLExpressionFunction : SQLExpression {
|
||||
/// Creates an SQL function call
|
||||
///
|
||||
/// // ABS(-1)
|
||||
/// SQLExpressionFunction(.abs, arguments: -1)
|
||||
init(_ functionName: SQLFunctionName, arguments: SQLExpressible...)
|
||||
}
|
||||
```
|
||||
|
||||
You add missing SQLite function names by extending SQLFunctionName:
|
||||
|
||||
```swift
|
||||
extension SQLFunctionName {
|
||||
/// The `STRFTIME` SQL function
|
||||
static let strftime = SQLFunctionName("STRFTIME")
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### The IN Operator
|
||||
|
||||
Build a `value IN (...)` expression from any sequence of [values](../../../#values):
|
||||
|
||||
```swift
|
||||
// SQLExpression: id IN (1, 2, 3)
|
||||
[1,2,3].contains(Column("id"))
|
||||
|
||||
// SQLExpression: id NOT IN (1, 2, 3)
|
||||
![1,2,3].contains(Column("id"))
|
||||
```
|
||||
|
||||
|
||||
#### The BETWEEN Operator
|
||||
|
||||
Build a `value BETWEEN min AND max` expression from Swift ranges:
|
||||
|
||||
```swift
|
||||
// SQLExpression: id BETWEEN 1 AND 10
|
||||
1...10.contains(Column("id")
|
||||
```
|
||||
|
||||
|
||||
#### The COUNT Function
|
||||
|
||||
Build a `COUNT(...)` expression from the [count](http://groue.github.io/GRDB.swift/docs/1.2/Functions.html) and [count(distinct:)](http://groue.github.io/GRDB.swift/docs/1.2/Functions.html) functions:
|
||||
|
||||
```swift
|
||||
// SQLExpression: COUNT(email)
|
||||
count(Column("email"))
|
||||
|
||||
// SQLExpression: COUNT(DISTINCT email)
|
||||
count(distinct: Column("email"))
|
||||
```
|
||||
|
||||
|
||||
#### The COLLATE Operator
|
||||
|
||||
Build a `expression COLLATE collation` expression with the `collating` method:
|
||||
|
||||
```swift
|
||||
// SQLExpression: name = 'Arthur' COLLATE NOCASE
|
||||
Column("name").collating(.nocase) == "Arthur"
|
||||
```
|
||||
|
||||
|
||||
## Add a New Kind of SQLite Expression
|
||||
|
||||
GRDB does not have built-in support for the full range of the SQLite [expression grammar](https://www.sqlite.org/lang_expr.html).
|
||||
|
||||
For example, [CAST expressions](https://www.sqlite.org/lang_expr.html#castexpr) are not ready-made. They can be useful, though: a CAST expression can efficiently convert json strings to UTF-8 data blobs for you:
|
||||
|
||||
```sql
|
||||
SELECT CAST(jsonString AS BLOB) FROM books
|
||||
```
|
||||
|
||||
We'll add below a Swift `cast` function:
|
||||
|
||||
```swift
|
||||
let request = Books.select(cast(Column("jsonString"), as: .blob))
|
||||
let jsonDatas = try Data.fetchAll(db, request) // [Data]
|
||||
```
|
||||
|
||||
`cast` is a top-level Swift function because this is how GRDB usually imports SQLite features which do not have matching standard Swift counterpart. It helps the Swift code looking like SQL when it is relevant. But YMMV.
|
||||
|
||||
The signature of the `cast` function is:
|
||||
|
||||
```swift
|
||||
func cast(_ value: SQLExpressible, as type: Database.ColumnType) -> SQLExpression
|
||||
```
|
||||
|
||||
Database.ColumnType is a String-based enumeration of all database column types (.integer, .text, .blob, etc.) You have already used if you have [created tables](../../../#create-tables) using the query interface.
|
||||
|
||||
The return type SQLExpression is the type returned by all GRDB functions and operators that build [query interface expressions](../../../#expressions).
|
||||
|
||||
SQLExpression is a protocol. But GRDB ships with a variety of [built-in expressions](#built-in-expressions) that are ready-made, so that you generally don't have to write your custom expression type. Here we need something new. So we'll use the most versatile of all, SQLExpressionLiteral:
|
||||
|
||||
```swift
|
||||
struct SQLExpressionLiteral : SQLExpression {
|
||||
/// Creates an SQL literal expression.
|
||||
///
|
||||
/// SQLExpressionLiteral("1 + 2")
|
||||
/// SQLExpressionLiteral("? + ?", arguments: [1, 2])
|
||||
init(_ sql: String, arguments: StatementArguments? = nil)
|
||||
}
|
||||
```
|
||||
|
||||
Here is the code that defines our `cast` function:
|
||||
|
||||
|
||||
```swift
|
||||
func cast(_ value: SQLExpressible, as type: Database.ColumnType) -> SQLExpression {
|
||||
// Turn the value into a literal expression
|
||||
let literal: SQLExpressionLiteral = value.sqlExpression.literal
|
||||
|
||||
// Build our "CAST(value AS type)" sql snippet
|
||||
let sql = "CAST(\(literal.sql) AS \(type.rawValue))"
|
||||
|
||||
// And return a new literal expression, preserving input arguments
|
||||
return SQLExpressionLiteral(sql, arguments: literal.arguments)
|
||||
}
|
||||
```
|
||||
|
||||
We haven't yet described the SQLExpressible type of the `value` argument:
|
||||
|
||||
SQLExpressible is the protocol for all types that can be turned into a SQL expression. This includes all [value types](../../../#values) (Bool, Int, String, Date, Swift enums, etc.):
|
||||
|
||||
```swift
|
||||
cast("foo", as: .blob) // SQLExpression: CAST('foo' AS BLOB)
|
||||
cast(Column("name"), as: .blob) // SQLExpression: CAST(name AS BLOB)
|
||||
```
|
||||
|
||||
You may want to compare it to another protocol, SQLSpecificExpressible, which has been described [above](#strftime), when we were adding support for the STRFTIME SQL function.
|
||||
|
||||
> :point_up: **Note**: whenever you extend GRDB with a Swift function, method, or operator, you should generally make sure that its signature contains at least one GRDB-specific type. In the `cast` function, it is Database.ColumnType.
|
||||
|
||||
**If SQLExpressionLiteral reveals too limited for your purpose**, you may have to implement a new type that adopts the [SQLExpression](http://groue.github.io/GRDB.swift/docs/1.2/Protocols/SQLExpression.html) protocol.
|
||||
@@ -0,0 +1,389 @@
|
||||
FTS5 Tokenizers
|
||||
===============
|
||||
|
||||
**[FTS5](https://www.sqlite.org/fts5.html) is an extensible full-text search engine.**
|
||||
|
||||
GRDB lets you define your own custom FST5 tokenizers, and extend SQLite built-in tokenizers. Possible use cases are:
|
||||
|
||||
- Have "fi" match the ligature "fi" (U+FB01)
|
||||
- Have "first" match "1st"
|
||||
- Have "Encyclopaedia" match "Encyclopædia"
|
||||
- Have "Mueller" match "Müller", and "Grossmann" match "Großmann"
|
||||
- Have "romaji" match "ローマ字", and "pinyin" match "拼音"
|
||||
- Prevent "the" and other stop words from matching any document
|
||||
|
||||
**Table of Contents**
|
||||
|
||||
- [Tokenizers and Full-Text Search](#tokenizers-and-full-text-search)
|
||||
- [The Tokenizer Protocols](#the-tokenizer-protocols)
|
||||
- [Using a Custom Tokenizer](#using-a-custom-tokenizer)
|
||||
- [FTS5Tokenizer](#fts5tokenizer)
|
||||
- [FTS5CustomTokenizer](#fts5customtokenizer)
|
||||
- [FTS5WrapperTokenizer](#fts5wrappertokenizer)
|
||||
- [Choosing the Wrapped Tokenizer](#choosing-the-wrapped-tokenizer)
|
||||
- [Example: Synonyms](#example-synonyms)
|
||||
- [Example: Latin Script](#example-latin-script)
|
||||
|
||||
|
||||
## Tokenizers and Full-Text Search
|
||||
|
||||
**A Tokenizer splits text into tokens**. For example, a tokenizer can split "SQLite is a database engine" into the five tokens "SQLite", "is", "a", "database", and "engine".
|
||||
|
||||
FTS5 use tokenizers to tokenize both indexed documents and search patterns. **A match between a document and a search pattern happens when both produce *identical* tokens.**
|
||||
|
||||
All SQLite [built-in tokenizers](https://www.sqlite.org/fts5.html#tokenizers) tokenize both "SQLite" and "sqlite" into the common lowercase token "sqlite". This is why they are case-insensitive. Generally speaking, different tokenizers achieve different matching by applying different transformations to the input text.
|
||||
|
||||
- The [ascii](https://www.sqlite.org/fts5.html#ascii_tokenizer) tokenizer turns all ASCII characters to lowercase. "SQLite is a database engine" gives "sqlite", "is", "a", "database", and "engine". The query "SQLITE DATABASE" will match, because its tokens "sqlite" and "database" are found in the document.
|
||||
|
||||
- The [unicode61](https://www.sqlite.org/fts5.html#unicode61_tokenizer) tokenizer remove diacritics from latin characters. Unlike the ascii tokenizer, it will match "Jérôme" with "Jerome", as both produce the same "jerome" token.
|
||||
|
||||
- The [porter](https://www.sqlite.org/fts5.html#porter_tokenizer) tokenizer turns English words into their root: "database engine" gives the "databas" and "engin" tokens. The query "database engines" will match, because it produces the same tokens.
|
||||
|
||||
However, built-in tokenizers don't match "first" with "1st", because they produce the different "first" and "1st" tokens.
|
||||
|
||||
Nor do they match "Grossmann" with "Großmann", because they produce the different "grossmann" and "großmann" tokens.
|
||||
|
||||
Custom tokenizers help dealing with these situations. We'll see how to match "Grossmann" and "Großmann" by tokenizing them into "grossmann" (see [latin script](#example-latin-script)). We'll also see how to have "first" and "1st" emit *synonym tokens*, so that they can match too (see [synonyms](#example-synonyms)).
|
||||
|
||||
|
||||
## The Tokenizer Protocols
|
||||
|
||||
GRDB lets you use and define FTS5 tokenizers through three protocols:
|
||||
|
||||
- [FTS5Tokenizer](#fts5tokenizer): the protocol for all FTS5 tokenizers, including the [built-in tokenizers](https://www.sqlite.org/fts5.html#tokenizers) ascii, unicode61, and porter.
|
||||
|
||||
- [FTS5CustomTokenizer](#fts5customtokenizer): the low-level protocol that lets custom tokenizers use the raw [FTS5 C API](https://www.sqlite.org/fts5.html#custom_tokenizers).
|
||||
|
||||
- [FTS5WrapperTokenizer](#fts5wrappertokenizer): the high-level protocol for custom tokenizers that post-processes the tokens produced by another FTS5Tokenizer.
|
||||
|
||||
|
||||
## Using a Custom Tokenizer
|
||||
|
||||
Once you have a custom tokenizer type that adopts [FTS5CustomTokenizer](#fts5customtokenizer) or [FTS5WrapperTokenizer](#fts5wrappertokenizer), it can fuel the FTS5 engine.
|
||||
|
||||
**Register the custom tokenizer into the database:**
|
||||
|
||||
```swift
|
||||
class MyTokenizer : FTS5CustomTokenizer { ... }
|
||||
|
||||
dbQueue.add(tokenizer: MyTokenizer.self) // or dbPool.add
|
||||
```
|
||||
|
||||
**Create [full-text tables](../../../#create-fts5-virtual-tables) that use the custom tokenizer:**
|
||||
|
||||
```swift
|
||||
try db.create(virtualTable: "documents", using: FTS5()) { t in
|
||||
t.tokenizer = MyTokenizer.tokenizerDescriptor()
|
||||
t.column("content")
|
||||
}
|
||||
```
|
||||
|
||||
The full-text table can be fed and queried in [a regular way](../../../#full-text-search):
|
||||
|
||||
```swift
|
||||
try db.execute("INSERT INTO documents VALUES (?)", arguments: ["..."])
|
||||
try Document(content: "...").insert(db)
|
||||
|
||||
let pattern = FTS5Pattern(matchingAnyTokenIn:"...")
|
||||
let documents = try Document.matching(pattern).fetchAll(db)
|
||||
```
|
||||
|
||||
|
||||
## FTS5Tokenizer
|
||||
|
||||
**FST5Tokenizer** is the protocol for all FTS5 tokenizers.
|
||||
|
||||
It only requires a tokenization method that matches the low-level `xTokenize` C function documented at https://www.sqlite.org/fts5.html#custom_tokenizers. We'll discuss it more when describing custom tokenizers.
|
||||
|
||||
```swift
|
||||
typealias FTS5TokenCallback = @convention(c) (
|
||||
_ context: UnsafeMutableRawPointer?,
|
||||
_ flags: Int32,
|
||||
_ pToken: UnsafePointer<Int8>?,
|
||||
_ nToken: Int32,
|
||||
_ iStart: Int32,
|
||||
_ iEnd: Int32) -> Int32
|
||||
|
||||
protocol FTS5Tokenizer : class {
|
||||
func tokenize(
|
||||
context: UnsafeMutableRawPointer?,
|
||||
tokenization: FTS5Tokenization,
|
||||
pText: UnsafePointer<Int8>?,
|
||||
nText: Int32,
|
||||
tokenCallback: FTS5TokenCallback?) -> Int32
|
||||
}
|
||||
```
|
||||
|
||||
You can instantiate tokenizers, including [built-in tokenizers](https://www.sqlite.org/fts5.html#tokenizers), with the `Database.makeTokenizer()` method:
|
||||
|
||||
```swift
|
||||
let unicode61 = try db.makeTokenizer(.unicode61()) // FTS5Tokenizer
|
||||
```
|
||||
|
||||
|
||||
## FTS5CustomTokenizer
|
||||
|
||||
**FTS5CustomTokenizer** is the low-level protocol for your custom tokenizers.
|
||||
|
||||
```swift
|
||||
protocol FTS5CustomTokenizer : FTS5Tokenizer {
|
||||
static var name: String { get }
|
||||
init(db: Database, arguments: [String]) throws
|
||||
}
|
||||
```
|
||||
|
||||
Custom tokenizers have a name, like built-in tokenizers have a name. Don't use "ascii", "porter", or "unicode61" since they are already taken!
|
||||
|
||||
```swift
|
||||
final class MyTokenizer : FTS5CustomTokenizer {
|
||||
static let name = "custom"
|
||||
}
|
||||
```
|
||||
|
||||
SQLite instantiates tokenizers when it needs tokens. The arguments parameter of the `init(db:arguments:)` initializer is an array of strings, which your custom tokenizer can use for its own purposes. In the example below, the arguments will be `["arg1", "arg2"]`.
|
||||
|
||||
```swift
|
||||
// CREATE VIRTUAL TABLE documents USING fts5(
|
||||
// tokenize='custom arg1 arg2',
|
||||
// authors, title, body
|
||||
// )
|
||||
try db.create(virtualTable: "documents", using: FTS5()) { t in
|
||||
t.tokenizer = MyTokenizer.tokenizerDescriptor(arguments: ["arg1", "arg2"])
|
||||
t.column("authors")
|
||||
t.column("title")
|
||||
t.column("body")
|
||||
}
|
||||
```
|
||||
|
||||
FTS5CustomTokenizer inherits from [FTS5Tokenizer](#fts5tokenizer), and performs tokenization with its `tokenize(context:tokenization:pText:nText:tokenCallback:)` method. This low-level method matches the `xTokenize` C function documented at https://www.sqlite.org/fts5.html#custom_tokenizers.
|
||||
|
||||
This method arguments are:
|
||||
|
||||
- `context`: An opaque pointer that is the first argument to the `tokenCallback` function
|
||||
- `tokenization`: The reason why FTS5 is requesting tokenization.
|
||||
- `pText`: The tokenized text bytes. May or may not be nul-terminated.
|
||||
- `nText`: The number of bytes in the tokenized text.
|
||||
- `tokenCallback`: The function to call for each found token. It matches the `xToken` callback at https://www.sqlite.org/fts5.html#custom_tokenizers:
|
||||
- `context`: An opaque pointer
|
||||
- `flags`: Flags that tell FTS5 how to register the token
|
||||
- `pToken`: The token bytes. May or may not be nul-terminated.
|
||||
- `nToken`: The number of bytes in the token
|
||||
- `iStart`: Byte offset of token within input text
|
||||
- `iEnd`: Byte offset of end of token within input text
|
||||
|
||||
Since tokenization is hard, and pointers to byte buffers uneasy to deal with, you may enjoy the [FTS5WrapperTokenizer](#fts5wrappertokenizer) protocol.
|
||||
|
||||
|
||||
## FTS5WrapperTokenizer
|
||||
|
||||
**FTS5WrapperTokenizer** is the high-level protocol for your custom tokenizers. It provides a default implementation for the low-level `tokenize(context:tokenization:pText:nText:tokenCallback:)` method, so that the adopting type does not have to deal with raw byte buffers of the raw [FTS5 C API](https://www.sqlite.org/fts5.html#custom_tokenizers).
|
||||
|
||||
A FTS5WrapperTokenizer lets the hard tokenization job to another tokenizer, the "wrapped tokenizer", and post-processes the tokens produced by this wrapped tokenizer.
|
||||
|
||||
```swift
|
||||
protocol FTS5WrapperTokenizer : FTS5CustomTokenizer {
|
||||
var wrappedTokenizer: FTS5Tokenizer { get }
|
||||
func accept(
|
||||
token: String,
|
||||
flags: FTS5TokenFlags,
|
||||
for tokenization: FTS5Tokenization,
|
||||
tokenCallback: FTS5WrapperTokenCallback) throws
|
||||
}
|
||||
```
|
||||
|
||||
As all custom tokenizers, wrapper tokenizers must have a name:
|
||||
|
||||
```swift
|
||||
final class MyTokenizer : FTS5WrapperTokenizer {
|
||||
static let name = "custom"
|
||||
}
|
||||
```
|
||||
|
||||
The `wrappedTokenizer` property is the mandatory wrapped tokenizer. You instantiate it once, in the initializer:
|
||||
|
||||
```swift
|
||||
final class MyTokenizer : FTS5WrapperTokenizer {
|
||||
let wrappedTokenizer: FTS5Tokenizer
|
||||
|
||||
init(db: Database, arguments: [String]) throws {
|
||||
// Wrap the unicode61 tokenizer
|
||||
wrappedTokenizer = try db.makeTokenizer(.unicode61())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Wrapper tokenizers have to implement the `accept(token:flags:for:tokenCallback:)` method.
|
||||
|
||||
For example, a tokenizer that simply passes tokens through gives:
|
||||
|
||||
```swift
|
||||
final class MyTokenizer : FTS5WrapperTokenizer {
|
||||
func accept(
|
||||
token: String,
|
||||
flags: FTS5TokenFlags,
|
||||
for tokenization: FTS5Tokenization,
|
||||
tokenCallback: FTS5WrapperTokenCallback) throws
|
||||
{
|
||||
// pass through
|
||||
try tokenCallback(token, flags)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The token argument is a token produced by the wrapped tokenizer, ready to be ignored, modified, or multiplied into several [synonyms](#example-synonyms).
|
||||
|
||||
The tokenization parameter tells the reason why tokens are produced, if FTS5 is tokenizing a document, or a search pattern. Some tokenizers may produce different tokens depending on this parameter.
|
||||
|
||||
Finally, the tokenCallback is a function you call to output a custom token.
|
||||
|
||||
There are a two rules to observe when implementing the accept method:
|
||||
|
||||
1. Errors thrown by the tokenCallback function must not be caught (they notify that FTS5 requires the tokenization process to stop immediately).
|
||||
2. The flags parameter should be given unmodified to the tokenCallback function along with the custom token, unless you union it with the `.colocated` flag when the tokenizer produces [synonyms](#example-synonyms).
|
||||
|
||||
|
||||
### Choosing the Wrapped Tokenizer
|
||||
|
||||
The wrapped tokenizer can be hard-coded, or chosen at runtime.
|
||||
|
||||
For example, your custom tokenizer can wrap [unicode61](https://www.sqlite.org/fts5.html#unicode61_tokenizer), unless arguments say otherwise (in a fashion similar to the [porter](https://www.sqlite.org/fts5.html#porter_tokenizer) tokenizer):
|
||||
|
||||
```swift
|
||||
final class MyTokenizer : FTS5WrapperTokenizer {
|
||||
static let name = "custom"
|
||||
let wrappedTokenizer: FTS5Tokenizer
|
||||
|
||||
init(db: Database, arguments: [String]) throws {
|
||||
if arguments.isEmpty {
|
||||
wrappedTokenizer = try db.makeTokenizer(.unicode61())
|
||||
} else {
|
||||
let descriptor = FTS5TokenizerDescriptor(components: arguments)
|
||||
wrappedTokenizer = try db.makeTokenizer(descriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Arguments are provided when the virtual table is created:
|
||||
|
||||
```swift
|
||||
// CREATE VIRTUAL TABLE documents USING fts5(
|
||||
// tokenize='custom',
|
||||
// content
|
||||
// )
|
||||
try db.create(virtualTable: "documents", using: FTS5()) { t in
|
||||
// Wraps the default unicode61
|
||||
t.tokenizer = MyTokenizer.tokenizerDescriptor()
|
||||
t.column("content")
|
||||
}
|
||||
|
||||
// CREATE VIRTUAL TABLE documents USING fts5(
|
||||
// tokenize='custom ascii'
|
||||
// content
|
||||
// )
|
||||
try db.create(virtualTable: "documents", using: FTS5()) { t in
|
||||
// Wraps ascii
|
||||
let ascii = FTS5TokenizerDescriptor.ascii()
|
||||
t.tokenizer = MyTokenizer.tokenizerDescriptor(arguments: ascii.components)
|
||||
t.column("content")
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Example: Synonyms
|
||||
|
||||
**FTS5 lets tokenizers produce synonyms**, so that, for example, "first" can match "1st".
|
||||
|
||||
The topic of synonyms is documented at https://www.sqlite.org/fts5.html#synonym_support, which describes several methods. You should carefully read this documentation, and pick the method you prefer.
|
||||
|
||||
In the example below, we'll pick method (3), and implement a tokenizer that adds multiple synonyms for a single term to the FTS index. Using this method, when tokenizing document text, the tokenizer provides multiple synonyms for each token. So that when a document such as "I won first place" is tokenized, entries are added to the FTS index for "i", "won", "first", "1st" and "place".
|
||||
|
||||
We'll also take care of the SQLite advice:
|
||||
|
||||
> When using methods (2) or (3), it is important that the tokenizer only provide synonyms when tokenizing document text or query text, not both. Doing so will not cause any errors, but is inefficient.
|
||||
|
||||
```swift
|
||||
final class SynonymsTokenizer : FTS5WrapperTokenizer {
|
||||
static let name = "synonyms"
|
||||
let wrappedTokenizer: FTS5Tokenizer
|
||||
let synonyms: [Set<String>] = [["first", "1st"]]
|
||||
|
||||
init(db: Database, arguments: [String]) throws {
|
||||
wrappedTokenizer = try db.makeTokenizer(.unicode61())
|
||||
}
|
||||
|
||||
func synonyms(for token: String) -> Set<String>? {
|
||||
return synonyms.first { $0.contains(token) }
|
||||
}
|
||||
|
||||
func accept(token: String, flags: FTS5TokenFlags, for tokenization: FTS5Tokenization, tokenCallback: FTS5WrapperTokenCallback) throws {
|
||||
if tokenization.contains(.query) {
|
||||
// Don't look for synonyms when tokenizing queries
|
||||
try tokenCallback(token, flags)
|
||||
return
|
||||
}
|
||||
|
||||
guard let synonyms = synonyms(for: token) else {
|
||||
// Token has no synonym
|
||||
try tokenCallback(token, flags)
|
||||
return
|
||||
}
|
||||
|
||||
for (index, synonym) in synonyms.enumerated() {
|
||||
// Notify each synonym, and set the colocated flag for all but the first
|
||||
let synonymFlags = (index == 0) ? flags : flags.union(.colocated)
|
||||
try tokenCallback(synonym, synonymFlags)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Example: Latin Script
|
||||
|
||||
Languages that use the [latin script](https://en.wikipedia.org/wiki/Latin_script) offer a rich set of typographical, historical, and local features such as diacritics, ligatures, and dotless I: Großmann, fidélité (with the ligature "fi" U+FB01), Diyarbakır.
|
||||
|
||||
Full-text search in such a corpus often needs input tolerance, so that "encyclopaedia" can match "Encyclopædia", "Grossmann", "Großmann", and "Jerome", "Jérôme".
|
||||
|
||||
German has something specific in that both "Mueller" and "Muller" should match "Müller", when "Bauer" should not match "Baur" (only "ü" accepts both "u" and "ue"). A pull request that adds a chapter about German will be welcome.
|
||||
|
||||
A custom FTS5 tokenizer lets you provide fuzzy latin matching: after "Grossmann", "Großmann", and "GROSSMANN" have all been turned into "grossmann", they will all match together.
|
||||
|
||||
We'll wrap the built-in [unicode61](https://www.sqlite.org/fts5.html#unicode61_tokenizer) tokenizer (the one that knows how to split text on spaces and punctuations), and transform its tokens into their bare lowercase ascii form.
|
||||
|
||||
The tokenizer wrapping is provided by the [FTS5WrapperTokenizer](#fts5wrappertokenizer) protocol. The string transformation is provided by the [String.applyingTransform](https://developer.apple.com/reference/swift/string/1643133-applyingtransform) method:
|
||||
|
||||
```swift
|
||||
final class LatinAsciiTokenizer : FTS5WrapperTokenizer {
|
||||
static let name = "latinascii"
|
||||
let wrappedTokenizer: FTS5Tokenizer
|
||||
|
||||
init(db: Database, arguments: [String]) throws {
|
||||
wrappedTokenizer = try db.makeTokenizer(.unicode61())
|
||||
}
|
||||
|
||||
func accept(token: String, flags: FTS5TokenFlags, for tokenization: FTS5Tokenization, tokenCallback: FTS5WrapperTokenCallback) throws {
|
||||
if let token = token.applyingTransform(StringTransform("Latin-ASCII; Lower"), reverse: false) {
|
||||
try tokenCallback(token, flags)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> :point_up: **Note**: String.applyingTransform is not available before iOS 9.0 and macOS 10.11. Use the Core Foundation function [CFStringTransform](https://developer.apple.com/reference/corefoundation/1542411-cfstringtransform) instead.
|
||||
|
||||
Remember to register LatinAsciiTokenizer before using it:
|
||||
|
||||
```swift
|
||||
dbQueue.add(tokenizer: LatinAsciiTokenizer.self) // or dbPool.add
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
try db.create(virtualTable: "documents", using: FTS5()) { t in
|
||||
t.tokenizer = LatinAsciiTokenizer.tokenizerDescriptor()
|
||||
t.column("authors")
|
||||
t.column("title")
|
||||
t.column("body")
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
The main documentation is available in [README.md](../../../#documentation).
|
||||
@@ -0,0 +1,33 @@
|
||||
Release Process
|
||||
===============
|
||||
|
||||
**This is internal documentation.**
|
||||
|
||||
To release a new GRDB version:
|
||||
|
||||
- Tests
|
||||
- `make test`
|
||||
- Build and run GRDBDemoiOS in Release configuration on a device
|
||||
- Archive GRDBDemoiOS
|
||||
- Check for performance regression with GRDBOSXPerformanceTests
|
||||
- On SDK upgrade, update Support/sqlite3.h
|
||||
- On https://github.com/groue/sqlcipher.git upgrade, update SQLCipher version in README.md
|
||||
- On https://github.com/swiftlyfalling/SQLiteLib upgrade, update SQLite version in README.md and Documentation/CustomSQLiteBuilds.md
|
||||
- Update GRDB version number and release date in:
|
||||
- Makefile
|
||||
- CHANGELOG.md
|
||||
- Documentation/CustomSQLiteBuilds.md
|
||||
- Documentation/ExtendingGRDB.md
|
||||
- GRDB.swift.podspec
|
||||
- GRDBCipher.podspec
|
||||
- README.md
|
||||
- Support/Info.plist
|
||||
- Commit and tag
|
||||
- Check tag authors: `git for-each-ref --format '%(refname) %(authorname)' refs/tags`
|
||||
- Push to the master branch
|
||||
- Push to the Swift3 branch
|
||||
- `pod trunk push --allow-warnings GRDB.swift.podspec`
|
||||
- `pod trunk push --allow-warnings GRDBCipher.podspec`
|
||||
- `make doc`, and update index.html in the `gh-pages` branch
|
||||
- Update http://github.com/groue/GRDBDemo
|
||||
- Update http://github.com/groue/WWDCCompanion
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
github "groue/GRDB.swift" "master"
|
||||
@@ -1,542 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
5673743C1B4D46600089DE44 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5673743B1B4D46600089DE44 /* AppDelegate.swift */; };
|
||||
5673743E1B4D46600089DE44 /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5673743D1B4D46600089DE44 /* MasterViewController.swift */; };
|
||||
567374401B4D46600089DE44 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5673743F1B4D46600089DE44 /* DetailViewController.swift */; };
|
||||
567374431B4D46600089DE44 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 567374411B4D46600089DE44 /* Main.storyboard */; };
|
||||
567374451B4D46600089DE44 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 567374441B4D46600089DE44 /* Assets.xcassets */; };
|
||||
567374481B4D46600089DE44 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 567374461B4D46600089DE44 /* LaunchScreen.storyboard */; };
|
||||
567374531B4D46600089DE44 /* iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567374521B4D46600089DE44 /* iOSTests.swift */; };
|
||||
5673745E1B4D46600089DE44 /* iOSUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5673745D1B4D46600089DE44 /* iOSUITests.swift */; };
|
||||
567374701B4D48AB0089DE44 /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5673746F1B4D48AB0089DE44 /* Person.swift */; };
|
||||
567374731B4D7A2E0089DE44 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 567374721B4D7A2E0089DE44 /* GRDB.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
5673744F1B4D46600089DE44 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 567374301B4D46600089DE44 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 567374371B4D46600089DE44;
|
||||
remoteInfo = iOS;
|
||||
};
|
||||
5673745A1B4D46600089DE44 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 567374301B4D46600089DE44 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 567374371B4D46600089DE44;
|
||||
remoteInfo = iOS;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
567374381B4D46600089DE44 /* iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5673743B1B4D46600089DE44 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
5673743D1B4D46600089DE44 /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = "<group>"; };
|
||||
5673743F1B4D46600089DE44 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
|
||||
567374421B4D46600089DE44 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
567374441B4D46600089DE44 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
567374471B4D46600089DE44 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
567374491B4D46600089DE44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
5673744E1B4D46600089DE44 /* iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
567374521B4D46600089DE44 /* iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSTests.swift; sourceTree = "<group>"; };
|
||||
567374541B4D46600089DE44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
567374591B4D46600089DE44 /* iOSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iOSUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5673745D1B4D46600089DE44 /* iOSUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSUITests.swift; sourceTree = "<group>"; };
|
||||
5673745F1B4D46600089DE44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
5673746F1B4D48AB0089DE44 /* Person.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Person.swift; sourceTree = "<group>"; };
|
||||
567374721B4D7A2E0089DE44 /* GRDB.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GRDB.framework; path = ../Carthage/Build/iOS/GRDB.framework; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
567374351B4D46600089DE44 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
567374731B4D7A2E0089DE44 /* GRDB.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
5673744B1B4D46600089DE44 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
567374561B4D46600089DE44 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
5673742F1B4D46600089DE44 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
567374721B4D7A2E0089DE44 /* GRDB.framework */,
|
||||
5673743A1B4D46600089DE44 /* iOS */,
|
||||
567374511B4D46600089DE44 /* iOSTests */,
|
||||
5673745C1B4D46600089DE44 /* iOSUITests */,
|
||||
567374391B4D46600089DE44 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
567374391B4D46600089DE44 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
567374381B4D46600089DE44 /* iOS.app */,
|
||||
5673744E1B4D46600089DE44 /* iOSTests.xctest */,
|
||||
567374591B4D46600089DE44 /* iOSUITests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5673743A1B4D46600089DE44 /* iOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5673743B1B4D46600089DE44 /* AppDelegate.swift */,
|
||||
5673743D1B4D46600089DE44 /* MasterViewController.swift */,
|
||||
5673743F1B4D46600089DE44 /* DetailViewController.swift */,
|
||||
5673746F1B4D48AB0089DE44 /* Person.swift */,
|
||||
567374411B4D46600089DE44 /* Main.storyboard */,
|
||||
567374441B4D46600089DE44 /* Assets.xcassets */,
|
||||
567374461B4D46600089DE44 /* LaunchScreen.storyboard */,
|
||||
567374491B4D46600089DE44 /* Info.plist */,
|
||||
);
|
||||
path = iOS;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
567374511B4D46600089DE44 /* iOSTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
567374521B4D46600089DE44 /* iOSTests.swift */,
|
||||
567374541B4D46600089DE44 /* Info.plist */,
|
||||
);
|
||||
path = iOSTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5673745C1B4D46600089DE44 /* iOSUITests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5673745D1B4D46600089DE44 /* iOSUITests.swift */,
|
||||
5673745F1B4D46600089DE44 /* Info.plist */,
|
||||
);
|
||||
path = iOSUITests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
567374371B4D46600089DE44 /* iOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 567374621B4D46600089DE44 /* Build configuration list for PBXNativeTarget "iOS" */;
|
||||
buildPhases = (
|
||||
567374341B4D46600089DE44 /* Sources */,
|
||||
567374351B4D46600089DE44 /* Frameworks */,
|
||||
567374361B4D46600089DE44 /* Resources */,
|
||||
567374741B4D7A3B0089DE44 /* ShellScript */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = iOS;
|
||||
productName = iOS;
|
||||
productReference = 567374381B4D46600089DE44 /* iOS.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
5673744D1B4D46600089DE44 /* iOSTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 567374651B4D46600089DE44 /* Build configuration list for PBXNativeTarget "iOSTests" */;
|
||||
buildPhases = (
|
||||
5673744A1B4D46600089DE44 /* Sources */,
|
||||
5673744B1B4D46600089DE44 /* Frameworks */,
|
||||
5673744C1B4D46600089DE44 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
567374501B4D46600089DE44 /* PBXTargetDependency */,
|
||||
);
|
||||
name = iOSTests;
|
||||
productName = iOSTests;
|
||||
productReference = 5673744E1B4D46600089DE44 /* iOSTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
567374581B4D46600089DE44 /* iOSUITests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 567374681B4D46600089DE44 /* Build configuration list for PBXNativeTarget "iOSUITests" */;
|
||||
buildPhases = (
|
||||
567374551B4D46600089DE44 /* Sources */,
|
||||
567374561B4D46600089DE44 /* Frameworks */,
|
||||
567374571B4D46600089DE44 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
5673745B1B4D46600089DE44 /* PBXTargetDependency */,
|
||||
);
|
||||
name = iOSUITests;
|
||||
productName = iOSUITests;
|
||||
productReference = 567374591B4D46600089DE44 /* iOSUITests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.ui-testing";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
567374301B4D46600089DE44 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0700;
|
||||
ORGANIZATIONNAME = "Gwendal Roué";
|
||||
TargetAttributes = {
|
||||
567374371B4D46600089DE44 = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
};
|
||||
5673744D1B4D46600089DE44 = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
TestTargetID = 567374371B4D46600089DE44;
|
||||
};
|
||||
567374581B4D46600089DE44 = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
TestTargetID = 567374371B4D46600089DE44;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 567374331B4D46600089DE44 /* Build configuration list for PBXProject "iOS" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 5673742F1B4D46600089DE44;
|
||||
productRefGroup = 567374391B4D46600089DE44 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
567374371B4D46600089DE44 /* iOS */,
|
||||
5673744D1B4D46600089DE44 /* iOSTests */,
|
||||
567374581B4D46600089DE44 /* iOSUITests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
567374361B4D46600089DE44 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
567374481B4D46600089DE44 /* LaunchScreen.storyboard in Resources */,
|
||||
567374451B4D46600089DE44 /* Assets.xcassets in Resources */,
|
||||
567374431B4D46600089DE44 /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
5673744C1B4D46600089DE44 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
567374571B4D46600089DE44 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
567374741B4D7A3B0089DE44 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"$(SRCROOT)/../Carthage/Build/iOS/GRDB.framework",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/usr/local/bin/carthage copy-frameworks";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
567374341B4D46600089DE44 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
567374401B4D46600089DE44 /* DetailViewController.swift in Sources */,
|
||||
5673743E1B4D46600089DE44 /* MasterViewController.swift in Sources */,
|
||||
567374701B4D48AB0089DE44 /* Person.swift in Sources */,
|
||||
5673743C1B4D46600089DE44 /* AppDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
5673744A1B4D46600089DE44 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
567374531B4D46600089DE44 /* iOSTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
567374551B4D46600089DE44 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5673745E1B4D46600089DE44 /* iOSUITests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
567374501B4D46600089DE44 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 567374371B4D46600089DE44 /* iOS */;
|
||||
targetProxy = 5673744F1B4D46600089DE44 /* PBXContainerItemProxy */;
|
||||
};
|
||||
5673745B1B4D46600089DE44 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 567374371B4D46600089DE44 /* iOS */;
|
||||
targetProxy = 5673745A1B4D46600089DE44 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
567374411B4D46600089DE44 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
567374421B4D46600089DE44 /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
567374461B4D46600089DE44 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
567374471B4D46600089DE44 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
567374601B4D46600089DE44 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
567374611B4D46600089DE44 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
567374631B4D46600089DE44 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../Carthage/Build/iOS",
|
||||
);
|
||||
INFOPLIST_FILE = iOS/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.iOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
567374641B4D46600089DE44 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../Carthage/Build/iOS",
|
||||
);
|
||||
INFOPLIST_FILE = iOS/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.iOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
567374661B4D46600089DE44 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
INFOPLIST_FILE = iOSTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.iOSTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS.app/iOS";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
567374671B4D46600089DE44 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
INFOPLIST_FILE = iOSTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.iOSTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS.app/iOS";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
567374691B4D46600089DE44 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
INFOPLIST_FILE = iOSUITests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.iOSUITests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_TARGET_NAME = iOS;
|
||||
USES_XCTRUNNER = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
5673746A1B4D46600089DE44 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
INFOPLIST_FILE = iOSUITests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.iOSUITests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_TARGET_NAME = iOS;
|
||||
USES_XCTRUNNER = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
567374331B4D46600089DE44 /* Build configuration list for PBXProject "iOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
567374601B4D46600089DE44 /* Debug */,
|
||||
567374611B4D46600089DE44 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
567374621B4D46600089DE44 /* Build configuration list for PBXNativeTarget "iOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
567374631B4D46600089DE44 /* Debug */,
|
||||
567374641B4D46600089DE44 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
};
|
||||
567374651B4D46600089DE44 /* Build configuration list for PBXNativeTarget "iOSTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
567374661B4D46600089DE44 /* Debug */,
|
||||
567374671B4D46600089DE44 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
};
|
||||
567374681B4D46600089DE44 /* Build configuration list for PBXNativeTarget "iOSUITests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
567374691B4D46600089DE44 /* Debug */,
|
||||
5673746A1B4D46600089DE44 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 567374301B4D46600089DE44 /* Project object */;
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// iOS
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import GRDB
|
||||
|
||||
var dbQueue: DatabaseQueue!
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
let splitViewController = self.window!.rootViewController as! UISplitViewController
|
||||
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
|
||||
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
|
||||
splitViewController.delegate = self
|
||||
|
||||
// Database
|
||||
dbQueue = DatabaseQueue()
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute("CREATE TABLE persons (id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT)")
|
||||
}
|
||||
migrator.registerMigration("addPersons") { db in
|
||||
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
|
||||
try Person(firstName: "Barbara", lastName: "Streisand").insert(db)
|
||||
try Person(firstName: "Cinderella").insert(db)
|
||||
}
|
||||
try! migrator.migrate(dbQueue)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: - Split view
|
||||
|
||||
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController:UIViewController, ontoPrimaryViewController primaryViewController:UIViewController) -> Bool {
|
||||
guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
|
||||
guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false }
|
||||
if topAsDetailController.person == nil {
|
||||
// Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8076" systemVersion="14D121" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8063"/>
|
||||
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright © 2015 Gwendal Roué. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
|
||||
<rect key="frame" x="20" y="559" width="560" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="iOS" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
|
||||
<rect key="frame" x="20" y="180" width="560" height="43"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
|
||||
<constraint firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
|
||||
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
|
||||
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
|
||||
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
|
||||
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
@@ -1,135 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8121.20" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="H1p-Uh-vWS">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8101.16"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Master-->
|
||||
<scene sceneID="pY4-Hu-kfo">
|
||||
<objects>
|
||||
<navigationController title="Master" id="RMx-3f-FxP" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="Pmd-2v-anx">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="7bK-jq-Zjz" kind="relationship" relationship="rootViewController" id="tsl-Nk-0bq"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="8fS-aE-onr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-38" y="-630"/>
|
||||
</scene>
|
||||
<!--Detail-->
|
||||
<scene sceneID="yUG-lL-AsK">
|
||||
<objects>
|
||||
<viewController title="Detail" id="JEX-9P-axG" customClass="DetailViewController" customModule="iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="SYR-Wa-9uf"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="GAO-Cl-Wes"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="svH-Pt-448">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Detail view content goes here" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="0XM-y9-sOw">
|
||||
<rect key="frame" x="20" y="292" width="560" height="17"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" size="system"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="0XM-y9-sOw" firstAttribute="leading" secondItem="svH-Pt-448" secondAttribute="leading" constant="20" symbolic="YES" id="Tsc-yG-G1q"/>
|
||||
<constraint firstItem="0XM-y9-sOw" firstAttribute="centerY" secondItem="svH-Pt-448" secondAttribute="centerY" id="jWN-iV-94e"/>
|
||||
<constraint firstAttribute="trailing" secondItem="0XM-y9-sOw" secondAttribute="trailing" constant="20" symbolic="YES" id="tHV-ZD-HQj"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<toolbarItems/>
|
||||
<navigationItem key="navigationItem" title="Detail" id="mOI-FS-AaM"/>
|
||||
<connections>
|
||||
<outlet property="detailDescriptionLabel" destination="0XM-y9-sOw" id="deQ-Na-JPF"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="FJe-Yq-33r" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="709" y="129"/>
|
||||
</scene>
|
||||
<!--Split View Controller-->
|
||||
<scene sceneID="Nki-YV-4Qg">
|
||||
<objects>
|
||||
<splitViewController id="H1p-Uh-vWS" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<connections>
|
||||
<segue destination="RMx-3f-FxP" kind="relationship" relationship="masterViewController" id="BlO-5A-QYV"/>
|
||||
<segue destination="vC3-pB-5Vb" kind="relationship" relationship="detailViewController" id="Tll-UG-LXB"/>
|
||||
</connections>
|
||||
</splitViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="cZU-Oi-B1e" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-856" y="-330"/>
|
||||
</scene>
|
||||
<!--Master-->
|
||||
<scene sceneID="smW-Zh-WAh">
|
||||
<objects>
|
||||
<tableViewController title="Master" clearsSelectionOnViewWillAppear="NO" id="7bK-jq-Zjz" customClass="MasterViewController" customModule="iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="r7i-6Z-zg0">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="Arm-wq-HPj" style="IBUITableViewCellStyleDefault" id="WCw-Qf-5nD">
|
||||
<rect key="frame" x="0.0" y="86" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WCw-Qf-5nD" id="37f-cq-3Eg">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Arm-wq-HPj">
|
||||
<rect key="frame" x="15" y="0.0" width="570" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
<segue destination="vC3-pB-5Vb" kind="showDetail" identifier="showDetail" id="6S0-TO-JiA"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<sections/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="7bK-jq-Zjz" id="Gho-Na-rnu"/>
|
||||
<outlet property="delegate" destination="7bK-jq-Zjz" id="RA6-mI-bju"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Master" id="Zdf-7t-Un8"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Rux-fX-hf1" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="709" y="-630"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="r7l-gg-dq7">
|
||||
<objects>
|
||||
<navigationController id="vC3-pB-5Vb" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="DjV-YW-jjY">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="JEX-9P-axG" kind="relationship" relationship="rootViewController" id="GKi-kA-LjT"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="SLD-UC-DBI" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-45" y="129"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="6S0-TO-JiA"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// DetailViewController.swift
|
||||
// iOS
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class DetailViewController: UIViewController {
|
||||
|
||||
@IBOutlet weak var detailDescriptionLabel: UILabel!
|
||||
|
||||
var person: Person? {
|
||||
didSet {
|
||||
self.configureView()
|
||||
}
|
||||
}
|
||||
|
||||
func configureView() {
|
||||
if let person = self.person {
|
||||
if let label = self.detailDescriptionLabel {
|
||||
label.text = person.fullName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.configureView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// MasterViewController.swift
|
||||
// iOS
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class MasterViewController: UITableViewController {
|
||||
|
||||
var detailViewController: DetailViewController? = nil
|
||||
var persons = [Person]()
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
self.navigationItem.leftBarButtonItem = self.editButtonItem()
|
||||
|
||||
if let split = self.splitViewController {
|
||||
let controllers = split.viewControllers
|
||||
self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
persons = dbQueue.inDatabase { db in
|
||||
db.fetchAll(Person.self, "SELECT * FROM persons ORDER BY firstName, lastName")
|
||||
}
|
||||
self.clearsSelectionOnViewWillAppear = self.splitViewController!.collapsed
|
||||
super.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
// MARK: - Segues
|
||||
|
||||
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
|
||||
if segue.identifier == "showDetail" {
|
||||
if let indexPath = self.tableView.indexPathForSelectedRow {
|
||||
let person = persons[indexPath.row]
|
||||
let controller = (segue.destinationViewController as! UINavigationController).topViewController as! DetailViewController
|
||||
controller.person = person
|
||||
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
|
||||
controller.navigationItem.leftItemsSupplementBackButton = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Table View
|
||||
|
||||
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return persons.count
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
|
||||
|
||||
let person = persons[indexPath.row]
|
||||
cell.textLabel!.text = person.fullName
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
|
||||
let person = persons[indexPath.row]
|
||||
try! dbQueue.inTransaction { db in
|
||||
try person.delete(db)
|
||||
return .Commit
|
||||
}
|
||||
persons.removeAtIndex(indexPath.row)
|
||||
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
//
|
||||
// Person.swift
|
||||
// iOS
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import GRDB
|
||||
|
||||
class Person : RowModel {
|
||||
var id: Int64!
|
||||
var firstName: String?
|
||||
var lastName: String?
|
||||
var fullName: String {
|
||||
return " ".join([firstName, lastName].filter { $0 != nil }.map { $0! })
|
||||
}
|
||||
|
||||
init(firstName: String? = nil, lastName: String? = nil) {
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
super.init()
|
||||
}
|
||||
|
||||
// MARK: - RowModel
|
||||
|
||||
override class var databaseTable: Table? {
|
||||
return Table(named: "persons", primaryKey: .RowID("id"))
|
||||
}
|
||||
|
||||
override func setDatabaseValue(dbv: DatabaseValue, forColumn column: String) {
|
||||
switch column {
|
||||
case "id": id = dbv.value()
|
||||
case "firstName": firstName = dbv.value()
|
||||
case "lastName": lastName = dbv.value()
|
||||
default: super.setDatabaseValue(dbv, forColumn: column)
|
||||
}
|
||||
}
|
||||
|
||||
override var storedDatabaseDictionary: [String: DatabaseValueConvertible?] {
|
||||
return [
|
||||
"id": id,
|
||||
"firstName": firstName,
|
||||
"lastName": lastName]
|
||||
}
|
||||
|
||||
required init(row: Row) {
|
||||
super.init(row: row)
|
||||
}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// iOSTests.swift
|
||||
// iOSTests
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class iOSTests: XCTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testExample() {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
func testPerformanceExample() {
|
||||
// This is an example of a performance test case.
|
||||
self.measureBlock() {
|
||||
// Put the code you want to measure the time of here.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// iOSUITests.swift
|
||||
// iOSUITests
|
||||
//
|
||||
// Created by Gwendal Roué on 08/07/2015.
|
||||
// Copyright © 2015 Gwendal Roué. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
class iOSUITests: XCTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
|
||||
// In UI tests it is usually best to stop immediately when a failure occurs.
|
||||
continueAfterFailure = false
|
||||
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
|
||||
XCUIApplication().launch()
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testExample() {
|
||||
// Use recording to get started writing UI tests.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,451 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class DatabaseTests : GRDBTestCase {
|
||||
|
||||
func testCreateTable() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
XCTAssertFalse(db.tableExists("persons"))
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"name TEXT, " +
|
||||
"age INT)")
|
||||
XCTAssertTrue(db.tableExists("persons"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateStatement() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
|
||||
// The tested function:
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES ('Arthur', 41)")
|
||||
try statement.execute()
|
||||
|
||||
let row = db.fetchOneRow("SELECT * FROM persons")!
|
||||
XCTAssertEqual(row.value(atIndex: 0)! as String, "Arthur")
|
||||
XCTAssertEqual(row.value(atIndex: 1)! as Int, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateStatementArrayBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (?, ?)")
|
||||
// The tested function:
|
||||
statement.bindings = ["Arthur", 41]
|
||||
try statement.execute()
|
||||
|
||||
let row = db.fetchOneRow("SELECT * FROM persons")!
|
||||
XCTAssertEqual(row.value(atIndex: 0)! as String, "Arthur")
|
||||
XCTAssertEqual(row.value(atIndex: 1)! as Int, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateStatementDictionaryBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (:name, :age)")
|
||||
// The tested function:
|
||||
statement.bindings = ["name": "Arthur", "age": 41]
|
||||
try statement.execute()
|
||||
|
||||
let row = db.fetchOneRow("SELECT * FROM persons")!
|
||||
XCTAssertEqual(row.value(atIndex: 0)! as String, "Arthur")
|
||||
XCTAssertEqual(row.value(atIndex: 1)! as Int, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateStatementWithArrayBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
|
||||
// The tested function:
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (?, ?)", bindings: ["Arthur", 41])
|
||||
try statement.execute()
|
||||
|
||||
let row = db.fetchOneRow("SELECT * FROM persons")!
|
||||
XCTAssertEqual(row.value(atIndex: 0)! as String, "Arthur")
|
||||
XCTAssertEqual(row.value(atIndex: 1)! as Int, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateStatementWithDictionaryBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
|
||||
// The tested function:
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try statement.execute()
|
||||
|
||||
let row = db.fetchOneRow("SELECT * FROM persons")!
|
||||
XCTAssertEqual(row.value(atIndex: 0)! as String, "Arthur")
|
||||
XCTAssertEqual(row.value(atIndex: 1)! as Int, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDatabaseExecute() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
|
||||
// The tested function:
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES ('Arthur', 41)")
|
||||
|
||||
let row = db.fetchOneRow("SELECT * FROM persons")!
|
||||
XCTAssertEqual(row.value(atIndex: 0)! as String, "Arthur")
|
||||
XCTAssertEqual(row.value(atIndex: 1)! as Int, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDatabaseExecuteWithArrayBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
|
||||
// The tested function:
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (?, ?)", bindings: ["Arthur", 41])
|
||||
|
||||
let row = db.fetchOneRow("SELECT * FROM persons")!
|
||||
XCTAssertEqual(row.value(atIndex: 0)! as String, "Arthur")
|
||||
XCTAssertEqual(row.value(atIndex: 1)! as Int, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDatabaseExecuteWithDictionaryBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
|
||||
// The tested function:
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
|
||||
let row = db.fetchOneRow("SELECT * FROM persons")!
|
||||
XCTAssertEqual(row.value(atIndex: 0)! as String, "Arthur")
|
||||
XCTAssertEqual(row.value(atIndex: 1)! as Int, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectStatement() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Barbara"])
|
||||
|
||||
// The tested function:
|
||||
let statement = db.selectStatement("SELECT * FROM persons")
|
||||
|
||||
let rows = statement.fetchAllRows()
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectStatementArrayBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Barbara"])
|
||||
|
||||
let statement = db.selectStatement("SELECT * FROM persons WHERE name = ?")
|
||||
// The tested function:
|
||||
statement.bindings = ["Arthur"]
|
||||
|
||||
let rows = statement.fetchAllRows()
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectStatementDictionaryBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Barbara"])
|
||||
|
||||
let statement = db.selectStatement("SELECT * FROM persons WHERE name = :name")
|
||||
// The tested function:
|
||||
statement.bindings = ["name": "Arthur"]
|
||||
|
||||
let rows = statement.fetchAllRows()
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectStatementWithArrayBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Barbara"])
|
||||
|
||||
// The tested function:
|
||||
let statement = db.selectStatement("SELECT * FROM persons WHERE name = ?", bindings: ["Arthur"])
|
||||
|
||||
let rows = statement.fetchAllRows()
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectStatementWithDictionaryBinding() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Barbara"])
|
||||
|
||||
// The tested function:
|
||||
let statement = db.selectStatement("SELECT * FROM persons WHERE name = :name", bindings: ["name": "Arthur"])
|
||||
|
||||
let rows = statement.fetchAllRows()
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testRowValueAtIndex() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Barbara"])
|
||||
|
||||
var names: [String?] = []
|
||||
var ages: [Int?] = []
|
||||
let rows = db.fetchRows("SELECT * FROM persons ORDER BY name")
|
||||
for row in rows {
|
||||
// The tested function:
|
||||
let name: String? = row.value(atIndex: 0)
|
||||
let age: Int? = row.value(atIndex: 1)
|
||||
names.append(name)
|
||||
ages.append(age)
|
||||
}
|
||||
|
||||
XCTAssertEqual(names[0]!, "Arthur")
|
||||
XCTAssertEqual(names[1]!, "Barbara")
|
||||
XCTAssertEqual(ages[0]!, 41)
|
||||
XCTAssertNil(ages[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testRowValueNamed() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Barbara"])
|
||||
|
||||
var names: [String?] = []
|
||||
var ages: [Int?] = []
|
||||
let rows = db.fetchRows("SELECT * FROM persons ORDER BY name")
|
||||
for row in rows {
|
||||
// The tested function:
|
||||
let name: String? = row.value(named: "name")
|
||||
let age: Int? = row.value(named: "age")
|
||||
names.append(name)
|
||||
ages.append(age)
|
||||
}
|
||||
|
||||
XCTAssertEqual(names[0]!, "Arthur")
|
||||
XCTAssertEqual(names[1]!, "Barbara")
|
||||
XCTAssertEqual(ages[0]!, 41)
|
||||
XCTAssertNil(ages[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testRowSequenceCanBeIteratedIndependentlyFromSQLiteStatement() {
|
||||
assertNoError {
|
||||
var rows: [Row] = []
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT, age INT)")
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (:name, :age)", bindings: ["name": "Barbara"])
|
||||
|
||||
rows = Array(db.fetchRows("SELECT * FROM persons ORDER BY name"))
|
||||
return .Commit
|
||||
}
|
||||
|
||||
var names: [String?] = []
|
||||
var ages: [Int?] = []
|
||||
|
||||
for row in rows {
|
||||
let name: String? = row.value(named: "name")
|
||||
let age: Int? = row.value(named: "age")
|
||||
names.append(name)
|
||||
ages.append(age)
|
||||
}
|
||||
|
||||
XCTAssertEqual(names[0]!, "Arthur")
|
||||
XCTAssertEqual(names[1]!, "Barbara")
|
||||
XCTAssertEqual(ages[0]!, 41)
|
||||
XCTAssertNil(ages[1])
|
||||
}
|
||||
}
|
||||
|
||||
func testRowSequenceCanBeIteratedTwice() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT)")
|
||||
try db.execute("INSERT INTO persons (name) VALUES (:name)", bindings: ["name": "Arthur"])
|
||||
try db.execute("INSERT INTO persons (name) VALUES (:name)", bindings: ["name": "Barbara"])
|
||||
|
||||
let rows = db.fetchRows("SELECT * FROM persons ORDER BY name")
|
||||
var names1: [String?] = rows.map { $0.value(named: "name") as String? }
|
||||
var names2: [String?] = rows.map { $0.value(named: "name") as String? }
|
||||
|
||||
XCTAssertEqual(names1[0]!, "Arthur")
|
||||
XCTAssertEqual(names1[1]!, "Barbara")
|
||||
XCTAssertEqual(names2[0]!, "Arthur")
|
||||
XCTAssertEqual(names2[1]!, "Barbara")
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testValueSequenceCanBeIteratedTwice() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT)")
|
||||
try db.execute("INSERT INTO persons (name) VALUES (:name)", bindings: ["name": "Arthur"])
|
||||
try db.execute("INSERT INTO persons (name) VALUES (:name)", bindings: ["name": "Barbara"])
|
||||
|
||||
let nameSequence = db.fetch(String.self, "SELECT name FROM persons ORDER BY name")
|
||||
var names1: [String?] = Array(nameSequence).map { $0 }
|
||||
var names2: [String?] = Array(nameSequence).map { $0 }
|
||||
|
||||
XCTAssertEqual(names1[0]!, "Arthur")
|
||||
XCTAssertEqual(names1[1]!, "Barbara")
|
||||
XCTAssertEqual(names2[0]!, "Arthur")
|
||||
XCTAssertEqual(names2[1]!, "Barbara")
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testREADME() {
|
||||
assertNoError {
|
||||
// DatabaseMigrator sets up migrations:
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"name TEXT, " +
|
||||
"age INT" +
|
||||
")")
|
||||
}
|
||||
migrator.registerMigration("createPets") { db in
|
||||
// Support for foreign keys is enabled by default:
|
||||
try db.execute(
|
||||
"CREATE TABLE pets (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"masterID INTEGER NOT NULL " +
|
||||
" REFERENCES persons(id) " +
|
||||
" ON DELETE CASCADE ON UPDATE CASCADE, " +
|
||||
"name TEXT" +
|
||||
")")
|
||||
}
|
||||
|
||||
try migrator.migrate(dbQueue)
|
||||
|
||||
|
||||
// Transactions:
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute(
|
||||
"INSERT INTO persons (name, age) VALUES (?, ?)",
|
||||
bindings: ["Arthur", 36])
|
||||
|
||||
try db.execute(
|
||||
"INSERT INTO persons (name, age) VALUES (:name, :age)",
|
||||
bindings: ["name": "Barbara", "age": 37])
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
|
||||
// Fetching rows and values:
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
for row in db.fetchRows("SELECT * FROM persons") {
|
||||
// Leverage Swift type inference
|
||||
let name: String? = row.value(atIndex: 1)
|
||||
|
||||
// Force unwrap when column is NOT NULL
|
||||
let id: Int64 = row.value(named: "id")!
|
||||
|
||||
// Both Int and Int64 are supported
|
||||
let age: Int? = row.value(named: "age")
|
||||
|
||||
print("id: \(id), name: \(name), age: \(age)")
|
||||
}
|
||||
|
||||
// Value sequences require explicit `type` parameter
|
||||
for name in db.fetch(String.self, "SELECT name FROM persons") {
|
||||
// name is `String?` because some rows may have a NULL name.
|
||||
print(name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Extracting values out of a database block:
|
||||
|
||||
let names = dbQueue.inDatabase { db in
|
||||
db.fetch(String.self, "SELECT name FROM persons ORDER BY name").map { $0! }
|
||||
}
|
||||
XCTAssertEqual(names, ["Arthur", "Barbara"])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class InMemoryDatabaseTests : GRDBTestCase
|
||||
{
|
||||
func testInMemoryDatabase() {
|
||||
assertNoError {
|
||||
let dbQueue = DatabaseQueue()
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("CREATE TABLE foo (bar TEXT)")
|
||||
try db.execute("INSERT INTO foo (bar) VALUES ('baz')")
|
||||
let baz = db.fetchOne(String.self, "SELECT bar FROM foo")!
|
||||
XCTAssertEqual(baz, "baz")
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class DatabaseMigratorTests : GRDBTestCase {
|
||||
|
||||
func testMigrator() {
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"name TEXT" +
|
||||
")")
|
||||
}
|
||||
migrator.registerMigration("createPets") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE pets (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"masterID INTEGER NOT NULL " +
|
||||
" REFERENCES persons(id) " +
|
||||
" ON DELETE CASCADE ON UPDATE CASCADE, " +
|
||||
"name TEXT" +
|
||||
")")
|
||||
}
|
||||
|
||||
assertNoError {
|
||||
try migrator.migrate(dbQueue)
|
||||
dbQueue.inDatabase { db in
|
||||
XCTAssertTrue(db.tableExists("persons"))
|
||||
XCTAssertTrue(db.tableExists("pets"))
|
||||
}
|
||||
}
|
||||
|
||||
migrator.registerMigration("destroyPersons") { db in
|
||||
try db.execute("DROP TABLE pets")
|
||||
}
|
||||
|
||||
assertNoError {
|
||||
try migrator.migrate(dbQueue)
|
||||
dbQueue.inDatabase { db in
|
||||
XCTAssertTrue(db.tableExists("persons"))
|
||||
XCTAssertFalse(db.tableExists("pets"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testMigrationFailureTriggersRollback() {
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute("CREATE TABLE persons (name TEXT)")
|
||||
try db.execute("INSERT INTO persons (name) VALUES ('Arthur')")
|
||||
}
|
||||
migrator.registerMigration("destroyPersonErroneous") { db in
|
||||
try db.execute("DELETE FROM persons")
|
||||
try db.execute("I like cookies.")
|
||||
}
|
||||
|
||||
do {
|
||||
try migrator.migrate(dbQueue)
|
||||
} catch {
|
||||
// The first migration should be committed.
|
||||
// The second migration should be rollbacked.
|
||||
let names = dbQueue.inDatabase { db in
|
||||
db.fetch(String.self, "SELECT * FROM persons").map { $0! }
|
||||
}
|
||||
XCTAssertEqual(names, ["Arthur"])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
struct DBDate: DatabaseValueConvertible {
|
||||
|
||||
// MARK: - DBDate <-> NSDate conversion
|
||||
|
||||
let date: NSDate
|
||||
|
||||
// Define a failable initializer in order to consistently use nil as the
|
||||
// NULL marker throughout the conversions NSDate <-> DBDate <-> Database
|
||||
init?(_ date: NSDate?) {
|
||||
if let date = date {
|
||||
self.date = date
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - DBDate <-> DatabaseValue conversion
|
||||
|
||||
var databaseValue: DatabaseValue {
|
||||
return .Real(date.timeIntervalSince1970)
|
||||
}
|
||||
|
||||
init?(databaseValue: DatabaseValue) {
|
||||
// Don't handle the raw DatabaseValue unless you know what you do.
|
||||
// It is recommended to use GRDB built-in conversions instead:
|
||||
if let timestamp = Double(databaseValue: databaseValue) {
|
||||
self.init(NSDate(timeIntervalSince1970: timestamp))
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GRDBTestCase: XCTestCase {
|
||||
var databasePath: String!
|
||||
var dbQueue: DatabaseQueue!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
self.databasePath = "/tmp/GRDB.sqlite"
|
||||
do { try NSFileManager.defaultManager().removeItemAtPath(databasePath) } catch { }
|
||||
let configuration = Configuration(trace: Configuration.logSQL)
|
||||
self.dbQueue = try! DatabaseQueue(path: databasePath, configuration: configuration)
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
super.tearDown()
|
||||
|
||||
self.dbQueue = nil
|
||||
try! NSFileManager.defaultManager().removeItemAtPath(databasePath)
|
||||
}
|
||||
|
||||
func assertNoError(@noescape test: (Void) throws -> Void) {
|
||||
do {
|
||||
try test()
|
||||
} catch let error as DatabaseError {
|
||||
XCTFail(error.description)
|
||||
} catch let error as RowModelError {
|
||||
XCTFail(error.description)
|
||||
} catch {
|
||||
XCTFail("error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class RowTests: GRDBTestCase {
|
||||
|
||||
func testRowAsSequence() {
|
||||
assertNoError {
|
||||
let dbQueue = DatabaseQueue()
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("CREATE TABLE texts (a TEXT, b TEXT, c TEXT)")
|
||||
try db.execute("INSERT INTO texts (a,b,c) VALUES ('foo', 'bar', 'baz')")
|
||||
let row = db.fetchOneRow("SELECT * FROM texts")!
|
||||
|
||||
var columnNames = [String]()
|
||||
var texts = [String]()
|
||||
for (columnName, databaseValue) in row {
|
||||
columnNames.append(columnName)
|
||||
texts.append(databaseValue.value()! as String)
|
||||
}
|
||||
|
||||
XCTAssertEqual(columnNames, ["a", "b", "c"])
|
||||
XCTAssertEqual(texts, ["foo", "bar", "baz"])
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class Citizenship: RowModel {
|
||||
var personID: Int64?
|
||||
var countryName: String?
|
||||
var grantedDate: NSDate?
|
||||
var native: Bool?
|
||||
|
||||
override class var databaseTable: Table? {
|
||||
return Table(named: "citizenships", primaryKey: .Columns(["personID", "countryName"]))
|
||||
}
|
||||
|
||||
override var storedDatabaseDictionary: [String: DatabaseValueConvertible?] {
|
||||
return [
|
||||
"personID": personID,
|
||||
"countryName": countryName,
|
||||
"grantedTimestamp": DBDate(grantedDate),
|
||||
"native": native]
|
||||
}
|
||||
|
||||
override func setDatabaseValue(dbv: DatabaseValue, forColumn column: String) {
|
||||
switch column {
|
||||
case "personID": personID = dbv.value()
|
||||
case "countryName": countryName = dbv.value()
|
||||
case "grantedTimestamp": grantedDate = (dbv.value() as DBDate?)?.date
|
||||
case "native": native = dbv.value()
|
||||
default: super.setDatabaseValue(dbv, forColumn: column)
|
||||
}
|
||||
}
|
||||
|
||||
static func setupInDatabase(db: Database) throws {
|
||||
try db.execute(
|
||||
"CREATE TABLE citizenships (" +
|
||||
"personID INTEGER NOT NULL " +
|
||||
" REFERENCES persons(ID) " +
|
||||
" ON DELETE CASCADE ON UPDATE CASCADE, " +
|
||||
"countryName TEXT NOT NULL, " +
|
||||
"grantedTimestamp DOUBLE, " +
|
||||
"native BOOLEAN, " +
|
||||
"PRIMARY KEY (personID, countryName)" +
|
||||
")")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PrimaryKeyMultipleTests: RowModelTestCase {
|
||||
|
||||
func testInsert() {
|
||||
// Models with Multiple primary key should be able to be inserted when
|
||||
// their primary key is set.
|
||||
|
||||
assertNoError {
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
|
||||
let dateComponents = NSDateComponents()
|
||||
dateComponents.year = 1973
|
||||
dateComponents.month = 09
|
||||
dateComponents.day = 18
|
||||
let date = calendar.dateFromComponents(dateComponents)!
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try arthur.insert(db)
|
||||
return .Commit
|
||||
}
|
||||
|
||||
let citizenship = Citizenship()
|
||||
citizenship.personID = arthur.id
|
||||
citizenship.countryName = "France"
|
||||
citizenship.grantedDate = date
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
// The tested method
|
||||
try citizenship.insert(db)
|
||||
|
||||
// After insertion, primary key is still set
|
||||
XCTAssertEqual(citizenship.personID!, arthur.id!)
|
||||
XCTAssertEqual(citizenship.countryName!, "France")
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
// After insertion, model should be present in the database
|
||||
dbQueue.inDatabase { db in
|
||||
let citizenships = db.fetchAll(Citizenship.self, "SELECT * FROM citizenships")
|
||||
XCTAssertEqual(citizenships.count, 1)
|
||||
XCTAssertEqual(citizenships.first!.personID!, arthur.id!)
|
||||
XCTAssertEqual(citizenships.first!.countryName!, "France")
|
||||
XCTAssertEqual(calendar.component(NSCalendarUnit.Year, fromDate: citizenships.first!.grantedDate!), 1973)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testInsertTwice() {
|
||||
assertNoError {
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try arthur.insert(db)
|
||||
return .Commit
|
||||
}
|
||||
|
||||
let citizenship = Citizenship()
|
||||
citizenship.personID = arthur.id
|
||||
citizenship.countryName = "France"
|
||||
|
||||
do {
|
||||
try dbQueue.inTransaction { db in
|
||||
// The tested method
|
||||
try citizenship.insert(db)
|
||||
try citizenship.insert(db)
|
||||
|
||||
return .Commit
|
||||
}
|
||||
XCTFail("Expected error")
|
||||
} catch is DatabaseError {
|
||||
// OK, this is expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdate() {
|
||||
assertNoError {
|
||||
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
|
||||
let dateComponents = NSDateComponents()
|
||||
dateComponents.year = 1973
|
||||
dateComponents.month = 09
|
||||
dateComponents.day = 18
|
||||
let date1 = calendar.dateFromComponents(dateComponents)!
|
||||
dateComponents.year = 2000
|
||||
let date2 = calendar.dateFromComponents(dateComponents)!
|
||||
XCTAssertFalse(date1.isEqualToDate(date2))
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
var citizenship = Citizenship()
|
||||
citizenship.personID = arthur.id
|
||||
citizenship.countryName = "France"
|
||||
citizenship.grantedDate = date1
|
||||
try citizenship.insert(db)
|
||||
|
||||
citizenship.grantedDate = date2
|
||||
try citizenship.update(db) // object still in database
|
||||
|
||||
citizenship = db.fetchOne(Citizenship.self, "SELECT * FROM citizenships WHERE personID = ? AND countryName = ?", bindings: [citizenship.personID, citizenship.countryName])!
|
||||
XCTAssertEqual(citizenship.countryName!, "France")
|
||||
XCTAssertEqual(calendar.component(NSCalendarUnit.Year, fromDate: citizenship.grantedDate!), 2000)
|
||||
|
||||
do {
|
||||
try citizenship.delete(db)
|
||||
try citizenship.update(db) // object no longer in database
|
||||
XCTFail("Expected RowModelError.RowModelNotFound")
|
||||
} catch RowModelError.RowModelNotFound {
|
||||
} catch {
|
||||
XCTFail("Expected RowModelError.RowModelNotFound, not \(error)")
|
||||
}
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectWithKey() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
var citizenship = Citizenship()
|
||||
citizenship.personID = arthur.id
|
||||
citizenship.countryName = "France"
|
||||
try citizenship.insert(db)
|
||||
|
||||
citizenship = db.fetchOne(Citizenship.self, key: ["countryName": "France", "personID": arthur.id])!
|
||||
XCTAssertEqual(citizenship.countryName!, "France")
|
||||
XCTAssertEqual(citizenship.personID!, arthur.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDelete() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
let citizenship1 = Citizenship()
|
||||
citizenship1.personID = arthur.id
|
||||
citizenship1.countryName = "France"
|
||||
try citizenship1.insert(db)
|
||||
|
||||
let citizenship2 = Citizenship()
|
||||
citizenship2.personID = arthur.id
|
||||
citizenship2.countryName = "Spain"
|
||||
try citizenship2.insert(db)
|
||||
|
||||
try citizenship1.delete(db) // The tested method
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let citizenships = db.fetchAll(Citizenship.self, "SELECT * FROM citizenships")
|
||||
XCTAssertEqual(citizenships.count, 1)
|
||||
XCTAssertEqual(citizenships.first!.countryName!, "Spain")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testReload() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
let citizenship = Citizenship()
|
||||
citizenship.personID = arthur.id
|
||||
citizenship.countryName = "France"
|
||||
citizenship.native = true
|
||||
try citizenship.insert(db)
|
||||
|
||||
citizenship.native = false
|
||||
XCTAssertEqual(citizenship.native!, false)
|
||||
try citizenship.reload(db) // object still in database
|
||||
XCTAssertEqual(citizenship.native!, true)
|
||||
|
||||
try citizenship.delete(db)
|
||||
|
||||
citizenship.native = false
|
||||
XCTAssertEqual(citizenship.native!, false)
|
||||
do {
|
||||
try citizenship.reload(db) // object no longer in database
|
||||
XCTFail("Expected RowModelError.RowModelNotFound")
|
||||
} catch RowModelError.RowModelNotFound {
|
||||
} catch {
|
||||
XCTFail("Expected RowModelError.RowModelNotFound, not \(error)")
|
||||
}
|
||||
XCTAssertEqual(citizenship.native!, false)
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class Item: RowModel {
|
||||
var name: String?
|
||||
|
||||
override class var databaseTable: Table? {
|
||||
return Table(named: "items")
|
||||
}
|
||||
|
||||
override var storedDatabaseDictionary: [String: DatabaseValueConvertible?] {
|
||||
return ["name": name]
|
||||
}
|
||||
|
||||
override func setDatabaseValue(dbv: DatabaseValue, forColumn column: String) {
|
||||
switch column {
|
||||
case "name": name = dbv.value()
|
||||
default: super.setDatabaseValue(dbv, forColumn: column)
|
||||
}
|
||||
}
|
||||
|
||||
static func setupInDatabase(db: Database) throws {
|
||||
try db.execute(
|
||||
"CREATE TABLE items (" +
|
||||
"name NOT NULL" +
|
||||
")")
|
||||
}
|
||||
}
|
||||
|
||||
class PrimaryKeyNoneTests: RowModelTestCase {
|
||||
|
||||
func testInsert() {
|
||||
// Models with None primary key should be able to be inserted.
|
||||
|
||||
assertNoError {
|
||||
let item = Item()
|
||||
item.name = "foo"
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
// The tested method
|
||||
try item.insert(db)
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
// After insertion, model should be present in the database
|
||||
dbQueue.inDatabase { db in
|
||||
let items = db.fetchAll(Item.self, "SELECT * FROM items ORDER BY name")
|
||||
XCTAssertEqual(items.count, 1)
|
||||
XCTAssertEqual(items.first!.name!, "foo")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testInsertTwice() {
|
||||
// Models with None primary key should be able to be inserted.
|
||||
//
|
||||
// The second insertion simply inserts a second row.
|
||||
|
||||
assertNoError {
|
||||
let item = Item()
|
||||
item.name = "foo"
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
// The tested method
|
||||
try item.insert(db)
|
||||
try item.insert(db)
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
// After insertion, model should be present in the database
|
||||
dbQueue.inDatabase { db in
|
||||
let items = db.fetchAll(Item.self, "SELECT * FROM items ORDER BY name")
|
||||
XCTAssertEqual(items.count, 2)
|
||||
XCTAssertEqual(items.first!.name!, "foo")
|
||||
XCTAssertEqual(items.last!.name!, "foo")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectWithKey() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
var item = Item()
|
||||
item.name = "foo"
|
||||
try item.insert(db)
|
||||
|
||||
item = db.fetchOne(Item.self, key: ["name": "foo"])!
|
||||
XCTAssertEqual(item.name!, "foo")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,304 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class Person: RowModel {
|
||||
var id: Int64!
|
||||
var name: String!
|
||||
var age: Int!
|
||||
var creationDate: NSDate!
|
||||
|
||||
override class var databaseTable: Table? {
|
||||
return Table(named: "persons", primaryKey: .RowID("id"))
|
||||
}
|
||||
|
||||
override var storedDatabaseDictionary: [String: DatabaseValueConvertible?] {
|
||||
return [
|
||||
"id": id,
|
||||
"name": name,
|
||||
"age": age,
|
||||
"creationTimestamp": DBDate(creationDate),
|
||||
]
|
||||
}
|
||||
|
||||
override func setDatabaseValue(dbv: DatabaseValue, forColumn column: String) {
|
||||
switch column {
|
||||
case "id": id = dbv.value()
|
||||
case "name": name = dbv.value()
|
||||
case "age": age = dbv.value()
|
||||
case "creationTimestamp": creationDate = (dbv.value() as DBDate?)?.date
|
||||
default: super.setDatabaseValue(dbv, forColumn: column)
|
||||
}
|
||||
}
|
||||
|
||||
override func insert(db: Database, conflictResolution: ConflictResolution? = nil) throws {
|
||||
// TODO: test
|
||||
if creationDate == nil {
|
||||
creationDate = NSDate()
|
||||
}
|
||||
|
||||
try super.insert(db, conflictResolution: conflictResolution)
|
||||
}
|
||||
|
||||
init (name: String? = nil, age: Int? = nil) {
|
||||
self.name = name
|
||||
self.age = age
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init(row: Row) {
|
||||
super.init(row: row)
|
||||
}
|
||||
|
||||
static func setupInDatabase(db: Database) throws {
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"creationTimestamp DOUBLE, " +
|
||||
"name TEXT NOT NULL, " +
|
||||
"age INT" +
|
||||
")")
|
||||
}
|
||||
}
|
||||
|
||||
class PrimaryKeyRowIDTests: RowModelTestCase {
|
||||
|
||||
func testInsert() {
|
||||
// Models with RowID primary key should be able to be inserted with a
|
||||
// nil primary key. After the insertion, they have their primary key
|
||||
// set.
|
||||
|
||||
assertNoError {
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
|
||||
XCTAssertTrue(arthur.id == nil)
|
||||
try dbQueue.inTransaction { db in
|
||||
// The tested method
|
||||
try arthur.insert(db)
|
||||
|
||||
// After insertion, ID should be set
|
||||
XCTAssertTrue(arthur.id != nil)
|
||||
|
||||
// After insertion, creationDate should be set
|
||||
XCTAssertTrue(arthur.creationDate != nil)
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
// After insertion, model should be present in the database
|
||||
dbQueue.inDatabase { db in
|
||||
let persons = db.fetchAll(Person.self, "SELECT * FROM persons ORDER BY name")
|
||||
XCTAssertEqual(persons.count, 1)
|
||||
let person = persons.first!
|
||||
XCTAssertEqual(person.name!, "Arthur")
|
||||
XCTAssertEqual(person.age!, 41)
|
||||
XCTAssertTrue(abs(person.creationDate!.timeIntervalSinceDate(NSDate())) < 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testInsertTwice() {
|
||||
// Models with RowID primary key should be able to be inserted with a
|
||||
// nil primary key. After the insertion, they have their primary key
|
||||
// set.
|
||||
//
|
||||
// The second insertion should fail because the primary key is already
|
||||
// taken.
|
||||
|
||||
assertNoError {
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
|
||||
XCTAssertTrue(arthur.id == nil)
|
||||
do {
|
||||
try dbQueue.inTransaction { db in
|
||||
try arthur.insert(db)
|
||||
try arthur.insert(db)
|
||||
return .Commit
|
||||
}
|
||||
XCTFail("Expected error")
|
||||
} catch is DatabaseError {
|
||||
// OK, this is expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdate() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
var arthur = Person(name: "Arthur", age: 41)
|
||||
XCTAssertTrue(arthur.id == nil)
|
||||
|
||||
try arthur.insert(db)
|
||||
|
||||
arthur.age = 42
|
||||
try arthur.update(db) // object still in database
|
||||
|
||||
arthur = db.fetchOne(Person.self, primaryKey: arthur.id)!
|
||||
XCTAssertEqual(arthur.age, 42)
|
||||
|
||||
do {
|
||||
try arthur.delete(db)
|
||||
try arthur.update(db) // object no longer in database
|
||||
XCTFail("Expected RowModelError.RowModelNotFound")
|
||||
} catch RowModelError.RowModelNotFound {
|
||||
} catch {
|
||||
XCTFail("Expected RowModelError.RowModelNotFound, not \(error)")
|
||||
}
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSave() {
|
||||
assertNoError {
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
|
||||
XCTAssertTrue(arthur.id == nil)
|
||||
try dbQueue.inTransaction { db in
|
||||
try arthur.save(db) // insert
|
||||
return .Commit
|
||||
}
|
||||
XCTAssertTrue(arthur.id != nil)
|
||||
arthur.age = 18
|
||||
try dbQueue.inTransaction { db in
|
||||
try arthur.save(db) // update
|
||||
return .Commit
|
||||
}
|
||||
|
||||
try dbQueue.inDatabase{ db in
|
||||
let arthur2 = db.fetchOne(Person.self, primaryKey: arthur.id!)!
|
||||
XCTAssertEqual(arthur2.age!, 18)
|
||||
|
||||
try arthur2.delete(db)
|
||||
do {
|
||||
try arthur.save(db) // object no longer in database
|
||||
XCTFail("Expected RowModelError.RowModelNotFound")
|
||||
} catch RowModelError.RowModelNotFound {
|
||||
} catch {
|
||||
XCTFail("Expected RowModelError.RowModelNotFound, not \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectWithPrimaryKey() {
|
||||
assertNoError {
|
||||
var arthurID: Int64? = nil
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
arthurID = arthur.id
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let arthur = db.fetchOne(Person.self, primaryKey: arthurID!)! // The tested method
|
||||
|
||||
XCTAssertEqual(arthur.id!, arthurID!)
|
||||
XCTAssertEqual(arthur.name!, "Arthur")
|
||||
XCTAssertEqual(arthur.age!, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectWithKey() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
var person = Person(name: "Arthur", age: 41)
|
||||
try person.insert(db)
|
||||
let personID = person.id
|
||||
|
||||
person = db.fetchOne(Person.self, key: ["name": "Arthur"])! // The tested method
|
||||
XCTAssertEqual(person.id!, personID!)
|
||||
XCTAssertEqual(person.name!, "Arthur")
|
||||
XCTAssertEqual(person.age!, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: make this code nicer
|
||||
func testSelectWithMultiplePrimaryKeys() {
|
||||
assertNoError {
|
||||
dbQueue.inDatabase { db in
|
||||
let ids = [1,2,3]
|
||||
let questionMarks = ",".join(Array(count: ids.count, repeatedValue: "?"))
|
||||
db.fetchAll(Person.self, "SELECT * FROM persons WHERE id IN (\(questionMarks))", bindings: Bindings(ids))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDelete() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur")
|
||||
try arthur.insert(db)
|
||||
|
||||
let barbara = Person(name: "Barbara")
|
||||
try barbara.insert(db)
|
||||
|
||||
try arthur.delete(db) // The tested method
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let persons = db.fetchAll(Person.self, "SELECT * FROM persons ORDER BY name")
|
||||
XCTAssertEqual(persons.count, 1)
|
||||
XCTAssertEqual(persons.first!.name!, "Barbara")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testReload() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur")
|
||||
try arthur.insert(db)
|
||||
|
||||
arthur.name = "Bobby"
|
||||
XCTAssertEqual(arthur.name!, "Bobby")
|
||||
try arthur.reload(db) // object still in database
|
||||
XCTAssertEqual(arthur.name!, "Arthur")
|
||||
|
||||
try arthur.delete(db)
|
||||
|
||||
arthur.name = "Bobby"
|
||||
XCTAssertEqual(arthur.name!, "Bobby")
|
||||
do {
|
||||
try arthur.reload(db) // object no longer in database
|
||||
XCTFail("Expected RowModelError.RowModelNotFound")
|
||||
} catch RowModelError.RowModelNotFound {
|
||||
} catch {
|
||||
XCTFail("Expected RowModelError.RowModelNotFound, not \(error)")
|
||||
}
|
||||
XCTAssertEqual(arthur.name!, "Bobby")
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class Pet: RowModel {
|
||||
var UUID: String?
|
||||
var masterID: Int64?
|
||||
var name: String?
|
||||
|
||||
override class var databaseTable: Table? {
|
||||
return Table(named: "pets", primaryKey: .Column("UUID"))
|
||||
}
|
||||
|
||||
override var storedDatabaseDictionary: [String: DatabaseValueConvertible?] {
|
||||
return [
|
||||
"UUID": UUID,
|
||||
"name": name,
|
||||
"masterID": masterID]
|
||||
}
|
||||
|
||||
override func setDatabaseValue(dbv: DatabaseValue, forColumn column: String) {
|
||||
switch column {
|
||||
case "UUID": UUID = dbv.value()
|
||||
case "name": name = dbv.value()
|
||||
case "masterID": masterID = dbv.value()
|
||||
default: super.setDatabaseValue(dbv, forColumn: column)
|
||||
}
|
||||
}
|
||||
|
||||
init (UUID: String? = nil, name: String? = nil, masterID: Int64? = nil) {
|
||||
self.UUID = UUID
|
||||
self.name = name
|
||||
self.masterID = masterID
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init(row: Row) {
|
||||
super.init(row: row)
|
||||
}
|
||||
|
||||
static func setupInDatabase(db: Database) throws {
|
||||
try db.execute(
|
||||
"CREATE TABLE pets (" +
|
||||
"UUID TEXT NOT NULL PRIMARY KEY, " +
|
||||
"masterID INTEGER NOT NULL " +
|
||||
" REFERENCES persons(ID) " +
|
||||
" ON DELETE CASCADE ON UPDATE CASCADE, " +
|
||||
"name TEXT" +
|
||||
")")
|
||||
}
|
||||
}
|
||||
|
||||
class PrimaryKeySingleTests: RowModelTestCase {
|
||||
|
||||
func testInsertWithNonNilPrimaryKey() {
|
||||
// Models with Single primary key should be able to be inserted when
|
||||
// their primary key is not nil.
|
||||
|
||||
assertNoError {
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try arthur.insert(db)
|
||||
return .Commit
|
||||
}
|
||||
|
||||
let pet = Pet(UUID: "BobbyID", name: "Bobby", masterID: arthur.id)
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
// The tested method
|
||||
try pet.insert(db)
|
||||
|
||||
// After insertion, primary key is still set
|
||||
XCTAssertEqual(pet.UUID!, "BobbyID")
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
// After insertion, model should be present in the database
|
||||
dbQueue.inDatabase { db in
|
||||
let pets = db.fetchAll(Pet.self, "SELECT * FROM pets ORDER BY name")
|
||||
XCTAssertEqual(pets.count, 1)
|
||||
XCTAssertEqual(pets.first!.UUID!, "BobbyID")
|
||||
XCTAssertEqual(pets.first!.name!, "Bobby")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testInsertWithNilPrimaryKey() {
|
||||
// Models with Single primary key should not be able to be inserted when
|
||||
// their primary key is nil.
|
||||
|
||||
assertNoError {
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try arthur.insert(db)
|
||||
return .Commit
|
||||
}
|
||||
|
||||
let pet = Pet(name: "Bobby", masterID: arthur.id)
|
||||
|
||||
do {
|
||||
try dbQueue.inTransaction { db in
|
||||
// The tested method
|
||||
try pet.insert(db)
|
||||
return .Commit
|
||||
}
|
||||
XCTFail("Expected error")
|
||||
} catch is DatabaseError {
|
||||
// OK, this is expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testInsertTwice() {
|
||||
// Models with Single primary key should be able to be inserted when
|
||||
// their primary key is not nil.
|
||||
//
|
||||
// The second insertion should fail because the primary key is already
|
||||
// taken.
|
||||
|
||||
assertNoError {
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try arthur.insert(db)
|
||||
return .Commit
|
||||
}
|
||||
|
||||
let pet = Pet(UUID: "BobbyID", name: "Bobby", masterID: arthur.id)
|
||||
|
||||
do {
|
||||
try dbQueue.inTransaction { db in
|
||||
// The tested method
|
||||
try pet.insert(db)
|
||||
try pet.insert(db)
|
||||
|
||||
return .Commit
|
||||
}
|
||||
XCTFail("Expected error")
|
||||
} catch is DatabaseError {
|
||||
// OK, this is expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdate() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
var pet = Pet(UUID: "BobbyID", name: "Bobby", masterID: arthur.id)
|
||||
try pet.insert(db)
|
||||
|
||||
pet.name = "Karl"
|
||||
try pet.update(db) // object still in database
|
||||
|
||||
pet = db.fetchOne(Pet.self, primaryKey: pet.UUID!)!
|
||||
XCTAssertEqual(pet.name!, "Karl")
|
||||
|
||||
do {
|
||||
try pet.delete(db)
|
||||
try pet.update(db) // object no longer in database
|
||||
XCTFail("Expected RowModelError.RowModelNotFound")
|
||||
} catch RowModelError.RowModelNotFound {
|
||||
} catch {
|
||||
XCTFail("Expected RowModelError.RowModelNotFound, not \(error)")
|
||||
}
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectWithPrimaryKey() {
|
||||
assertNoError {
|
||||
let petUUID = "BobbyID"
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
let pet = Pet(UUID: "BobbyID", name: "Bobby", masterID: arthur.id)
|
||||
try pet.insert(db)
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let pet = db.fetchOne(Pet.self, primaryKey: petUUID)! // The tested method
|
||||
|
||||
XCTAssertEqual(pet.UUID!, petUUID)
|
||||
XCTAssertEqual(pet.name!, "Bobby")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectWithKey() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
let uuid = "BobbyID"
|
||||
var pet = Pet(UUID: uuid, name: "Bobby", masterID: arthur.id)
|
||||
try pet.insert(db)
|
||||
|
||||
pet = db.fetchOne(Pet.self, key: ["name": "Bobby"])! // The tested method
|
||||
XCTAssertEqual(pet.UUID!, uuid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDelete() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
let bobby = Pet(UUID: "BobbyID", name: "Bobby", masterID: arthur.id)
|
||||
try bobby.insert(db)
|
||||
|
||||
let karl = Pet(UUID: "KarlID", name: "Karl", masterID: arthur.id)
|
||||
try karl.insert(db)
|
||||
|
||||
try bobby.delete(db) // The tested method
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let pets = db.fetchAll(Pet.self, "SELECT * FROM pets ORDER BY name")
|
||||
XCTAssertEqual(pets.count, 1)
|
||||
XCTAssertEqual(pets.first!.name!, "Karl")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testReload() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
let arthur = Person(name: "Arthur", age: 41)
|
||||
try arthur.insert(db)
|
||||
|
||||
let bobby = Pet(UUID: "BobbyID", name: "Bobby", masterID: arthur.id)
|
||||
try bobby.insert(db)
|
||||
|
||||
bobby.name = "Karl"
|
||||
XCTAssertEqual(bobby.name!, "Karl")
|
||||
try bobby.reload(db) // object still in database
|
||||
XCTAssertEqual(bobby.name!, "Bobby")
|
||||
|
||||
try bobby.delete(db)
|
||||
|
||||
bobby.name = "Karl"
|
||||
XCTAssertEqual(bobby.name!, "Karl")
|
||||
do {
|
||||
try bobby.reload(db) // object no longer in database
|
||||
XCTFail("Expected RowModelError.RowModelNotFound")
|
||||
} catch RowModelError.RowModelNotFound {
|
||||
} catch {
|
||||
XCTFail("Expected RowModelError.RowModelNotFound, not \(error)")
|
||||
}
|
||||
XCTAssertEqual(bobby.name!, "Karl")
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class EmptyRowModel : RowModel {
|
||||
}
|
||||
|
||||
class SingleColumnRowModel : RowModel {
|
||||
var name: String?
|
||||
|
||||
override var storedDatabaseDictionary: [String: DatabaseValueConvertible?] {
|
||||
return ["name": name]
|
||||
}
|
||||
}
|
||||
|
||||
class DoubleColumnRowModel : RowModel {
|
||||
var name: String?
|
||||
var age: Int?
|
||||
|
||||
override var storedDatabaseDictionary: [String: DatabaseValueConvertible?] {
|
||||
return ["name": name, "age": age]
|
||||
}
|
||||
}
|
||||
|
||||
class RowModelDescriptionTests: RowModelTestCase {
|
||||
|
||||
func testEmptyRowModelDescription() {
|
||||
let model = EmptyRowModel()
|
||||
XCTAssertEqual(model.description, "<GRDBTests.EmptyRowModel>")
|
||||
}
|
||||
|
||||
func testSimpleRowModelDescription() {
|
||||
let model = SingleColumnRowModel()
|
||||
model.name = "foo"
|
||||
XCTAssertEqual(model.description, "<GRDBTests.SingleColumnRowModel name:\"foo\">")
|
||||
}
|
||||
|
||||
func testDoubleColumnRowModelDescription() {
|
||||
let model = DoubleColumnRowModel()
|
||||
model.name = "foo"
|
||||
model.age = 35
|
||||
XCTAssertTrue(["<GRDBTests.DoubleColumnRowModel name:\"foo\" age:35>", "<GRDBTests.DoubleColumnRowModel age:35 name:\"foo\">"].indexOf(model.description) != nil)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
|
||||
class RowModelFetchTests: RowModelTestCase {
|
||||
|
||||
func testSelectStatement() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
try Person(name: "Arthur", age: 41).insert(db)
|
||||
try Person(name: "Barbara", age: 37).insert(db)
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let statement = db.selectStatement("SELECT * FROM persons WHERE name = ?")
|
||||
|
||||
for name in ["Arthur", "Barbara"] {
|
||||
let person = statement.fetchOne(Person.self, bindings: [name])!
|
||||
XCTAssertEqual(person.name!, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDatabaseRowModelSequenceCanBeIteratedTwice() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
try Person(name: "Arthur", age: 41).insert(db)
|
||||
try Person(name: "Barbara", age: 37).insert(db)
|
||||
|
||||
let personSequence = db.fetch(Person.self, "SELECT * FROM persons ORDER BY name")
|
||||
var names1: [String?] = personSequence.map { $0.name }
|
||||
var names2: [String?] = personSequence.map { $0.name }
|
||||
|
||||
XCTAssertEqual(names1[0]!, "Arthur")
|
||||
XCTAssertEqual(names1[1]!, "Barbara")
|
||||
XCTAssertEqual(names2[0]!, "Arthur")
|
||||
XCTAssertEqual(names2[1]!, "Barbara")
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectStatementRowModelSequenceCanBeIteratedTwice() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
try Person(name: "Arthur", age: 41).insert(db)
|
||||
try Person(name: "Barbara", age: 37).insert(db)
|
||||
|
||||
let statement = db.selectStatement("SELECT * FROM persons ORDER BY name")
|
||||
let personSequence = statement.fetch(Person.self)
|
||||
var names1: [String?] = personSequence.map { $0.name }
|
||||
var names2: [String?] = personSequence.map { $0.name }
|
||||
|
||||
XCTAssertEqual(names1[0]!, "Arthur")
|
||||
XCTAssertEqual(names1[1]!, "Barbara")
|
||||
XCTAssertEqual(names2[0]!, "Arthur")
|
||||
XCTAssertEqual(names2[1]!, "Barbara")
|
||||
|
||||
return .Commit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
@testable import GRDB
|
||||
|
||||
// Tests about how minimal can class go regarding their initializers
|
||||
|
||||
// What happens for a class without property, without any initializer?
|
||||
class EmptyRowModelWithoutInitializer : RowModel {
|
||||
// nothing is required
|
||||
}
|
||||
|
||||
// What happens if we add a mutable property, still without any initializer?
|
||||
// A compiler error: class 'RowModelWithoutInitializer' has no initializers
|
||||
//
|
||||
// class RowModelWithoutInitializer : RowModel {
|
||||
// let name: String?
|
||||
// }
|
||||
|
||||
// What happens with a mutable property, and init(row: Row)?
|
||||
class RowModelWithMutablePropertyAndRowInitializer : RowModel {
|
||||
var name: String?
|
||||
|
||||
required init(row: Row) {
|
||||
super.init(row: row) // super.init(row: row) is required
|
||||
self.name = "toto" // property can be set before or after super.init
|
||||
}
|
||||
}
|
||||
|
||||
// What happens with a mutable property, and init()?
|
||||
class RowModelWithMutablePropertyAndEmptyInitializer : RowModel {
|
||||
var name: String?
|
||||
|
||||
override init() {
|
||||
super.init() // super.init() is required
|
||||
self.name = "toto" // property can be set before or after super.init
|
||||
}
|
||||
|
||||
required init(row: Row) { // init(row: row) is required
|
||||
super.init(row: row) // super.init(row: row) is required
|
||||
}
|
||||
}
|
||||
|
||||
// What happens with a mutable property, and a custom initializer()?
|
||||
class RowModelWithMutablePropertyAndCustomInitializer : RowModel {
|
||||
var name: String?
|
||||
|
||||
init(name: String? = nil) {
|
||||
self.name = name
|
||||
super.init() // super.init() is required
|
||||
}
|
||||
|
||||
required init(row: Row) { // init(row: row) is required
|
||||
super.init(row: row) // super.init(row: row) is required
|
||||
}
|
||||
}
|
||||
|
||||
// What happens with an immutable property?
|
||||
class RowModelWithImmutableProperty : RowModel {
|
||||
let initializedFromRow: Bool
|
||||
|
||||
required init(row: Row) { // An initializer is required, and the minimum is init(row: row)
|
||||
initializedFromRow = true // property must bet set before super.init(row: row)
|
||||
super.init(row: row) // super.init(row: row) is required
|
||||
}
|
||||
}
|
||||
|
||||
// What happens with an immutable property and init()?
|
||||
class RowModelWithPedigree : RowModel {
|
||||
let initializedFromRow: Bool
|
||||
|
||||
override init() {
|
||||
initializedFromRow = false // property must bet set before super.init(row: row)
|
||||
super.init() // super.init() is required
|
||||
}
|
||||
|
||||
required init(row: Row) { // An initializer is required, and the minimum is init(row: row)
|
||||
initializedFromRow = true // property must bet set before super.init(row: row)
|
||||
super.init(row: row) // super.init(row: row) is required
|
||||
}
|
||||
}
|
||||
|
||||
// What happens with an immutable property and a custom initializer()?
|
||||
class RowModelWithImmutablePropertyAndCustomInitializer : RowModel {
|
||||
let initializedFromRow: Bool
|
||||
|
||||
init(name: String? = nil) {
|
||||
initializedFromRow = false // property must bet set before super.init(row: row)
|
||||
super.init() // super.init() is required
|
||||
}
|
||||
|
||||
required init(row: Row) { // An initializer is required, and the minimum is init(row: row)
|
||||
initializedFromRow = true // property must bet set before super.init(row: row)
|
||||
super.init(row: row) // super.init(row: row) is required
|
||||
}
|
||||
}
|
||||
|
||||
class RowModelInitializersTests : RowModelTestCase {
|
||||
|
||||
func testFetchedRowModelAreInitializedFromRow() {
|
||||
|
||||
// Here we test that RowModel.init(row: Row) can be overriden independently from RowModel.init().
|
||||
// People must be able to perform some initialization work when fetching row models from the database.
|
||||
|
||||
// The basics: test the initializedFromRow property:
|
||||
XCTAssertFalse(RowModelWithPedigree().initializedFromRow)
|
||||
XCTAssertTrue(RowModelWithPedigree(row: Row(databaseDictionary: [:])).initializedFromRow)
|
||||
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE pedigrees (foo INTEGER)")
|
||||
try db.execute("INSERT INTO pedigrees (foo) VALUES (NULL)")
|
||||
|
||||
let pedigree = db.fetchOne(RowModelWithPedigree.self, "SELECT * FROM pedigrees")!
|
||||
XCTAssertTrue(pedigree.initializedFromRow) // very important
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class PersonWithPet: Person {
|
||||
var petCount: Int?
|
||||
|
||||
override func setDatabaseValue(dbv: DatabaseValue, forColumn column: String) {
|
||||
switch column {
|
||||
case "petCount": petCount = dbv.value()
|
||||
default: super.setDatabaseValue(dbv, forColumn: column)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RowModelSubClassTests: RowModelTestCase {
|
||||
|
||||
func testSelect() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
try Person(name: "Arthur", age: 41).insert(db)
|
||||
try Person(name: "Barbara", age: 36).insert(db)
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let persons = db.fetchAll(Person.self, "SELECT * FROM persons ORDER BY name")
|
||||
let arthur = db.fetchOne(Person.self, "SELECT * FROM persons ORDER BY age DESC")!
|
||||
|
||||
XCTAssertEqual(persons.map { $0.name! }, ["Arthur", "Barbara"])
|
||||
XCTAssertEqual(persons.map { $0.age! }, [41, 36])
|
||||
XCTAssertEqual(arthur.name!, "Arthur")
|
||||
XCTAssertEqual(arthur.age!, 41)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class RowModelTestCase : GRDBTestCase {
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
|
||||
migrator.registerMigration("createPersons", Person.setupInDatabase)
|
||||
migrator.registerMigration("createPets", Pet.setupInDatabase)
|
||||
migrator.registerMigration("createItems", Item.setupInDatabase)
|
||||
migrator.registerMigration("createCitizenships", Citizenship.setupInDatabase)
|
||||
|
||||
assertNoError {
|
||||
try migrator.migrate(dbQueue)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
@testable import GRDB
|
||||
|
||||
class DatabaseErrorTests: GRDBTestCase {
|
||||
|
||||
func testDatabaseErrorThrownByUpdateStatementContainSQL() {
|
||||
dbQueue.inDatabase { db in
|
||||
do {
|
||||
try db.updateStatement("BLAH")
|
||||
XCTFail()
|
||||
} catch let error as DatabaseError {
|
||||
XCTAssertEqual(error.code, 1)
|
||||
XCTAssertEqual(error.message!, "near \"BLAH\": syntax error")
|
||||
XCTAssertEqual(error.sql!, "BLAH")
|
||||
XCTAssertEqual(error.description, "SQLite error 1 with statement `BLAH`: near \"BLAH\": syntax error")
|
||||
} catch {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDatabaseErrorThrownByUpdateStatementContainSQLAndBindings() {
|
||||
dbQueue.inDatabase { db in
|
||||
do {
|
||||
try db.execute("CREATE TABLE persons (id INTEGER PRIMARY KEY)")
|
||||
try db.execute("CREATE TABLE pets (masterId INTEGER NOT NULL REFERENCES persons(id), name TEXT)")
|
||||
try db.execute("INSERT INTO pets (masterId, name) VALUES (?, ?)", bindings: [1, "Bobby"])
|
||||
XCTFail()
|
||||
} catch let error as DatabaseError {
|
||||
XCTAssertEqual(error.code, Int(SQLITE_CONSTRAINT))
|
||||
XCTAssertEqual(error.message!, "FOREIGN KEY constraint failed")
|
||||
XCTAssertEqual(error.sql!, "INSERT INTO pets (masterId, name) VALUES (?, ?)")
|
||||
XCTAssertEqual(error.description, "SQLite error 19 with statement `INSERT INTO pets (masterId, name) VALUES (?, ?)` bindings [1, \"Bobby\"]: FOREIGN KEY constraint failed")
|
||||
} catch {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDatabaseErrorThrownBySelectStatementContainSQL() {
|
||||
dbQueue.inDatabase { db in
|
||||
do {
|
||||
let _ = try SelectStatement(database: db, sql: "SELECT * FROM blah", bindings: nil, unsafe: false)
|
||||
XCTFail()
|
||||
} catch let error as DatabaseError {
|
||||
XCTAssertEqual(error.code, 1)
|
||||
XCTAssertEqual(error.message!, "no such table: blah")
|
||||
XCTAssertEqual(error.sql!, "SELECT * FROM blah")
|
||||
XCTAssertEqual(error.description, "SQLite error 1 with statement `SELECT * FROM blah`: no such table: blah")
|
||||
} catch {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class CustomDatabaseValueConvertibleTests : GRDBTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE stuffs (" +
|
||||
"ID INTEGER PRIMARY KEY, " +
|
||||
"creationTimestamp DOUBLE" +
|
||||
")")
|
||||
}
|
||||
assertNoError {
|
||||
try migrator.migrate(dbQueue)
|
||||
}
|
||||
}
|
||||
|
||||
func testDBDate() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
|
||||
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
|
||||
do {
|
||||
let dateComponents = NSDateComponents()
|
||||
dateComponents.year = 1973
|
||||
dateComponents.month = 09
|
||||
dateComponents.day = 18
|
||||
let date = calendar.dateFromComponents(dateComponents)!
|
||||
try db.execute("INSERT INTO stuffs (creationTimestamp) VALUES (?)", bindings: [DBDate(date)])
|
||||
}
|
||||
|
||||
do {
|
||||
let row = db.fetchOneRow("SELECT creationTimestamp FROM stuffs")!
|
||||
let date: DBDate = row.value(atIndex: 0)!
|
||||
let year = calendar.component(NSCalendarUnit.Year, fromDate: date.date)
|
||||
XCTAssertEqual(year, 1973)
|
||||
}
|
||||
|
||||
do {
|
||||
let date = db.fetchOne(DBDate.self, "SELECT creationTimestamp FROM stuffs")!
|
||||
let year = calendar.component(NSCalendarUnit.Year, fromDate: date.date)
|
||||
XCTAssertEqual(year, 1973)
|
||||
}
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
enum Color : Int {
|
||||
case Red
|
||||
case White
|
||||
case Rose
|
||||
}
|
||||
|
||||
enum Grape : String {
|
||||
case Chardonnay
|
||||
case Merlot
|
||||
case Riesling
|
||||
}
|
||||
|
||||
extension Color : DatabaseIntRepresentable { }
|
||||
extension Grape : DatabaseStringRepresentable { }
|
||||
|
||||
class RawRepresentableTests: GRDBTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute("CREATE TABLE wines (grape TEXT, color INTEGER)")
|
||||
}
|
||||
assertNoError {
|
||||
try migrator.migrate(dbQueue)
|
||||
}
|
||||
}
|
||||
|
||||
func testColor() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
|
||||
do {
|
||||
for color in [Color.Red, Color.White, Color.Rose] {
|
||||
try db.execute("INSERT INTO wines (color) VALUES (?)", bindings: [color])
|
||||
}
|
||||
try db.execute("INSERT INTO wines (color) VALUES (?)", bindings: [4])
|
||||
}
|
||||
|
||||
do {
|
||||
let rows = db.fetchAllRows("SELECT color FROM wines ORDER BY color")
|
||||
let colors = rows.map { $0.value(atIndex: 0) as Color? }
|
||||
XCTAssertEqual(colors[0]!, Color.Red)
|
||||
XCTAssertEqual(colors[1]!, Color.White)
|
||||
XCTAssertEqual(colors[2]!, Color.Rose)
|
||||
XCTAssertTrue(colors[3] == nil)
|
||||
}
|
||||
|
||||
do {
|
||||
let colors = db.fetchAll(Color.self, "SELECT color FROM wines ORDER BY color")
|
||||
XCTAssertEqual(colors[0]!, Color.Red)
|
||||
XCTAssertEqual(colors[1]!, Color.White)
|
||||
XCTAssertEqual(colors[2]!, Color.Rose)
|
||||
XCTAssertTrue(colors[3] == nil)
|
||||
}
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testGrape() {
|
||||
assertNoError {
|
||||
try dbQueue.inTransaction { db in
|
||||
|
||||
do {
|
||||
for grape in [Grape.Chardonnay, Grape.Merlot, Grape.Riesling] {
|
||||
try db.execute("INSERT INTO wines (grape) VALUES (?)", bindings: [grape])
|
||||
}
|
||||
try db.execute("INSERT INTO wines (grape) VALUES (?)", bindings: ["Syrah"])
|
||||
}
|
||||
|
||||
do {
|
||||
let rows = db.fetchAllRows("SELECT grape FROM wines ORDER BY grape")
|
||||
let grapes = rows.map { $0.value(atIndex: 0) as Grape? }
|
||||
XCTAssertEqual(grapes[0]!, Grape.Chardonnay)
|
||||
XCTAssertEqual(grapes[1]!, Grape.Merlot)
|
||||
XCTAssertEqual(grapes[2]!, Grape.Riesling)
|
||||
XCTAssertTrue(grapes[3] == nil)
|
||||
}
|
||||
|
||||
do {
|
||||
let grapes = db.fetchAll(Grape.self, "SELECT grape FROM wines ORDER BY grape")
|
||||
XCTAssertEqual(grapes[0]!, Grape.Chardonnay)
|
||||
XCTAssertEqual(grapes[1]!, Grape.Merlot)
|
||||
XCTAssertEqual(grapes[2]!, Grape.Riesling)
|
||||
XCTAssertTrue(grapes[3] == nil)
|
||||
}
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,600 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
@testable import GRDB
|
||||
|
||||
enum SQLiteStorageClass {
|
||||
case Null
|
||||
case Integer
|
||||
case Real
|
||||
case Text
|
||||
case Blob
|
||||
}
|
||||
|
||||
extension DatabaseValue {
|
||||
var storageClass: SQLiteStorageClass {
|
||||
switch self {
|
||||
case .Null:
|
||||
return .Null
|
||||
case .Integer:
|
||||
return .Integer
|
||||
case .Real:
|
||||
return .Real
|
||||
case .Text:
|
||||
return .Text
|
||||
case .Blob:
|
||||
return .Blob
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DatabaseValueConvertibleTests : GRDBTestCase {
|
||||
|
||||
// Datatypes In SQLite Version 3: https://www.sqlite.org/datatype3.html
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE `values` (" +
|
||||
"integerAffinity INTEGER, " +
|
||||
"textAffinity TEXT, " +
|
||||
"noneAffinity BLOB, " +
|
||||
"realAffinity DOUBLE, " +
|
||||
"numericAffinity NUMERIC" +
|
||||
")")
|
||||
}
|
||||
|
||||
assertNoError {
|
||||
try migrator.migrate(dbQueue)
|
||||
}
|
||||
}
|
||||
|
||||
func bool(databaseValue: DatabaseValue) -> Bool? {
|
||||
return databaseValue.value()
|
||||
}
|
||||
func int(databaseValue: DatabaseValue) -> Int? {
|
||||
return databaseValue.value()
|
||||
}
|
||||
func int64(databaseValue: DatabaseValue) -> Int64? {
|
||||
return databaseValue.value()
|
||||
}
|
||||
func double(databaseValue: DatabaseValue) -> Double? {
|
||||
return databaseValue.value()
|
||||
}
|
||||
func string(databaseValue: DatabaseValue) -> String? {
|
||||
return databaseValue.value()
|
||||
}
|
||||
func blob(databaseValue: DatabaseValue) -> Blob? {
|
||||
return databaseValue.value()
|
||||
}
|
||||
|
||||
func testTextAffinity() {
|
||||
// https://www.sqlite.org/datatype3.html
|
||||
//
|
||||
// > A column with TEXT affinity stores all data using storage classes
|
||||
// > NULL, TEXT or BLOB. If numerical data is inserted into a column
|
||||
// > with TEXT affinity it is converted into text form before being
|
||||
// > stored.
|
||||
|
||||
assertNoError {
|
||||
|
||||
// Integer is turned to Text
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (textAffinity) VALUES (?)", bindings: [0])
|
||||
let databaseValue = db.fetchOneRow("SELECT textAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Text)
|
||||
|
||||
// Check built-in conversions from Text storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertEqual(self.string(databaseValue)!, "0")
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// Double is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (textAffinity) VALUES (?)", bindings: [0.0])
|
||||
let databaseValue = db.fetchOneRow("SELECT textAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Text)
|
||||
|
||||
// Check built-in conversions from Text storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertEqual(self.string(databaseValue)!, "0.0")
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "3.0e+5" is turned to Text
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (textAffinity) VALUES (?)", bindings: ["3.0e+5"])
|
||||
let databaseValue = db.fetchOneRow("SELECT textAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Text)
|
||||
|
||||
// Check built-in conversions from Text storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertEqual(self.string(databaseValue)!, "3.0e+5")
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "foo" is turned to Text
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (textAffinity) VALUES (?)", bindings: ["foo"])
|
||||
let databaseValue = db.fetchOneRow("SELECT textAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Text)
|
||||
|
||||
// Check built-in conversions from Text storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertEqual(self.string(databaseValue)!, "foo")
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// Blob is turned to Blob
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (textAffinity) VALUES (?)", bindings: [Blob("foo".dataUsingEncoding(NSUTF8StringEncoding))])
|
||||
let databaseValue = db.fetchOneRow("SELECT textAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Blob)
|
||||
|
||||
// Check built-in conversions from Blob storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue)!.data .isEqualToData("foo".dataUsingEncoding(NSUTF8StringEncoding)!))
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testNumericAffinity() {
|
||||
// https://www.sqlite.org/datatype3.html
|
||||
//
|
||||
// > A column with NUMERIC affinity may contain values using all five
|
||||
// > storage classes. When text data is inserted into a NUMERIC column,
|
||||
// > the storage class of the text is converted to INTEGER or REAL (in
|
||||
// > order of preference) if such conversion is lossless and reversible.
|
||||
// > For conversions between TEXT and REAL storage classes, SQLite
|
||||
// > considers the conversion to be lossless and reversible if the first
|
||||
// > 15 significant decimal digits of the number are preserved. If the
|
||||
// > lossless conversion of TEXT to INTEGER or REAL is not possible then
|
||||
// > the value is stored using the TEXT storage class. No attempt is
|
||||
// > made to convert NULL or BLOB values.
|
||||
// >
|
||||
// > A string might look like a floating-point literal with a decimal
|
||||
// > point and/or exponent notation but as long as the value can be
|
||||
// > expressed as an integer, the NUMERIC affinity will convert it into
|
||||
// > an integer. Hence, the string '3.0e+5' is stored in a column with
|
||||
// > NUMERIC affinity as the integer 300000, not as the floating point
|
||||
// > value 300000.0.
|
||||
|
||||
testNumericAffinity("numericAffinity")
|
||||
}
|
||||
|
||||
func testIntegerAffinity() {
|
||||
// https://www.sqlite.org/datatype3.html
|
||||
//
|
||||
// > A column that uses INTEGER affinity behaves the same as a column
|
||||
// > with NUMERIC affinity. The difference between INTEGER and NUMERIC
|
||||
// > affinity is only evident in a CAST expression.
|
||||
|
||||
testNumericAffinity("integerAffinity")
|
||||
}
|
||||
|
||||
func testRealAffinity() {
|
||||
// https://www.sqlite.org/datatype3.html
|
||||
//
|
||||
// > A column with REAL affinity behaves like a column with NUMERIC
|
||||
// > affinity except that it forces integer values into floating point
|
||||
// > representation. (As an internal optimization, small floating point
|
||||
// > values with no fractional component and stored in columns with REAL
|
||||
// > affinity are written to disk as integers in order to take up less
|
||||
// > space and are automatically converted back into floating point as
|
||||
// > the value is read out. This optimization is completely invisible at
|
||||
// > the SQL level and can only be detected by examining the raw bits of
|
||||
// > the database file.)
|
||||
|
||||
assertNoError {
|
||||
|
||||
// Integer is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (realAffinity) VALUES (?)", bindings: [0])
|
||||
let databaseValue = db.fetchOneRow("SELECT realAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Real)
|
||||
|
||||
// Check built-in conversions from Real storage
|
||||
XCTAssertEqual(self.bool(databaseValue)!, false)
|
||||
XCTAssertEqual(self.int(databaseValue)!, 0)
|
||||
XCTAssertEqual(self.int64(databaseValue)!, Int64(0))
|
||||
XCTAssertEqual(self.double(databaseValue)!, 0.0)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// 3.0e5 Double is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (realAffinity) VALUES (?)", bindings: [3.0e5])
|
||||
let databaseValue = db.fetchOneRow("SELECT realAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Real)
|
||||
|
||||
// Check built-in conversions from Real storage
|
||||
XCTAssertEqual(self.bool(databaseValue)!, true)
|
||||
XCTAssertEqual(self.int(databaseValue)!, 300000)
|
||||
XCTAssertEqual(self.int64(databaseValue)!, Int64(300000))
|
||||
XCTAssertEqual(self.double(databaseValue)!, Double(300000))
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// 1.0e20 Double is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (realAffinity) VALUES (?)", bindings: [1.0e20])
|
||||
let databaseValue = db.fetchOneRow("SELECT realAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Real)
|
||||
|
||||
// Check built-in conversions from Real storage (avoid Int and Int64 since 1.0e20 does not fit)
|
||||
XCTAssertEqual(self.bool(databaseValue)!, true)
|
||||
XCTAssertEqual(self.double(databaseValue)!, 1e20)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "3.0e+5" is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (realAffinity) VALUES (?)", bindings: ["3.0e+5"])
|
||||
let databaseValue = db.fetchOneRow("SELECT realAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Real)
|
||||
|
||||
// Check built-in conversions from Real storage
|
||||
XCTAssertEqual(self.bool(databaseValue)!, true)
|
||||
XCTAssertEqual(self.int(databaseValue)!, 300000)
|
||||
XCTAssertEqual(self.int64(databaseValue)!, Int64(300000))
|
||||
XCTAssertEqual(self.double(databaseValue)!, Double(300000))
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "1.0e+20" is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (realAffinity) VALUES (?)", bindings: ["1.0e+20"])
|
||||
let databaseValue = db.fetchOneRow("SELECT realAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Real)
|
||||
|
||||
// Check built-in conversions from Real storage: (avoid Int and Int64 since 1.0e20 does not fit)
|
||||
XCTAssertEqual(self.bool(databaseValue)!, true)
|
||||
XCTAssertEqual(self.double(databaseValue)!, 1e20)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "foo" is turned to Text
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (realAffinity) VALUES (?)", bindings: ["foo"])
|
||||
let databaseValue = db.fetchOneRow("SELECT realAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Text)
|
||||
|
||||
// Check built-in conversions from Text storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertEqual(self.string(databaseValue)!, "foo")
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// Blob is turned to Blob
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (realAffinity) VALUES (?)", bindings: [Blob("foo".dataUsingEncoding(NSUTF8StringEncoding))])
|
||||
let databaseValue = db.fetchOneRow("SELECT realAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Blob)
|
||||
|
||||
// Check built-in conversions from Blob storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue)!.data .isEqualToData("foo".dataUsingEncoding(NSUTF8StringEncoding)!))
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testNoneAffinity() {
|
||||
// https://www.sqlite.org/datatype3.html
|
||||
//
|
||||
// > A column with affinity NONE does not prefer one storage class over
|
||||
// > another and no attempt is made to coerce data from one storage
|
||||
// > class into another.
|
||||
|
||||
assertNoError {
|
||||
|
||||
// Integer is turned to Integer
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (noneAffinity) VALUES (?)", bindings: [0])
|
||||
let databaseValue = db.fetchOneRow("SELECT noneAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Integer)
|
||||
|
||||
// Check built-in conversions from Integer storage
|
||||
XCTAssertEqual(self.bool(databaseValue)!, false)
|
||||
XCTAssertEqual(self.int(databaseValue)!, 0)
|
||||
XCTAssertEqual(self.int64(databaseValue)!, Int64(0))
|
||||
XCTAssertEqual(self.double(databaseValue)!, 0.0)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// Double is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (noneAffinity) VALUES (?)", bindings: [0.0])
|
||||
let databaseValue = db.fetchOneRow("SELECT noneAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Real)
|
||||
|
||||
// Check built-in conversions from Real storage
|
||||
XCTAssertEqual(self.bool(databaseValue)!, false)
|
||||
XCTAssertEqual(self.int(databaseValue)!, 0)
|
||||
XCTAssertEqual(self.int64(databaseValue)!, Int64(0))
|
||||
XCTAssertEqual(self.double(databaseValue)!, 0.0)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "3.0e+5" is turned to Text
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (noneAffinity) VALUES (?)", bindings: ["3.0e+5"])
|
||||
let databaseValue = db.fetchOneRow("SELECT noneAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Text)
|
||||
|
||||
// Check built-in conversions from Text storage
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertEqual(self.string(databaseValue)!, "3.0e+5")
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// Blob is turned to Blob
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (noneAffinity) VALUES (?)", bindings: [Blob("foo".dataUsingEncoding(NSUTF8StringEncoding))])
|
||||
let databaseValue = db.fetchOneRow("SELECT noneAffinity FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Blob)
|
||||
|
||||
// Check built-in conversions from Blob storage
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue)!.data .isEqualToData("foo".dataUsingEncoding(NSUTF8StringEncoding)!))
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testNumericAffinity(columnName: String) {
|
||||
// https://www.sqlite.org/datatype3.html
|
||||
//
|
||||
// > A column with NUMERIC affinity may contain values using all five
|
||||
// > storage classes. When text data is inserted into a NUMERIC column,
|
||||
// > the storage class of the text is converted to INTEGER or REAL (in
|
||||
// > order of preference) if such conversion is lossless and reversible.
|
||||
// > For conversions between TEXT and REAL storage classes, SQLite
|
||||
// > considers the conversion to be lossless and reversible if the first
|
||||
// > 15 significant decimal digits of the number are preserved. If the
|
||||
// > lossless conversion of TEXT to INTEGER or REAL is not possible then
|
||||
// > the value is stored using the TEXT storage class. No attempt is
|
||||
// > made to convert NULL or BLOB values.
|
||||
// >
|
||||
// > A string might look like a floating-point literal with a decimal
|
||||
// > point and/or exponent notation but as long as the value can be
|
||||
// > expressed as an integer, the NUMERIC affinity will convert it into
|
||||
// > an integer. Hence, the string '3.0e+5' is stored in a column with
|
||||
// > NUMERIC affinity as the integer 300000, not as the floating point
|
||||
// > value 300000.0.
|
||||
|
||||
assertNoError {
|
||||
|
||||
// Integer is turned to Integer
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (\(columnName)) VALUES (?)", bindings: [0])
|
||||
let databaseValue = db.fetchOneRow("SELECT \(columnName) FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Integer)
|
||||
|
||||
// Check built-in conversions from Integer storage
|
||||
XCTAssertEqual(self.bool(databaseValue)!, false)
|
||||
XCTAssertEqual(self.int(databaseValue)!, 0)
|
||||
XCTAssertEqual(self.int64(databaseValue)!, Int64(0))
|
||||
XCTAssertEqual(self.double(databaseValue)!, 0.0)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// 3.0e5 Double is turned to Integer
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (\(columnName)) VALUES (?)", bindings: [3.0e5])
|
||||
let databaseValue = db.fetchOneRow("SELECT \(columnName) FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Integer)
|
||||
|
||||
// Check built-in conversions from Integer storage
|
||||
XCTAssertEqual(self.bool(databaseValue)!, true)
|
||||
XCTAssertEqual(self.int(databaseValue)!, 300000)
|
||||
XCTAssertEqual(self.int64(databaseValue)!, Int64(300000))
|
||||
XCTAssertEqual(self.double(databaseValue)!, Double(300000))
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// 1.0e20 Double is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (\(columnName)) VALUES (?)", bindings: [1.0e20])
|
||||
let databaseValue = db.fetchOneRow("SELECT \(columnName) FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Real)
|
||||
|
||||
// Check built-in conversions from Real storage (avoid Int and Int64 since 1.0e20 does not fit)
|
||||
XCTAssertEqual(self.bool(databaseValue)!, true)
|
||||
XCTAssertEqual(self.double(databaseValue)!, 1e20)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "3.0e+5" is turned to Integer
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (\(columnName)) VALUES (?)", bindings: ["3.0e+5"])
|
||||
let databaseValue = db.fetchOneRow("SELECT \(columnName) FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Integer)
|
||||
|
||||
// Check built-in conversions from Integer storage
|
||||
XCTAssertEqual(self.bool(databaseValue)!, true)
|
||||
XCTAssertEqual(self.int(databaseValue)!, 300000)
|
||||
XCTAssertEqual(self.int64(databaseValue)!, Int64(300000))
|
||||
XCTAssertEqual(self.double(databaseValue)!, Double(300000))
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "1.0e+20" is turned to Real
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (\(columnName)) VALUES (?)", bindings: ["1.0e+20"])
|
||||
let databaseValue = db.fetchOneRow("SELECT \(columnName) FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Real)
|
||||
|
||||
// Check built-in conversions from Real storage: (avoid Int and Int64 since 1.0e20 does not fit)
|
||||
XCTAssertEqual(self.bool(databaseValue)!, true)
|
||||
XCTAssertEqual(self.double(databaseValue)!, 1e20)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// "foo" is turned to Text
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (\(columnName)) VALUES (?)", bindings: ["foo"])
|
||||
let databaseValue = db.fetchOneRow("SELECT \(columnName) FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Text)
|
||||
|
||||
// Check built-in conversions from Text storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertEqual(self.string(databaseValue)!, "foo")
|
||||
XCTAssertTrue(self.blob(databaseValue) == nil)
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
|
||||
// Blob is turned to Blob
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("INSERT INTO `values` (\(columnName)) VALUES (?)", bindings: [Blob("foo".dataUsingEncoding(NSUTF8StringEncoding))])
|
||||
let databaseValue = db.fetchOneRow("SELECT \(columnName) FROM `values`")![0]
|
||||
XCTAssertEqual(databaseValue.storageClass, SQLiteStorageClass.Blob)
|
||||
|
||||
// Check built-in conversions from Blob storage:
|
||||
XCTAssertTrue(self.bool(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int(databaseValue) == nil)
|
||||
XCTAssertTrue(self.int64(databaseValue) == nil)
|
||||
XCTAssertTrue(self.double(databaseValue) == nil)
|
||||
XCTAssertTrue(self.string(databaseValue) == nil)
|
||||
XCTAssertTrue(self.blob(databaseValue)!.data .isEqualToData("foo".dataUsingEncoding(NSUTF8StringEncoding)!))
|
||||
|
||||
return .Rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class SelectStatementTests : GRDBTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"creationTimestamp DOUBLE, " +
|
||||
"name TEXT NOT NULL, " +
|
||||
"age INT" +
|
||||
")")
|
||||
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (?,?)", bindings: ["Arthur", 41])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (?,?)", bindings: ["Barbara", 26])
|
||||
try db.execute("INSERT INTO persons (name, age) VALUES (?,?)", bindings: ["Craig", 13])
|
||||
}
|
||||
|
||||
assertNoError {
|
||||
try migrator.migrate(dbQueue)
|
||||
}
|
||||
}
|
||||
|
||||
func testArrayBindingsWithSetter() {
|
||||
assertNoError {
|
||||
dbQueue.inDatabase { db in
|
||||
let statement = db.selectStatement("SELECT COUNT(*) FROM persons WHERE age < ?")
|
||||
let ages = [20, 30, 40, 50]
|
||||
let counts = ages.map { age -> Int in
|
||||
statement.bindings = [age]
|
||||
return statement.fetchOne(Int.self)!
|
||||
}
|
||||
XCTAssertEqual(counts, [1,2,2,3])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testArrayBindingsInFetch() {
|
||||
assertNoError {
|
||||
dbQueue.inDatabase { db in
|
||||
let statement = db.selectStatement("SELECT COUNT(*) FROM persons WHERE age < ?")
|
||||
let ages = [20, 30, 40, 50]
|
||||
let counts = ages.map { statement.fetchOne(Int.self, bindings: [$0])! }
|
||||
XCTAssertEqual(counts, [1,2,2,3])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDictionaryBindingsWithSetter() {
|
||||
assertNoError {
|
||||
dbQueue.inDatabase { db in
|
||||
let statement = db.selectStatement("SELECT COUNT(*) FROM persons WHERE age < :age")
|
||||
// TODO: why is this explicit type declaration required?
|
||||
let ageDicts: [[String: DatabaseValueConvertible?]] = [["age": 20], ["age": 30], ["age": 40], ["age": 50]]
|
||||
let counts = ageDicts.map { ageDict -> Int in
|
||||
statement.bindings = Bindings(ageDict)
|
||||
return statement.fetchOne(Int.self)!
|
||||
}
|
||||
XCTAssertEqual(counts, [1,2,2,3])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDictionaryBindingsInFetch() {
|
||||
assertNoError {
|
||||
dbQueue.inDatabase { db in
|
||||
let statement = db.selectStatement("SELECT COUNT(*) FROM persons WHERE age < :age")
|
||||
// TODO: why is this explicit type declaration required?
|
||||
let ageDicts: [[String: DatabaseValueConvertible?]] = [["age": 20], ["age": 30], ["age": 40], ["age": 50]]
|
||||
let counts = ageDicts.map { statement.fetchOne(Int.self, bindings: Bindings($0))! }
|
||||
XCTAssertEqual(counts, [1,2,2,3])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testRowSequenceCanBeIteratedTwice() {
|
||||
assertNoError {
|
||||
dbQueue.inDatabase { db in
|
||||
let statement = db.selectStatement("SELECT * FROM persons ORDER BY name")
|
||||
let rows = statement.fetchRows()
|
||||
var names1: [String?] = rows.map { $0.value(named: "name") as String? }
|
||||
var names2: [String?] = rows.map { $0.value(named: "name") as String? }
|
||||
|
||||
XCTAssertEqual(names1[0]!, "Arthur")
|
||||
XCTAssertEqual(names1[1]!, "Barbara")
|
||||
XCTAssertEqual(names1[2]!, "Craig")
|
||||
XCTAssertEqual(names2[0]!, "Arthur")
|
||||
XCTAssertEqual(names2[1]!, "Barbara")
|
||||
XCTAssertEqual(names2[2]!, "Craig")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testValueSequenceCanBeIteratedTwice() {
|
||||
assertNoError {
|
||||
dbQueue.inDatabase { db in
|
||||
let statement = db.selectStatement("SELECT name FROM persons ORDER BY name")
|
||||
let nameSequence = statement.fetch(String.self)
|
||||
var names1: [String?] = Array(nameSequence).map { $0 }
|
||||
var names2: [String?] = Array(nameSequence).map { $0 }
|
||||
|
||||
XCTAssertEqual(names1[0]!, "Arthur")
|
||||
XCTAssertEqual(names1[1]!, "Barbara")
|
||||
XCTAssertEqual(names1[2]!, "Craig")
|
||||
XCTAssertEqual(names2[0]!, "Arthur")
|
||||
XCTAssertEqual(names2[1]!, "Barbara")
|
||||
XCTAssertEqual(names2[2]!, "Craig")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
class UpdateStatementTests : GRDBTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"creationTimestamp DOUBLE, " +
|
||||
"name TEXT NOT NULL, " +
|
||||
"age INT" +
|
||||
")")
|
||||
}
|
||||
|
||||
assertNoError {
|
||||
try migrator.migrate(dbQueue)
|
||||
}
|
||||
}
|
||||
|
||||
func testArrayBindingsWithSetter() {
|
||||
assertNoError {
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (?, ?)")
|
||||
let persons = [
|
||||
["Arthur", 41],
|
||||
["Barbara"],
|
||||
]
|
||||
for person in persons {
|
||||
statement.bindings = Bindings(person)
|
||||
try statement.execute()
|
||||
}
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let rows = db.fetchAllRows("SELECT * FROM persons ORDER BY name")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
XCTAssertEqual(rows[0].value(named: "name")! as String, "Arthur")
|
||||
XCTAssertEqual(rows[0].value(named: "age")! as Int, 41)
|
||||
XCTAssertEqual(rows[1].value(named: "name")! as String, "Barbara")
|
||||
XCTAssertTrue(rows[1].value(named: "age") == nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testArrayBindingsInExecute() {
|
||||
assertNoError {
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (?, ?)")
|
||||
let persons = [
|
||||
["Arthur", 41],
|
||||
["Barbara"],
|
||||
]
|
||||
for person in persons {
|
||||
try statement.execute(bindings: Bindings(person))
|
||||
}
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let rows = db.fetchAllRows("SELECT * FROM persons ORDER BY name")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
XCTAssertEqual(rows[0].value(named: "name")! as String, "Arthur")
|
||||
XCTAssertEqual(rows[0].value(named: "age")! as Int, 41)
|
||||
XCTAssertEqual(rows[1].value(named: "name")! as String, "Barbara")
|
||||
XCTAssertTrue(rows[1].value(named: "age") == nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDictionaryBindingsWithSetter() {
|
||||
assertNoError {
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (:name, :age)")
|
||||
let persons = [
|
||||
["name": "Arthur", "age": 41],
|
||||
["name": "Barbara"],
|
||||
]
|
||||
for person in persons {
|
||||
statement.bindings = Bindings(person)
|
||||
try statement.execute()
|
||||
}
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let rows = db.fetchAllRows("SELECT * FROM persons ORDER BY name")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
XCTAssertEqual(rows[0].value(named: "name")! as String, "Arthur")
|
||||
XCTAssertEqual(rows[0].value(named: "age")! as Int, 41)
|
||||
XCTAssertEqual(rows[1].value(named: "name")! as String, "Barbara")
|
||||
XCTAssertTrue(rows[1].value(named: "age") == nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDictionaryBindingsInExecute() {
|
||||
assertNoError {
|
||||
|
||||
try dbQueue.inTransaction { db in
|
||||
|
||||
let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (:name, :age)")
|
||||
let persons = [
|
||||
["name": "Arthur", "age": 41],
|
||||
["name": "Barbara"],
|
||||
]
|
||||
for person in persons {
|
||||
try statement.execute(bindings: Bindings(person))
|
||||
}
|
||||
|
||||
return .Commit
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
let rows = db.fetchAllRows("SELECT * FROM persons ORDER BY name")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
XCTAssertEqual(rows[0].value(named: "name")! as String, "Arthur")
|
||||
XCTAssertEqual(rows[0].value(named: "age")! as Int, 41)
|
||||
XCTAssertEqual(rows[1].value(named: "name")! as String, "Barbara")
|
||||
XCTAssertTrue(rows[1].value(named: "age") == nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -1,17 +1,20 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'GRDB.swift'
|
||||
s.version = '0.2.0'
|
||||
s.version = '1.2'
|
||||
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.summary = 'SQLite toolkit for Swift.'
|
||||
s.summary = 'A Swift application toolkit for SQLite databases.'
|
||||
s.homepage = 'https://github.com/groue/GRDB.swift'
|
||||
s.author = { 'Gwendal Roué' => 'gr@pierlis.com' }
|
||||
s.source = { :git => 'https://github.com/groue/GRDB.swift.git', :tag => "v#{s.version}" }
|
||||
s.source_files = 'GRDB/**/*.{h,m,swift}'
|
||||
s.module_name = 'GRDB'
|
||||
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.9'
|
||||
s.requires_arc = true
|
||||
s.module_map = 'GRDB/module.modulemap'
|
||||
s.watchos.deployment_target = '2.0'
|
||||
|
||||
s.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}'
|
||||
s.module_map = 'Support/module.modulemap'
|
||||
s.framework = 'Foundation'
|
||||
s.library = 'sqlite3'
|
||||
end
|
||||
Regular → Executable
+5895
-274
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0830"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "560FC5191CB003810014AA8E"
|
||||
BuildableName = "GRDBCipher.framework"
|
||||
BlueprintName = "GRDBCipherOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "560FC55D1CB00B880014AA8E"
|
||||
BuildableName = "GRDBCipherOSXTests.xctest"
|
||||
BlueprintName = "GRDBCipherOSXTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "567156191CB16729007DC145"
|
||||
BuildableName = "GRDBCipherOSXEncryptedTests.xctest"
|
||||
BlueprintName = "GRDBCipherOSXEncryptedTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "560FC5191CB003810014AA8E"
|
||||
BuildableName = "GRDBCipher.framework"
|
||||
BlueprintName = "GRDBCipherOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "560FC5191CB003810014AA8E"
|
||||
BuildableName = "GRDBCipher.framework"
|
||||
BlueprintName = "GRDBCipherOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "560FC5191CB003810014AA8E"
|
||||
BuildableName = "GRDBCipher.framework"
|
||||
BlueprintName = "GRDBCipherOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0830"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56AFC9EE1CB1A8BB00F48B96"
|
||||
BuildableName = "GRDBCipher.framework"
|
||||
BlueprintName = "GRDBCipheriOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56AFCA2B1CB1AA9900F48B96"
|
||||
BuildableName = "GRDBCipheriOSTests.xctest"
|
||||
BlueprintName = "GRDBCipheriOSTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56AFCA841CB1ABC800F48B96"
|
||||
BuildableName = "GRDBCipheriOSEncryptedTests.xctest"
|
||||
BlueprintName = "GRDBCipheriOSEncryptedTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56AFC9EE1CB1A8BB00F48B96"
|
||||
BuildableName = "GRDBCipher.framework"
|
||||
BlueprintName = "GRDBCipheriOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56AFC9EE1CB1A8BB00F48B96"
|
||||
BuildableName = "GRDBCipher.framework"
|
||||
BlueprintName = "GRDBCipheriOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56AFC9EE1CB1A8BB00F48B96"
|
||||
BuildableName = "GRDBCipher.framework"
|
||||
BlueprintName = "GRDBCipheriOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0830"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA80591CFB2BB2003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLite.framework"
|
||||
BlueprintName = "GRDBCustomSQLiteOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA809A1CFB2F6F003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLiteOSXTests.xctest"
|
||||
BlueprintName = "GRDBCustomSQLiteOSXTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA80591CFB2BB2003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLite.framework"
|
||||
BlueprintName = "GRDBCustomSQLiteOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA80591CFB2BB2003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLite.framework"
|
||||
BlueprintName = "GRDBCustomSQLiteOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA80591CFB2BB2003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLite.framework"
|
||||
BlueprintName = "GRDBCustomSQLiteOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0830"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA7FFD1CFB25E4003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLite.framework"
|
||||
BlueprintName = "GRDBCustomSQLiteiOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA80401CFB2AD7003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLiteiOSTests.xctest"
|
||||
BlueprintName = "GRDBCustomSQLiteiOSTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA7FFD1CFB25E4003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLite.framework"
|
||||
BlueprintName = "GRDBCustomSQLiteiOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA7FFD1CFB25E4003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLite.framework"
|
||||
BlueprintName = "GRDBCustomSQLiteiOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F3BA7FFD1CFB25E4003DC1BA"
|
||||
BuildableName = "GRDBCustomSQLite.framework"
|
||||
BlueprintName = "GRDBCustomSQLiteiOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0810"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DC3773F219C8CBB3004FCF85"
|
||||
BuildableName = "GRDB.framework"
|
||||
BlueprintName = "GRDBOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
|
||||
BuildableName = "GRDBOSXTests.xctest"
|
||||
BlueprintName = "GRDBOSXTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
codeCoverageEnabled = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
|
||||
BuildableName = "GRDBOSXTests.xctest"
|
||||
BlueprintName = "GRDBOSXTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "FetchedRecordsControllerTests/testEmptyFetchedRecordsAfterPerformFetch()">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "FetchedRecordsControllerTests/testNoFetchedRecordsBeforeFetch()">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "FetchedRecordsControllerTests/testNotEmptyFetchedRecordsAfterPerformFetch()">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "FetchedRecordsControllerTests/testNotificationsOnInsertion()">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "FetchedRecordsControllerTests/testRecordDeleted()">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "FetchedRecordsControllerTests/testRecordInserted()">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "FetchedRecordsControllerTests/testRecordUpdated()">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DC3773F219C8CBB3004FCF85"
|
||||
BuildableName = "GRDB.framework"
|
||||
BlueprintName = "GRDBOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DC3773F219C8CBB3004FCF85"
|
||||
BuildableName = "GRDB.framework"
|
||||
BlueprintName = "GRDBOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DC3773F219C8CBB3004FCF85"
|
||||
BuildableName = "GRDB.framework"
|
||||
BlueprintName = "GRDBOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "560C97CF1C0E22D300BF8471"
|
||||
BuildableName = "GRDBOSXPerformanceTests.xctest"
|
||||
BlueprintName = "GRDBOSXPerformanceTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
+11
-20
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "0810"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -14,39 +14,30 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DC3773F219C8CBB3004FCF85"
|
||||
BlueprintIdentifier = "5654909F1D5A4798005622CB"
|
||||
BuildableName = "GRDB.framework"
|
||||
BlueprintName = "GRDBOSX"
|
||||
BlueprintName = "GRDBWatchOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DC3773F219C8CBB3004FCF85"
|
||||
BuildableName = "GRDB.framework"
|
||||
BlueprintName = "GRDBOSX"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
@@ -54,9 +45,9 @@
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DC3773F219C8CBB3004FCF85"
|
||||
BlueprintIdentifier = "5654909F1D5A4798005622CB"
|
||||
BuildableName = "GRDB.framework"
|
||||
BlueprintName = "GRDBOSX"
|
||||
BlueprintName = "GRDBWatchOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
@@ -64,17 +55,17 @@
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DC3773F219C8CBB3004FCF85"
|
||||
BlueprintIdentifier = "5654909F1D5A4798005622CB"
|
||||
BuildableName = "GRDB.framework"
|
||||
BlueprintName = "GRDBOSX"
|
||||
BlueprintName = "GRDBWatchOS"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
+15
-4
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "0810"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -23,11 +23,22 @@
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
codeCoverageEnabled = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "56E5D7D21B4D3FEE00430942"
|
||||
BuildableName = "GRDBiOSTests.xctest"
|
||||
BlueprintName = "GRDBiOSTests"
|
||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
@@ -42,11 +53,11 @@
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
@@ -64,10 +75,10 @@
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
+22
-3
@@ -1,12 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Playground.playground">
|
||||
</FileRef>
|
||||
<Group
|
||||
location = "group:Playgrounds"
|
||||
name = "Playgrounds">
|
||||
<FileRef
|
||||
location = "group:Tour.playground">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:JSONSynchronization.playground">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Record.playground">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:TransactionObserver.playground">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:MyPlayground.playground">
|
||||
</FileRef>
|
||||
</Group>
|
||||
<FileRef
|
||||
location = "group:GRDB.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj">
|
||||
</FileRef>
|
||||
|
||||
@@ -1,374 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
/**
|
||||
Bindings hold statement parameters:
|
||||
|
||||
INSERT INTO persons (name, age) VALUES (?, ?)
|
||||
INSERT INTO persons (name, age) VALUES (:name, :age)
|
||||
|
||||
To fill question mark parameters, feed Bindings with an array:
|
||||
|
||||
db.execute("INSERT ... (?, ?)", bindings: Bindings(["Arthur", 41]))
|
||||
|
||||
Array literals are automatically converted to Bindings:
|
||||
|
||||
db.execute("INSERT ... (?, ?)", bindings: ["Arthur", 41])
|
||||
|
||||
To fill named parameters, feed Bindings with a dictionary:
|
||||
|
||||
db.execute("INSERT ... (:name, :age)", bindings: Bindings(["name": "Arthur", "age": 41]))
|
||||
|
||||
Dictionary literals are automatically converted to Bindings:
|
||||
|
||||
db.execute("INSERT ... (:name, :age)", bindings: ["name": "Arthur", "age": 41])
|
||||
|
||||
GRDB.swift only supports colon-prefixed named parameters, even though SQLite
|
||||
supports other syntaxes. See https://www.sqlite.org/lang_expr.html#varparam for
|
||||
more information.
|
||||
*/
|
||||
public struct Bindings {
|
||||
|
||||
// MARK: - Positional parameters
|
||||
|
||||
/**
|
||||
Initializes bindings from a sequence of optional values.
|
||||
|
||||
let values: [String?] = ["foo", "bar", nil]
|
||||
db.execute("INSERT ... (?,?,?)", bindings: Bindings(values))
|
||||
|
||||
- parameter sequence: A sequence of optional values that adopt the
|
||||
DatabaseValueConvertible protocol.
|
||||
- returns: A Bindings.
|
||||
*/
|
||||
public init<Sequence: SequenceType where Sequence.Generator.Element == Optional<DatabaseValueConvertible>>(_ sequence: Sequence) {
|
||||
impl = BindingsArrayImpl(values: Array(sequence))
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes bindings from a sequence of values.
|
||||
|
||||
let values: [String] = ["foo", "bar", "baz"]
|
||||
db.execute("INSERT ... (?,?,?)", bindings: Bindings(values))
|
||||
|
||||
- parameter sequence: A sequence of values that adopt the
|
||||
DatabaseValueConvertible protocol.
|
||||
- returns: A Bindings.
|
||||
*/
|
||||
public init<Sequence: SequenceType where Sequence.Generator.Element == DatabaseValueConvertible>(_ sequence: Sequence) {
|
||||
impl = BindingsArrayImpl(values: sequence.map { $0 })
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes bindings from an NSArray.
|
||||
|
||||
The array must contain objects that adopt the DatabaseValueConvertible
|
||||
protocol, NSNull, NSNumber or NSString. A fatal error is thrown otherwise.
|
||||
|
||||
let values: NSArray = ["foo", "bar", "baz"]
|
||||
db.execute("INSERT ... (?,?,?)", bindings: Bindings(values))
|
||||
|
||||
- parameter array: An NSArray
|
||||
- returns: A Bindings.
|
||||
*/
|
||||
public init(_ array: NSArray) {
|
||||
// IMPLEMENTATION NOTE
|
||||
//
|
||||
// This initializer is required for the following code to compile:
|
||||
//
|
||||
// let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (?, ?)")
|
||||
// let persons = [ // NSArray of NSArray, actually
|
||||
// ["Arthur", 41],
|
||||
// ["Barbara"],
|
||||
// ]
|
||||
// for person in persons {
|
||||
// try statement.execute(Bindings(person)) // Avoid an error here
|
||||
// }
|
||||
var values = [DatabaseValueConvertible?]()
|
||||
for item in array {
|
||||
values.append(Bindings.valueFromAnyObject(item))
|
||||
}
|
||||
self.init(values)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Named Parameters
|
||||
|
||||
/**
|
||||
Initializes bindings from a dictionary of optional values.
|
||||
|
||||
let values: [String: String?] = ["firstName": nil, "lastName": "Miller"]
|
||||
db.execute("INSERT ... (:firstName, :lastName)", bindings: Bindings(values))
|
||||
|
||||
GRDB.swift only supports colon-prefixed named parameters, even though SQLite
|
||||
supports other syntaxes. See https://www.sqlite.org/lang_expr.html#varparam
|
||||
for more information.
|
||||
|
||||
- parameter dictionary: A dictionary of optional values that adopt the
|
||||
DatabaseValueConvertible protocol.
|
||||
- returns: A Bindings.
|
||||
*/
|
||||
public init(_ dictionary: [String: DatabaseValueConvertible?]) {
|
||||
impl = BindingsDictionaryImpl(dictionary: dictionary)
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes bindings from an NSDictionary.
|
||||
|
||||
The dictionary must contain objects that adopt the DatabaseValueConvertible
|
||||
protocol, NSNull, NSNumber or NSString. A fatal error is thrown otherwise.
|
||||
|
||||
let values: NSDictionary = ["firstName": "Arthur", "lastName": "Miller"]
|
||||
db.execute("INSERT ... (?,?,?)", bindings: Bindings(values))
|
||||
|
||||
GRDB.swift only supports colon-prefixed named parameters, even though SQLite
|
||||
supports other syntaxes. See https://www.sqlite.org/lang_expr.html#varparam
|
||||
for more information.
|
||||
|
||||
- parameter dictionary: An NSDictionary
|
||||
- returns: A Bindings.
|
||||
*/
|
||||
public init(_ dictionary: NSDictionary) {
|
||||
// IMPLEMENTATION NOTE
|
||||
//
|
||||
// This initializer is required for the following code to compile:
|
||||
//
|
||||
// let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (:name, :age)")
|
||||
// let persons = [ // NSArray of NSDictionary, actually
|
||||
// ["name": "Arthur", "age": 41],
|
||||
// ["name": "Barbara"],
|
||||
// ]
|
||||
// for person in persons {
|
||||
// try statement.execute(Bindings(person)) // Avoid an error here
|
||||
// }
|
||||
var values = [String: DatabaseValueConvertible?]()
|
||||
for (key, item) in dictionary {
|
||||
if let key = key as? String {
|
||||
values[key] = Bindings.valueFromAnyObject(item)
|
||||
} else {
|
||||
fatalError("Not a String key: \(key)")
|
||||
}
|
||||
}
|
||||
self.init(values)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Not Public
|
||||
|
||||
let impl: BindingsImpl
|
||||
|
||||
// Supported usage: Statement.bindings property
|
||||
//
|
||||
// let statement = db.UpdateStatement("INSERT INTO persons (name, age) VALUES (?,?)"
|
||||
// statement.bindings = ["Arthur", 41]
|
||||
// statement.execute()
|
||||
func bindInStatement(statement: Statement) {
|
||||
impl.bindInStatement(statement)
|
||||
}
|
||||
|
||||
// Supported usage: loading of RowModel by multiple-columns primary keys:
|
||||
//
|
||||
// let person = db.fetchOne(Person.self, primaryKey: Bindings)
|
||||
func dictionary(defaultColumnNames defaultColumnNames: [String]?) -> [String: DatabaseValueConvertible?] {
|
||||
return impl.dictionary(defaultColumnNames: defaultColumnNames)
|
||||
}
|
||||
|
||||
// Support for array-based bindings
|
||||
private struct BindingsArrayImpl : BindingsImpl {
|
||||
let values: [DatabaseValueConvertible?]
|
||||
init(values: [DatabaseValueConvertible?]) {
|
||||
self.values = values
|
||||
}
|
||||
func bindInStatement(statement: Statement) {
|
||||
for (index, value) in values.enumerate() {
|
||||
statement.bind(value, atIndex: index + 1)
|
||||
}
|
||||
}
|
||||
func dictionary(defaultColumnNames defaultColumnNames: [String]?) -> [String : DatabaseValueConvertible?] {
|
||||
guard let defaultColumnNames = defaultColumnNames else {
|
||||
fatalError("Missing column names")
|
||||
}
|
||||
guard defaultColumnNames.count == values.count else {
|
||||
fatalError("Columns count mismatch.")
|
||||
}
|
||||
var dictionary = [String : DatabaseValueConvertible?]()
|
||||
for (column, value) in zip(defaultColumnNames, values) {
|
||||
dictionary[column] = value
|
||||
}
|
||||
return dictionary
|
||||
}
|
||||
|
||||
var description: String {
|
||||
return "[" + ", ".join(values.map { value in
|
||||
if let string = value as? String {
|
||||
let escapedString = string
|
||||
.stringByReplacingOccurrencesOfString("\\", withString: "\\\\")
|
||||
.stringByReplacingOccurrencesOfString("\n", withString: "\\n")
|
||||
.stringByReplacingOccurrencesOfString("\r", withString: "\\r")
|
||||
.stringByReplacingOccurrencesOfString("\t", withString: "\\t")
|
||||
.stringByReplacingOccurrencesOfString("\"", withString: "\\\"")
|
||||
return "\"\(escapedString)\""
|
||||
} else if let value = value {
|
||||
return "\(value)"
|
||||
} else {
|
||||
return "nil"
|
||||
}}) + "]"
|
||||
}
|
||||
}
|
||||
|
||||
// Support for dictionary-based bindings
|
||||
private struct BindingsDictionaryImpl : BindingsImpl {
|
||||
let dictionary: [String: DatabaseValueConvertible?]
|
||||
init(dictionary: [String: DatabaseValueConvertible?]) {
|
||||
self.dictionary = dictionary
|
||||
}
|
||||
func bindInStatement(statement: Statement) {
|
||||
for (key, value) in dictionary {
|
||||
statement.bind(value, forKey: key)
|
||||
}
|
||||
}
|
||||
func dictionary( defaultColumnNames defaultColumnNames: [String]?) -> [String : DatabaseValueConvertible?] {
|
||||
return dictionary
|
||||
}
|
||||
|
||||
var description: String {
|
||||
return "[" + ", ".join(dictionary.map { (key, value) in
|
||||
if let string = value as? String {
|
||||
let escapedString = string
|
||||
.stringByReplacingOccurrencesOfString("\\", withString: "\\\\")
|
||||
.stringByReplacingOccurrencesOfString("\n", withString: "\\n")
|
||||
.stringByReplacingOccurrencesOfString("\r", withString: "\\r")
|
||||
.stringByReplacingOccurrencesOfString("\t", withString: "\\t")
|
||||
.stringByReplacingOccurrencesOfString("\"", withString: "\\\"")
|
||||
return "\(key): \"\(escapedString)\""
|
||||
} else if let value = value {
|
||||
return "\(key): \(value)"
|
||||
} else {
|
||||
return "\(key): nil"
|
||||
}}) + "]"
|
||||
}
|
||||
}
|
||||
|
||||
// IMPLEMENTATION NOTE:
|
||||
//
|
||||
// NSNumber, NSString, NSNull can't adopt DatabaseValueConvertible because
|
||||
// Swift 2 won't make it possible.
|
||||
//
|
||||
// This is why this method exists. As a convenience for init(NSArray)
|
||||
// and init(NSDictionary), themselves conveniences for the library user.
|
||||
private static func valueFromAnyObject(object: AnyObject) -> DatabaseValueConvertible? {
|
||||
|
||||
switch object {
|
||||
case let value as DatabaseValueConvertible:
|
||||
return value
|
||||
case _ as NSNull:
|
||||
return nil
|
||||
case let string as NSString:
|
||||
return string as String
|
||||
case let number as NSNumber:
|
||||
let objCType = String.fromCString(number.objCType)!
|
||||
switch objCType {
|
||||
case "c":
|
||||
return Int64(number.charValue)
|
||||
case "C":
|
||||
return Int64(number.unsignedCharValue)
|
||||
case "s":
|
||||
return Int64(number.shortValue)
|
||||
case "S":
|
||||
return Int64(number.unsignedShortValue)
|
||||
case "i":
|
||||
return Int64(number.intValue)
|
||||
case "I":
|
||||
return Int64(number.unsignedIntValue)
|
||||
case "l":
|
||||
return Int64(number.longValue)
|
||||
case "L":
|
||||
return Int64(number.unsignedLongValue)
|
||||
case "q":
|
||||
return Int64(number.longLongValue)
|
||||
case "Q":
|
||||
return Int64(number.unsignedLongLongValue)
|
||||
case "f":
|
||||
return Double(number.floatValue)
|
||||
case "d":
|
||||
return number.doubleValue
|
||||
case "B":
|
||||
return number.boolValue
|
||||
default:
|
||||
fatalError("Not a DatabaseValueConvertible: \(object)")
|
||||
}
|
||||
default:
|
||||
fatalError("Not a DatabaseValueConvertible: \(object)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The protocol for Bindings underlying implementation
|
||||
protocol BindingsImpl : CustomStringConvertible {
|
||||
func bindInStatement(statement: Statement)
|
||||
func dictionary(defaultColumnNames defaultColumnNames: [String]?) -> [String: DatabaseValueConvertible?]
|
||||
}
|
||||
|
||||
|
||||
// MARK: - ArrayLiteralConvertible
|
||||
|
||||
extension Bindings : ArrayLiteralConvertible {
|
||||
/**
|
||||
Returns a Bindings from an array literal:
|
||||
|
||||
db.selectRows("SELECT ...", bindings: ["Arthur", 41])
|
||||
*/
|
||||
public init(arrayLiteral elements: DatabaseValueConvertible?...) {
|
||||
self.init(elements)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - DictionaryLiteralConvertible
|
||||
|
||||
extension Bindings : DictionaryLiteralConvertible {
|
||||
/**
|
||||
Returns a Bindings from a dictionary literal:
|
||||
|
||||
db.selectRows("SELECT ...", bindings: ["name": "Arthur", "age": 41])
|
||||
*/
|
||||
public init(dictionaryLiteral elements: (String, DatabaseValueConvertible?)...) {
|
||||
var dictionary = [String: DatabaseValueConvertible?]()
|
||||
for (key, value) in elements {
|
||||
dictionary[key] = value
|
||||
}
|
||||
self.init(dictionary)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CustomStringConvertible
|
||||
|
||||
extension Bindings : CustomStringConvertible {
|
||||
/// A textual representation of `self`.
|
||||
public var description: String {
|
||||
return impl.description
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
//
|
||||
// GRDB.swift
|
||||
// https://github.com/groue/GRDB.swift
|
||||
// Copyright (c) 2015 Gwendal Roué
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
/**
|
||||
Configuration are arguments to the DatabaseQueue initializers.
|
||||
*/
|
||||
public struct Configuration {
|
||||
|
||||
/// A tracing function that logs SQL statements
|
||||
public static func logSQL(sql: String, bindings: Bindings?) {
|
||||
NSLog("GRDB: %@", sql)
|
||||
if let bindings = bindings {
|
||||
NSLog("GRDB: bindings %@", bindings.description)
|
||||
}
|
||||
}
|
||||
|
||||
/// A tracing function.
|
||||
public typealias TraceFunction = (sql: String, bindings: Bindings?) -> Void
|
||||
|
||||
/// If true, the database has support for foreign keys.
|
||||
public var foreignKeysEnabled: Bool
|
||||
|
||||
/// If true, the database is opened readonly.
|
||||
public var readonly: Bool
|
||||
|
||||
/// A tracing function that you can use for any purpose.
|
||||
public var trace: TraceFunction?
|
||||
|
||||
/**
|
||||
Setup a configuration.
|
||||
|
||||
- parameter foreignKeysEnabled: If true (the default), the database has
|
||||
support for foreign keys.
|
||||
- parameter readonly: If false (the default), the database will be
|
||||
created and opened for writing. If true, the
|
||||
database is opened readonly.
|
||||
- parameter trace: An optional tracing function (default nil).
|
||||
|
||||
- returns: A Configuration.
|
||||
*/
|
||||
public init(foreignKeysEnabled: Bool = true, readonly: Bool = false, trace: TraceFunction? = nil) {
|
||||
self.foreignKeysEnabled = foreignKeysEnabled
|
||||
self.readonly = readonly
|
||||
self.trace = trace
|
||||
}
|
||||
|
||||
var sqliteOpenFlags: Int32 {
|
||||
// See https://www.sqlite.org/c3ref/open.html
|
||||
return readonly ? SQLITE_OPEN_READONLY : (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import Foundation
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import CSQLite
|
||||
#endif
|
||||
|
||||
/// Configuration for a DatabaseQueue or DatabasePool.
|
||||
public struct Configuration {
|
||||
|
||||
// MARK: - Misc options
|
||||
|
||||
/// If true, foreign key constraints are checked.
|
||||
///
|
||||
/// Default: true
|
||||
public var foreignKeysEnabled: Bool = true
|
||||
|
||||
/// If true, database modifications are disallowed.
|
||||
///
|
||||
/// Default: false
|
||||
public var readonly: Bool = false
|
||||
|
||||
/// A function that is called on every statement executed by the database.
|
||||
///
|
||||
/// Default: nil
|
||||
public var trace: TraceFunction?
|
||||
|
||||
|
||||
// MARK: - Encryption
|
||||
|
||||
#if SQLITE_HAS_CODEC
|
||||
/// The passphrase for encrypted database.
|
||||
///
|
||||
/// Default: nil
|
||||
public var passphrase: String?
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: - Transactions
|
||||
|
||||
/// The default kind of transaction.
|
||||
///
|
||||
/// Default: deferred
|
||||
public var defaultTransactionKind: Database.TransactionKind = .deferred
|
||||
|
||||
|
||||
// MARK: - Concurrency
|
||||
|
||||
/// The behavior in case of SQLITE_BUSY error. See https://www.sqlite.org/rescode.html#busy
|
||||
///
|
||||
/// Default: immediateError
|
||||
public var busyMode: Database.BusyMode = .immediateError
|
||||
|
||||
/// The maximum number of concurrent readers (applies to database
|
||||
/// pools only).
|
||||
///
|
||||
/// Default: 5
|
||||
public var maximumReaderCount: Int = 5
|
||||
|
||||
|
||||
// MARK: - Factory Configuration
|
||||
|
||||
/// Creates a factory configuration
|
||||
public init() { }
|
||||
|
||||
|
||||
// MARK: - Not Public
|
||||
|
||||
var threadingMode: Database.ThreadingMode = .`default`
|
||||
var SQLiteConnectionDidOpen: (() -> ())?
|
||||
var SQLiteConnectionWillClose: ((SQLiteConnection) -> ())?
|
||||
var SQLiteConnectionDidClose: (() -> ())?
|
||||
var SQLiteOpenFlags: Int32 {
|
||||
let readWriteFlags = readonly ? SQLITE_OPEN_READONLY : (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)
|
||||
return threadingMode.SQLiteOpenFlags | readWriteFlags
|
||||
}
|
||||
}
|
||||
|
||||
/// A tracing function that takes an SQL string.
|
||||
public typealias TraceFunction = (String) -> Void
|
||||
@@ -0,0 +1,331 @@
|
||||
extension Array {
|
||||
/// Creates an array containing the elements of a cursor.
|
||||
///
|
||||
/// let cursor = try String.fetchCursor(db, "SELECT 'foo' UNION ALL SELECT 'bar'")
|
||||
/// let strings = try Array(cursor) // ["foo", "bar"]
|
||||
public init<C: Cursor>(_ cursor: C) throws where C.Element == Element {
|
||||
self.init()
|
||||
while let element = try cursor.next() {
|
||||
append(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A type that supplies the values of some external resource, one at a time.
|
||||
///
|
||||
/// ## Overview
|
||||
///
|
||||
/// The most common way to iterate over the elements of a cursor is to use a
|
||||
/// `while` loop:
|
||||
///
|
||||
/// let cursor = ...
|
||||
/// while let element = try cursor.next() {
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// ## Relationship with standard Sequence and IteratorProtocol
|
||||
///
|
||||
/// Cursors share traits with lazy sequences and iterators from the Swift
|
||||
/// standard library. Differences are:
|
||||
///
|
||||
/// - Cursor types are classes, and have a lifetime.
|
||||
/// - Cursor iteration may throw errors.
|
||||
/// - A cursor can not be repeated.
|
||||
///
|
||||
/// The protocol comes with default implementations for many operations similar
|
||||
/// to those defined by Swift's LazySequenceProtocol:
|
||||
///
|
||||
/// - `func contains(Self.Element)`
|
||||
/// - `func contains(where: (Self.Element) throws -> Bool)`
|
||||
/// - `func enumerated()`
|
||||
/// - `func filter((Self.Element) throws -> Bool)`
|
||||
/// - `func first(where: (Self.Element) throws -> Bool)`
|
||||
/// - `func flatMap<ElementOfResult>((Self.Element) throws -> ElementOfResult?)`
|
||||
/// - `func flatMap<SegmentOfResult>((Self.Element) throws -> SegmentOfResult)`
|
||||
/// - `func forEach((Self.Element) throws -> Void)`
|
||||
/// - `func joined()`
|
||||
/// - `func map<T>((Self.Element) throws -> T)`
|
||||
/// - `func reduce<Result>(Result, (Result, Self.Element) throws -> Result)`
|
||||
public protocol Cursor : class {
|
||||
/// The type of element traversed by the cursor.
|
||||
associatedtype Element
|
||||
|
||||
/// Advances to the next element and returns it, or nil if no next element
|
||||
/// exists. Once nil has been returned, all subsequent calls return nil.
|
||||
func next() throws -> Element?
|
||||
}
|
||||
|
||||
/// A type-erased cursor of Element.
|
||||
///
|
||||
/// This cursor forwards its next() method to an arbitrary underlying cursor
|
||||
/// having the same Element type, hiding the specifics of the underlying
|
||||
/// cursor.
|
||||
public class AnyCursor<Element> : Cursor {
|
||||
/// Creates a cursor that wraps a base cursor but whose type depends only on
|
||||
/// the base cursor’s element type
|
||||
public init<C: Cursor>(_ base: C) where C.Element == Element {
|
||||
element = base.next
|
||||
}
|
||||
|
||||
/// Creates a cursor that wraps the given closure in its next() method
|
||||
public init(_ body: @escaping () throws -> Element?) {
|
||||
element = body
|
||||
}
|
||||
|
||||
/// Advances to the next element and returns it, or nil if no next
|
||||
/// element exists.
|
||||
public func next() throws -> Element? {
|
||||
return try element()
|
||||
}
|
||||
|
||||
private let element: () throws -> Element?
|
||||
}
|
||||
|
||||
extension Cursor {
|
||||
/// Returns a Boolean value indicating whether the cursor contains an
|
||||
/// element that satisfies the given predicate.
|
||||
///
|
||||
/// - parameter predicate: A closure that takes an element of the cursor as
|
||||
/// its argument and returns a Boolean value that indicates whether the
|
||||
/// passed element represents a match.
|
||||
/// - returns: true if the cursor contains an element that satisfies
|
||||
/// predicate; otherwise, false.
|
||||
public func contains(where predicate: (Element) throws -> Bool) throws -> Bool {
|
||||
while let element = try next() {
|
||||
if try predicate(element) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/// Returns a cursor of pairs (n, x), where n represents a consecutive
|
||||
/// integer starting at zero, and x represents an element of the cursor.
|
||||
///
|
||||
/// let cursor = try String.fetchCursor(db, "SELECT 'foo' UNION ALL SELECT 'bar'")
|
||||
/// let c = cursor.enumerated()
|
||||
/// while let (n, x) = c.next() {
|
||||
/// print("\(n): \(x)")
|
||||
/// }
|
||||
/// // Prints: "0: foo"
|
||||
/// // Prints: "1: bar"
|
||||
public func enumerated() -> EnumeratedCursor<Self> {
|
||||
return EnumeratedCursor(self)
|
||||
}
|
||||
|
||||
/// Returns the elements of the cursor that satisfy the given predicate.
|
||||
public func filter(_ isIncluded: @escaping (Element) throws -> Bool) -> FilterCursor<Self> {
|
||||
return FilterCursor(self, isIncluded)
|
||||
}
|
||||
|
||||
/// Returns the first element of the cursor that satisfies the given
|
||||
/// predicate or nil if no such element is found.
|
||||
public func first(where predicate: (Element) throws -> Bool) throws -> Element? {
|
||||
while let element = try next() {
|
||||
if try predicate(element) {
|
||||
return element
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/// Returns a cursor over the concatenated non-nil results of mapping
|
||||
/// transform over this cursor.
|
||||
public func flatMap<ElementOfResult>(_ transform: @escaping (Element) throws -> ElementOfResult?) -> MapCursor<FilterCursor<MapCursor<Self, ElementOfResult?>>, ElementOfResult> {
|
||||
return map(transform).filter { $0 != nil }.map { $0! }
|
||||
}
|
||||
|
||||
/// Returns a cursor over the concatenated results of mapping transform
|
||||
/// over self.
|
||||
public func flatMap<SegmentOfResult: Sequence>(_ transform: @escaping (Element) throws -> SegmentOfResult) -> FlattenCursor<MapCursor<Self, IteratorCursor<SegmentOfResult.Iterator>>> {
|
||||
return flatMap { try IteratorCursor(transform($0)) }
|
||||
}
|
||||
|
||||
/// Returns a cursor over the concatenated results of mapping transform
|
||||
/// over self.
|
||||
public func flatMap<SegmentOfResult: Cursor>(_ transform: @escaping (Element) throws -> SegmentOfResult) -> FlattenCursor<MapCursor<Self, SegmentOfResult>> {
|
||||
return map(transform).joined()
|
||||
}
|
||||
|
||||
/// Calls the given closure on each element in the cursor.
|
||||
public func forEach(_ body: (Element) throws -> Void) throws {
|
||||
while let element = try next() {
|
||||
try body(element)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a cursor over the results of the transform function applied to
|
||||
/// this cursor's elements.
|
||||
public func map<T>(_ transform: @escaping (Element) throws -> T) -> MapCursor<Self, T> {
|
||||
return MapCursor(self, transform)
|
||||
}
|
||||
|
||||
/// Returns the result of calling the given combining closure with each
|
||||
/// element of this sequence and an accumulating value.
|
||||
public func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Element) throws -> Result) throws -> Result {
|
||||
var result = initialResult
|
||||
while let element = try next() {
|
||||
result = try nextPartialResult(result, element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
extension Cursor where Element: Equatable {
|
||||
/// Returns a Boolean value indicating whether the cursor contains the
|
||||
/// given element.
|
||||
public func contains(_ element: Element) throws -> Bool {
|
||||
while let e = try next() {
|
||||
if e == element {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
extension Cursor where Element: Cursor {
|
||||
/// Returns the elements of this cursor of cursors, concatenated.
|
||||
public func joined() -> FlattenCursor<Self> {
|
||||
return FlattenCursor(self)
|
||||
}
|
||||
}
|
||||
|
||||
extension Cursor where Element: Sequence {
|
||||
/// Returns the elements of this cursor of sequences, concatenated.
|
||||
public func joined() -> FlattenCursor<MapCursor<Self, IteratorCursor<Self.Element.Iterator>>> {
|
||||
return flatMap { $0 }
|
||||
}
|
||||
}
|
||||
|
||||
/// An enumeration of the elements of a cursor.
|
||||
///
|
||||
/// To create an instance of `EnumeratedCursor`, call the `enumerated()` method
|
||||
/// on a cursor:
|
||||
///
|
||||
/// let cursor = try String.fetchCursor(db, "SELECT 'foo' UNION ALL SELECT 'bar'")
|
||||
/// let c = cursor.enumerated()
|
||||
/// while let (n, x) = c.next() {
|
||||
/// print("\(n): \(x)")
|
||||
/// }
|
||||
/// // Prints: "0: foo"
|
||||
/// // Prints: "1: bar"
|
||||
public final class EnumeratedCursor<Base: Cursor> : Cursor {
|
||||
init(_ base: Base) {
|
||||
self.index = 0
|
||||
self.base = base
|
||||
}
|
||||
|
||||
/// Advances to the next element and returns it, or nil if no next
|
||||
/// element exists.
|
||||
public func next() throws -> (Int, Base.Element)? {
|
||||
guard let element = try base.next() else { return nil }
|
||||
defer { index += 1 }
|
||||
return (index, element)
|
||||
}
|
||||
|
||||
private var index: Int
|
||||
private var base: Base
|
||||
}
|
||||
|
||||
/// A cursor whose elements consist of the elements of some base cursor that
|
||||
/// also satisfy a given predicate.
|
||||
public final class FilterCursor<Base: Cursor> : Cursor {
|
||||
init(_ base: Base, _ isIncluded: @escaping (Base.Element) throws -> Bool) {
|
||||
self.base = base
|
||||
self.isIncluded = isIncluded
|
||||
}
|
||||
|
||||
/// Advances to the next element and returns it, or nil if no next
|
||||
/// element exists.
|
||||
public func next() throws -> Base.Element? {
|
||||
while let element = try base.next() {
|
||||
if try isIncluded(element) {
|
||||
return element
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private let base: Base
|
||||
private let isIncluded: (Base.Element) throws -> Bool
|
||||
}
|
||||
|
||||
/// A cursor consisting of all the elements contained in each segment contained
|
||||
/// in some Base cursor.
|
||||
///
|
||||
/// See Cursor.joined(), Cursor.flatMap(_:), Sequence.flatMap(_:)
|
||||
public final class FlattenCursor<Base: Cursor> : Cursor where Base.Element: Cursor {
|
||||
init(_ base: Base) {
|
||||
self.base = base
|
||||
}
|
||||
|
||||
/// Advances to the next element and returns it, or nil if no next
|
||||
/// element exists.
|
||||
public func next() throws -> Base.Element.Element? {
|
||||
while true {
|
||||
if let element = try inner?.next() {
|
||||
return element
|
||||
}
|
||||
guard let inner = try base.next() else {
|
||||
return nil
|
||||
}
|
||||
self.inner = inner
|
||||
}
|
||||
}
|
||||
|
||||
private var inner: Base.Element?
|
||||
private let base: Base
|
||||
}
|
||||
|
||||
/// A Cursor whose elements consist of those in a Base Cursor passed through a
|
||||
/// transform function returning Element.
|
||||
///
|
||||
/// See Cursor.map(_:)
|
||||
public final class MapCursor<Base: Cursor, Element> : Cursor {
|
||||
init(_ base: Base, _ transform: @escaping (Base.Element) throws -> Element) {
|
||||
self.base = base
|
||||
self.transform = transform
|
||||
}
|
||||
|
||||
/// Advances to the next element and returns it, or nil if no next
|
||||
/// element exists.
|
||||
public func next() throws -> Element? {
|
||||
guard let element = try base.next() else { return nil }
|
||||
return try transform(element)
|
||||
}
|
||||
|
||||
private let base: Base
|
||||
private let transform: (Base.Element) throws -> Element
|
||||
}
|
||||
|
||||
/// A Cursor whose elements are those of a sequence iterator.
|
||||
public final class IteratorCursor<Base: IteratorProtocol> : Cursor {
|
||||
|
||||
/// Creates a cursor from a sequence iterator.
|
||||
public init(_ base: Base) {
|
||||
self.base = base
|
||||
}
|
||||
|
||||
/// Creates a cursor from a sequence.
|
||||
public init<S: Sequence>(_ s: S) where S.Iterator == Base {
|
||||
self.base = s.makeIterator()
|
||||
}
|
||||
|
||||
/// Advances to the next element and returns it, or nil if no next
|
||||
/// element exists.
|
||||
public func next() -> Base.Element? {
|
||||
return base.next()
|
||||
}
|
||||
|
||||
private var base: Base
|
||||
}
|
||||
|
||||
extension Sequence {
|
||||
|
||||
/// Returns a cursor over the concatenated results of mapping transform
|
||||
/// over self.
|
||||
public func flatMap<SegmentOfResult: Cursor>(_ transform: @escaping (Iterator.Element) throws -> SegmentOfResult) -> FlattenCursor<MapCursor<IteratorCursor<Self.Iterator>, SegmentOfResult>> {
|
||||
return IteratorCursor(self).flatMap(transform)
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,255 @@
|
||||
import Foundation
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import CSQLite
|
||||
#endif
|
||||
|
||||
public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible {
|
||||
public let rawValue: Int32
|
||||
|
||||
public init(rawValue: Int32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
/// A result code limited to the least significant 8 bits of the receiver.
|
||||
/// See https://www.sqlite.org/rescode.html for more information.
|
||||
///
|
||||
/// let resultCode = .SQLITE_CONSTRAINT_FOREIGNKEY
|
||||
/// resultCode.primaryResultCode == .SQLITE_CONSTRAINT // true
|
||||
public var primaryResultCode: ResultCode {
|
||||
return ResultCode(rawValue: rawValue & 0xFF)
|
||||
}
|
||||
|
||||
var isPrimary: Bool {
|
||||
return self == primaryResultCode
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
// sqlite3_errstr was added in SQLite 3.7.15 http://www.sqlite.org/changes.html#version_3_7_15
|
||||
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
return "\(rawValue) (\(String(cString: sqlite3_errstr(rawValue))))"
|
||||
#else
|
||||
if #available(iOS 8.2, OSX 10.10, OSXApplicationExtension 10.10, iOSApplicationExtension 8.2, *) {
|
||||
return "\(rawValue) (\(String(cString: sqlite3_errstr(rawValue))))"
|
||||
} else {
|
||||
return "\(rawValue)"
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static func == (_ lhs: ResultCode, _ rhs: ResultCode) -> Bool {
|
||||
return lhs.rawValue == rhs.rawValue
|
||||
}
|
||||
|
||||
/// Returns true if the code on the left matches the code on the right.
|
||||
///
|
||||
/// Primary result codes match themselves and their extended result codes,
|
||||
/// while extended result codes match only themselves:
|
||||
///
|
||||
/// switch error.extendedResultCode {
|
||||
/// case .SQLITE_CONSTRAINT_FOREIGNKEY: // foreign key constraint error
|
||||
/// case .SQLITE_CONSTRAINT: // any other constraint error
|
||||
/// default: // any other database error
|
||||
/// }
|
||||
public static func ~= (pattern: ResultCode, code: ResultCode) -> Bool {
|
||||
if pattern.isPrimary {
|
||||
return pattern == code.primaryResultCode
|
||||
} else {
|
||||
return pattern == code
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Result codes
|
||||
// https://www.sqlite.org/rescode.html#primary_result_code_list
|
||||
|
||||
public static let SQLITE_OK = ResultCode(rawValue: 0) // Successful result
|
||||
public static let SQLITE_ERROR = ResultCode(rawValue: 1) // SQL error or missing database
|
||||
public static let SQLITE_INTERNAL = ResultCode(rawValue: 2) // Internal logic error in SQLite
|
||||
public static let SQLITE_PERM = ResultCode(rawValue: 3) // Access permission denied
|
||||
public static let SQLITE_ABORT = ResultCode(rawValue: 4) // Callback routine requested an abort
|
||||
public static let SQLITE_BUSY = ResultCode(rawValue: 5) // The database file is locked
|
||||
public static let SQLITE_LOCKED = ResultCode(rawValue: 6) // A table in the database is locked
|
||||
public static let SQLITE_NOMEM = ResultCode(rawValue: 7) // A malloc() failed
|
||||
public static let SQLITE_READONLY = ResultCode(rawValue: 8) // Attempt to write a readonly database
|
||||
public static let SQLITE_INTERRUPT = ResultCode(rawValue: 9) // Operation terminated by sqlite3_interrupt()
|
||||
public static let SQLITE_IOERR = ResultCode(rawValue: 10) // Some kind of disk I/O error occurred
|
||||
public static let SQLITE_CORRUPT = ResultCode(rawValue: 11) // The database disk image is malformed
|
||||
public static let SQLITE_NOTFOUND = ResultCode(rawValue: 12) // Unknown opcode in sqlite3_file_control()
|
||||
public static let SQLITE_FULL = ResultCode(rawValue: 13) // Insertion failed because database is full
|
||||
public static let SQLITE_CANTOPEN = ResultCode(rawValue: 14) // Unable to open the database file
|
||||
public static let SQLITE_PROTOCOL = ResultCode(rawValue: 15) // Database lock protocol error
|
||||
public static let SQLITE_EMPTY = ResultCode(rawValue: 16) // Database is empty
|
||||
public static let SQLITE_SCHEMA = ResultCode(rawValue: 17) // The database schema changed
|
||||
public static let SQLITE_TOOBIG = ResultCode(rawValue: 18) // String or BLOB exceeds size limit
|
||||
public static let SQLITE_CONSTRAINT = ResultCode(rawValue: 19) // Abort due to constraint violation
|
||||
public static let SQLITE_MISMATCH = ResultCode(rawValue: 20) // Data type mismatch
|
||||
public static let SQLITE_MISUSE = ResultCode(rawValue: 21) // Library used incorrectly
|
||||
public static let SQLITE_NOLFS = ResultCode(rawValue: 22) // Uses OS features not supported on host
|
||||
public static let SQLITE_AUTH = ResultCode(rawValue: 23) // Authorization denied
|
||||
public static let SQLITE_FORMAT = ResultCode(rawValue: 24) // Auxiliary database format error
|
||||
public static let SQLITE_RANGE = ResultCode(rawValue: 25) // 2nd parameter to sqlite3_bind out of range
|
||||
public static let SQLITE_NOTADB = ResultCode(rawValue: 26) // File opened that is not a database file
|
||||
public static let SQLITE_NOTICE = ResultCode(rawValue: 27) // Notifications from sqlite3_log()
|
||||
public static let SQLITE_WARNING = ResultCode(rawValue: 28) // Warnings from sqlite3_log()
|
||||
public static let SQLITE_ROW = ResultCode(rawValue: 100) // sqlite3_step() has another row ready
|
||||
public static let SQLITE_DONE = ResultCode(rawValue: 101) // sqlite3_step() has finished executing
|
||||
|
||||
// Extended Result Code
|
||||
// https://www.sqlite.org/rescode.html#extended_result_code_list
|
||||
|
||||
public static let SQLITE_IOERR_READ = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (1<<8)))
|
||||
public static let SQLITE_IOERR_SHORT_READ = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (2<<8)))
|
||||
public static let SQLITE_IOERR_WRITE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (3<<8)))
|
||||
public static let SQLITE_IOERR_FSYNC = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (4<<8)))
|
||||
public static let SQLITE_IOERR_DIR_FSYNC = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (5<<8)))
|
||||
public static let SQLITE_IOERR_TRUNCATE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (6<<8)))
|
||||
public static let SQLITE_IOERR_FSTAT = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (7<<8)))
|
||||
public static let SQLITE_IOERR_UNLOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (8<<8)))
|
||||
public static let SQLITE_IOERR_RDLOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (9<<8)))
|
||||
public static let SQLITE_IOERR_DELETE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (10<<8)))
|
||||
public static let SQLITE_IOERR_BLOCKED = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (11<<8)))
|
||||
public static let SQLITE_IOERR_NOMEM = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (12<<8)))
|
||||
public static let SQLITE_IOERR_ACCESS = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (13<<8)))
|
||||
public static let SQLITE_IOERR_CHECKRESERVEDLOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (14<<8)))
|
||||
public static let SQLITE_IOERR_LOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (15<<8)))
|
||||
public static let SQLITE_IOERR_CLOSE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (16<<8)))
|
||||
public static let SQLITE_IOERR_DIR_CLOSE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (17<<8)))
|
||||
public static let SQLITE_IOERR_SHMOPEN = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (18<<8)))
|
||||
public static let SQLITE_IOERR_SHMSIZE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (19<<8)))
|
||||
public static let SQLITE_IOERR_SHMLOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (20<<8)))
|
||||
public static let SQLITE_IOERR_SHMMAP = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (21<<8)))
|
||||
public static let SQLITE_IOERR_SEEK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (22<<8)))
|
||||
public static let SQLITE_IOERR_DELETE_NOENT = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (23<<8)))
|
||||
public static let SQLITE_IOERR_MMAP = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (24<<8)))
|
||||
public static let SQLITE_IOERR_GETTEMPPATH = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (25<<8)))
|
||||
public static let SQLITE_IOERR_CONVPATH = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (26<<8)))
|
||||
public static let SQLITE_IOERR_VNODE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (27<<8)))
|
||||
public static let SQLITE_IOERR_AUTH = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (28<<8)))
|
||||
public static let SQLITE_LOCKED_SHAREDCACHE = ResultCode(rawValue: (SQLITE_LOCKED.rawValue | (1<<8)))
|
||||
public static let SQLITE_BUSY_RECOVERY = ResultCode(rawValue: (SQLITE_BUSY.rawValue | (1<<8)))
|
||||
public static let SQLITE_BUSY_SNAPSHOT = ResultCode(rawValue: (SQLITE_BUSY.rawValue | (2<<8)))
|
||||
public static let SQLITE_CANTOPEN_NOTEMPDIR = ResultCode(rawValue: (SQLITE_CANTOPEN.rawValue | (1<<8)))
|
||||
public static let SQLITE_CANTOPEN_ISDIR = ResultCode(rawValue: (SQLITE_CANTOPEN.rawValue | (2<<8)))
|
||||
public static let SQLITE_CANTOPEN_FULLPATH = ResultCode(rawValue: (SQLITE_CANTOPEN.rawValue | (3<<8)))
|
||||
public static let SQLITE_CANTOPEN_CONVPATH = ResultCode(rawValue: (SQLITE_CANTOPEN.rawValue | (4<<8)))
|
||||
public static let SQLITE_CORRUPT_VTAB = ResultCode(rawValue: (SQLITE_CORRUPT.rawValue | (1<<8)))
|
||||
public static let SQLITE_READONLY_RECOVERY = ResultCode(rawValue: (SQLITE_READONLY.rawValue | (1<<8)))
|
||||
public static let SQLITE_READONLY_CANTLOCK = ResultCode(rawValue: (SQLITE_READONLY.rawValue | (2<<8)))
|
||||
public static let SQLITE_READONLY_ROLLBACK = ResultCode(rawValue: (SQLITE_READONLY.rawValue | (3<<8)))
|
||||
public static let SQLITE_READONLY_DBMOVED = ResultCode(rawValue: (SQLITE_READONLY.rawValue | (4<<8)))
|
||||
public static let SQLITE_ABORT_ROLLBACK = ResultCode(rawValue: (SQLITE_ABORT.rawValue | (2<<8)))
|
||||
public static let SQLITE_CONSTRAINT_CHECK = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (1<<8)))
|
||||
public static let SQLITE_CONSTRAINT_COMMITHOOK = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (2<<8)))
|
||||
public static let SQLITE_CONSTRAINT_FOREIGNKEY = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (3<<8)))
|
||||
public static let SQLITE_CONSTRAINT_FUNCTION = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (4<<8)))
|
||||
public static let SQLITE_CONSTRAINT_NOTNULL = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (5<<8)))
|
||||
public static let SQLITE_CONSTRAINT_PRIMARYKEY = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (6<<8)))
|
||||
public static let SQLITE_CONSTRAINT_TRIGGER = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (7<<8)))
|
||||
public static let SQLITE_CONSTRAINT_UNIQUE = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (8<<8)))
|
||||
public static let SQLITE_CONSTRAINT_VTAB = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (9<<8)))
|
||||
public static let SQLITE_CONSTRAINT_ROWID = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (10<<8)))
|
||||
public static let SQLITE_NOTICE_RECOVER_WAL = ResultCode(rawValue: (SQLITE_NOTICE.rawValue | (1<<8)))
|
||||
public static let SQLITE_NOTICE_RECOVER_ROLLBACK = ResultCode(rawValue: (SQLITE_NOTICE.rawValue | (2<<8)))
|
||||
public static let SQLITE_WARNING_AUTOINDEX = ResultCode(rawValue: (SQLITE_WARNING.rawValue | (1<<8)))
|
||||
public static let SQLITE_AUTH_USER = ResultCode(rawValue: (SQLITE_AUTH.rawValue | (1<<8)))
|
||||
public static let SQLITE_OK_LOAD_PERMANENTLY = ResultCode(rawValue: (SQLITE_OK.rawValue | (1<<8)))
|
||||
|
||||
}
|
||||
|
||||
/// DatabaseError wraps an SQLite error.
|
||||
public struct DatabaseError : Error {
|
||||
|
||||
/// The SQLite error code (see
|
||||
/// https://www.sqlite.org/rescode.html#primary_result_code_list).
|
||||
///
|
||||
/// do {
|
||||
/// ...
|
||||
/// } catch let error as DatabaseError where error.resultCode == .SQL_CONSTRAINT {
|
||||
/// // A constraint error
|
||||
/// }
|
||||
///
|
||||
/// This property returns a "primary result code", that is to say the least
|
||||
/// significant 8 bits of any SQLite result code. See
|
||||
/// https://www.sqlite.org/rescode.html for more information.
|
||||
///
|
||||
/// See also `extendedResultCode`.
|
||||
public var resultCode: ResultCode {
|
||||
return extendedResultCode.primaryResultCode
|
||||
}
|
||||
|
||||
/// The SQLite extended error code (see
|
||||
/// https://www.sqlite.org/rescode.html#extended_result_code_list).
|
||||
///
|
||||
/// do {
|
||||
/// ...
|
||||
/// } catch let error as DatabaseError where error.extendedResultCode == .SQLITE_CONSTRAINT_FOREIGNKEY {
|
||||
/// // A foreign key constraint error
|
||||
/// }
|
||||
///
|
||||
/// See also `resultCode`.
|
||||
public let extendedResultCode: ResultCode
|
||||
|
||||
/// The SQLite error message.
|
||||
public let message: String?
|
||||
|
||||
/// The SQL query that yielded the error (if relevant).
|
||||
public let sql: String?
|
||||
|
||||
/// Creates a Database Error
|
||||
public init(resultCode: ResultCode = .SQLITE_ERROR, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) {
|
||||
self.extendedResultCode = resultCode
|
||||
self.message = message
|
||||
self.sql = sql
|
||||
self.arguments = arguments
|
||||
}
|
||||
|
||||
/// Creates a Database Error with a raw Int32 result code.
|
||||
///
|
||||
/// This initializer is not public because library user is not supposed to
|
||||
/// be exposed to raw result codes.
|
||||
init(resultCode: Int32, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) {
|
||||
self.init(resultCode: ResultCode(rawValue: resultCode), message: message, sql: sql, arguments: arguments)
|
||||
}
|
||||
|
||||
// MARK: Not public
|
||||
|
||||
/// The query arguments that yielded the error (if relevant).
|
||||
/// Not public because the StatementArguments class has no public method.
|
||||
let arguments: StatementArguments?
|
||||
}
|
||||
|
||||
extension DatabaseError: CustomStringConvertible {
|
||||
/// A textual representation of `self`.
|
||||
public var description: String {
|
||||
var description = "SQLite error \(extendedResultCode.rawValue)"
|
||||
if let sql = sql {
|
||||
description += " with statement `\(sql)`"
|
||||
}
|
||||
if let arguments = arguments, !arguments.isEmpty {
|
||||
description += " arguments \(arguments)"
|
||||
}
|
||||
if let message = message {
|
||||
description += ": \(message)"
|
||||
}
|
||||
return description
|
||||
}
|
||||
}
|
||||
|
||||
extension DatabaseError : CustomNSError {
|
||||
|
||||
/// NSError bridging: the domain of the error.
|
||||
public static var errorDomain: String {
|
||||
return "GRDB.DatabaseError"
|
||||
}
|
||||
|
||||
/// NSError bridging: the error code within the given domain.
|
||||
public var errorCode: Int {
|
||||
return Int(extendedResultCode.rawValue)
|
||||
}
|
||||
|
||||
/// NSError bridging: the user-info dictionary.
|
||||
public var errorUserInfo: [String : Any] {
|
||||
return [NSLocalizedDescriptionKey: description]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
#if SWIFT_PACKAGE
|
||||
import CSQLite
|
||||
#endif
|
||||
|
||||
/// An SQL function or aggregate.
|
||||
public final class DatabaseFunction {
|
||||
public let name: String
|
||||
let argumentCount: Int32?
|
||||
let pure: Bool
|
||||
private let kind: Kind
|
||||
fileprivate var nArg: Int32 { return argumentCount ?? -1 }
|
||||
fileprivate var eTextRep: Int32 { return (SQLITE_UTF8 | (pure ? SQLITE_DETERMINISTIC : 0)) }
|
||||
|
||||
/// Returns an SQL function.
|
||||
///
|
||||
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
|
||||
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
|
||||
/// return nil
|
||||
/// }
|
||||
/// return int + 1
|
||||
/// }
|
||||
/// db.add(function: fn)
|
||||
/// try Int.fetchOne(db, "SELECT succ(1)")! // 2
|
||||
///
|
||||
/// - parameters:
|
||||
/// - name: The function name.
|
||||
/// - argumentCount: The number of arguments of the function. If
|
||||
/// omitted, or nil, the function accepts any number of arguments.
|
||||
/// - pure: Whether the function is "pure", which means that its results
|
||||
/// only depends on its inputs. When a function is pure, SQLite has
|
||||
/// the opportunity to perform additional optimizations. Default value
|
||||
/// is false.
|
||||
/// - function: A function that takes an array of DatabaseValue
|
||||
/// arguments, and returns an optional DatabaseValueConvertible such
|
||||
/// as Int, String, NSDate, etc. The array is guaranteed to have
|
||||
/// exactly *argumentCount* elements, provided *argumentCount* is
|
||||
/// not nil.
|
||||
public init(_ name: String, argumentCount: Int32? = nil, pure: Bool = false, function: @escaping ([DatabaseValue]) throws -> DatabaseValueConvertible?) {
|
||||
self.name = name
|
||||
self.argumentCount = argumentCount
|
||||
self.pure = pure
|
||||
self.kind = .function{ (argc, argv) in
|
||||
let arguments = (0..<Int(argc)).map { index in
|
||||
DatabaseValue(sqliteValue: argv.unsafelyUnwrapped[index]!)
|
||||
}
|
||||
return try function(arguments)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an SQL aggregate function.
|
||||
///
|
||||
/// struct MySum : DatabaseAggregate {
|
||||
/// var sum: Int = 0
|
||||
///
|
||||
/// mutating func step(_ dbValues: [DatabaseValue]) {
|
||||
/// if let int = Int.fromDatabaseValue(dbValues[0]) {
|
||||
/// sum += int
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// func finalize() -> DatabaseValueConvertible? {
|
||||
/// return sum
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// let dbQueue = DatabaseQueue()
|
||||
/// let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
|
||||
/// dbQueue.add(function: fn)
|
||||
/// try dbQueue.inDatabase { db in
|
||||
/// try db.execute("CREATE TABLE test(i)")
|
||||
/// try db.execute("INSERT INTO test(i) VALUES (1)")
|
||||
/// try db.execute("INSERT INTO test(i) VALUES (2)")
|
||||
/// try Int.fetchOne(db, "SELECT mysum(i) FROM test")! // 3
|
||||
/// }
|
||||
///
|
||||
/// - parameters:
|
||||
/// - name: The function name.
|
||||
/// - argumentCount: The number of arguments of the aggregate. If
|
||||
/// omitted, or nil, the aggregate accepts any number of arguments.
|
||||
/// - pure: Whether the aggregate is "pure", which means that its
|
||||
/// results only depends on its inputs. When an aggregate is pure,
|
||||
/// SQLite has the opportunity to perform additional optimizations.
|
||||
/// Default value is false.
|
||||
/// - aggregate: A type that implements the DatabaseAggregate protocol.
|
||||
/// For each step of the aggregation, its `step` method is called with
|
||||
/// an array of DatabaseValue arguments. The array is guaranteed to
|
||||
/// have exactly *argumentCount* elements, provided *argumentCount* is
|
||||
/// not nil.
|
||||
public init<Aggregate: DatabaseAggregate>(_ name: String, argumentCount: Int32? = nil, pure: Bool = false, aggregate: Aggregate.Type) {
|
||||
self.name = name
|
||||
self.argumentCount = argumentCount
|
||||
self.pure = pure
|
||||
self.kind = .aggregate { return Aggregate() }
|
||||
}
|
||||
|
||||
/// Calls sqlite3_create_function_v2
|
||||
/// See https://sqlite.org/c3ref/create_function.html
|
||||
func install(in db: Database) {
|
||||
// Retain the function definition
|
||||
let definition = kind.definition
|
||||
let definitionP = Unmanaged.passRetained(definition).toOpaque()
|
||||
|
||||
let code = sqlite3_create_function_v2(
|
||||
db.sqliteConnection,
|
||||
name,
|
||||
nArg,
|
||||
eTextRep,
|
||||
definitionP,
|
||||
kind.xFunc,
|
||||
kind.xStep,
|
||||
kind.xFinal,
|
||||
{ definitionP in
|
||||
// Release the function definition
|
||||
Unmanaged<AnyObject>.fromOpaque(definitionP!).release()
|
||||
})
|
||||
|
||||
guard code == SQLITE_OK else {
|
||||
// Assume a GRDB bug: there is no point throwing any error.
|
||||
fatalError(DatabaseError(resultCode: code, message: db.lastErrorMessage).description)
|
||||
}
|
||||
}
|
||||
|
||||
/// Calls sqlite3_create_function_v2
|
||||
/// See https://sqlite.org/c3ref/create_function.html
|
||||
func uninstall(in db: Database) {
|
||||
let code = sqlite3_create_function_v2(
|
||||
db.sqliteConnection,
|
||||
name,
|
||||
nArg,
|
||||
eTextRep,
|
||||
nil, nil, nil, nil, nil)
|
||||
|
||||
guard code == SQLITE_OK else {
|
||||
// Assume a GRDB bug: there is no point throwing any error.
|
||||
fatalError(DatabaseError(resultCode: code, message: db.lastErrorMessage).description)
|
||||
}
|
||||
}
|
||||
|
||||
/// The way to compute the result of a function.
|
||||
/// Feeds the `pApp` parameter of sqlite3_create_function_v2
|
||||
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
|
||||
private class FunctionDefinition {
|
||||
let compute: (Int32, UnsafeMutablePointer<OpaquePointer?>?) throws -> DatabaseValueConvertible?
|
||||
init(compute: @escaping (Int32, UnsafeMutablePointer<OpaquePointer?>?) throws -> DatabaseValueConvertible?) {
|
||||
self.compute = compute
|
||||
}
|
||||
}
|
||||
|
||||
/// The way to start an aggregate.
|
||||
/// Feeds the `pApp` parameter of sqlite3_create_function_v2
|
||||
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
|
||||
private class AggregateDefinition {
|
||||
let makeAggregate: () -> DatabaseAggregate
|
||||
init(makeAggregate: @escaping () -> DatabaseAggregate) {
|
||||
self.makeAggregate = makeAggregate
|
||||
}
|
||||
}
|
||||
|
||||
/// The current state of an aggregate, storable in SQLite
|
||||
private class AggregateContext {
|
||||
var aggregate: DatabaseAggregate
|
||||
var hasErrored = false
|
||||
init(aggregate: DatabaseAggregate) {
|
||||
self.aggregate = aggregate
|
||||
}
|
||||
}
|
||||
|
||||
/// A function kind: an "SQL function" or an "aggregate".
|
||||
/// See http://sqlite.org/capi3ref.html#sqlite3_create_function
|
||||
private enum Kind {
|
||||
/// A regular function: SELECT f(1)
|
||||
case function((Int32, UnsafeMutablePointer<OpaquePointer?>?) throws -> DatabaseValueConvertible?)
|
||||
|
||||
/// An aggregate: SELECT f(foo) FROM bar GROUP BY baz
|
||||
case aggregate(() -> DatabaseAggregate)
|
||||
|
||||
/// Feeds the `pApp` parameter of sqlite3_create_function_v2
|
||||
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
|
||||
var definition: AnyObject {
|
||||
switch self {
|
||||
case .function(let compute):
|
||||
return FunctionDefinition(compute: compute)
|
||||
case .aggregate(let makeAggregate):
|
||||
return AggregateDefinition(makeAggregate: makeAggregate)
|
||||
}
|
||||
}
|
||||
|
||||
/// Feeds the `xFunc` parameter of sqlite3_create_function_v2
|
||||
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
|
||||
var xFunc: (@convention(c) (OpaquePointer?, Int32, UnsafeMutablePointer<OpaquePointer?>?) -> Void)? {
|
||||
guard case .function = self else { return nil }
|
||||
return { (sqliteContext, argc, argv) in
|
||||
let definition = Unmanaged<FunctionDefinition>.fromOpaque(sqlite3_user_data(sqliteContext)).takeUnretainedValue()
|
||||
do {
|
||||
try DatabaseFunction.report(
|
||||
result: definition.compute(argc, argv),
|
||||
in: sqliteContext)
|
||||
} catch {
|
||||
DatabaseFunction.report(error: error, in: sqliteContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Feeds the `xStep` parameter of sqlite3_create_function_v2
|
||||
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
|
||||
var xStep: (@convention(c) (OpaquePointer?, Int32, UnsafeMutablePointer<OpaquePointer?>?) -> Void)? {
|
||||
guard case .aggregate = self else { return nil }
|
||||
return { (sqliteContext, argc, argv) in
|
||||
let aggregateContextU = DatabaseFunction.unmanagedAggregateContext(sqliteContext)
|
||||
let aggregateContext = aggregateContextU.takeUnretainedValue()
|
||||
assert(!aggregateContext.hasErrored)
|
||||
do {
|
||||
let arguments = (0..<Int(argc)).map { index in
|
||||
DatabaseValue(sqliteValue: argv.unsafelyUnwrapped[index]!)
|
||||
}
|
||||
try aggregateContext.aggregate.step(arguments)
|
||||
} catch {
|
||||
aggregateContext.hasErrored = true
|
||||
DatabaseFunction.report(error: error, in: sqliteContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Feeds the `xFinal` parameter of sqlite3_create_function_v2
|
||||
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
|
||||
var xFinal: (@convention(c) (OpaquePointer?) -> Void)? {
|
||||
guard case .aggregate = self else { return nil }
|
||||
return { (sqliteContext) in
|
||||
let aggregateContextU = DatabaseFunction.unmanagedAggregateContext(sqliteContext)
|
||||
let aggregateContext = aggregateContextU.takeUnretainedValue()
|
||||
aggregateContextU.release()
|
||||
|
||||
guard !aggregateContext.hasErrored else {
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
try DatabaseFunction.report(
|
||||
result: aggregateContext.aggregate.finalize(),
|
||||
in: sqliteContext)
|
||||
} catch {
|
||||
DatabaseFunction.report(error: error, in: sqliteContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function that extracts the current state of an aggregate from an
|
||||
/// sqlite function execution context.
|
||||
///
|
||||
/// The result must be released when the aggregate concludes.
|
||||
///
|
||||
/// See https://sqlite.org/c3ref/context.html
|
||||
/// See https://sqlite.org/c3ref/aggregate_context.html
|
||||
private static func unmanagedAggregateContext(_ sqliteContext: OpaquePointer?) -> Unmanaged<AggregateContext> {
|
||||
// The current aggregate buffer
|
||||
let stride = MemoryLayout<Unmanaged<AggregateContext>>.stride
|
||||
let aggregateContextBufferP = UnsafeMutableRawBufferPointer(start: sqlite3_aggregate_context(sqliteContext, Int32(stride))!, count: stride)
|
||||
|
||||
if aggregateContextBufferP.contains(where: { $0 != 0 }) {
|
||||
// Buffer contains non-null pointer: load aggregate context
|
||||
let aggregateContextP = aggregateContextBufferP.baseAddress!.assumingMemoryBound(to: Unmanaged<AggregateContext>.self)
|
||||
return aggregateContextP.pointee
|
||||
} else {
|
||||
// Buffer contains null pointer: create aggregate context...
|
||||
let aggregate = Unmanaged<AggregateDefinition>.fromOpaque(sqlite3_user_data(sqliteContext))
|
||||
.takeUnretainedValue()
|
||||
.makeAggregate()
|
||||
let aggregateContext = AggregateContext(aggregate: aggregate)
|
||||
|
||||
// retain and store in SQLite's buffer
|
||||
let aggregateContextU = Unmanaged.passRetained(aggregateContext)
|
||||
var aggregateContextP = aggregateContextU.toOpaque()
|
||||
withUnsafeBytes(of: &aggregateContextP) {
|
||||
aggregateContextBufferP.copyBytes(from: $0)
|
||||
}
|
||||
return aggregateContextU
|
||||
}
|
||||
}
|
||||
|
||||
private static func report(result: DatabaseValueConvertible?, in sqliteContext: OpaquePointer?) {
|
||||
switch result?.databaseValue.storage ?? .null {
|
||||
case .null:
|
||||
sqlite3_result_null(sqliteContext)
|
||||
case .int64(let int64):
|
||||
sqlite3_result_int64(sqliteContext, int64)
|
||||
case .double(let double):
|
||||
sqlite3_result_double(sqliteContext, double)
|
||||
case .string(let string):
|
||||
sqlite3_result_text(sqliteContext, string, -1, SQLITE_TRANSIENT)
|
||||
case .blob(let data):
|
||||
data.withUnsafeBytes { bytes in
|
||||
sqlite3_result_blob(sqliteContext, bytes, Int32(data.count), SQLITE_TRANSIENT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static func report(error: Error, in sqliteContext: OpaquePointer?) {
|
||||
if let error = error as? DatabaseError {
|
||||
if let message = error.message {
|
||||
sqlite3_result_error(sqliteContext, message, -1)
|
||||
}
|
||||
sqlite3_result_error_code(sqliteContext, error.extendedResultCode.rawValue)
|
||||
} else {
|
||||
sqlite3_result_error(sqliteContext, "\(error)", -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension DatabaseFunction : Hashable {
|
||||
/// The hash value
|
||||
public var hashValue: Int {
|
||||
return name.hashValue ^ nArg.hashValue
|
||||
}
|
||||
|
||||
/// Two functions are equal if they share the same name and arity.
|
||||
public static func == (lhs: DatabaseFunction, rhs: DatabaseFunction) -> Bool {
|
||||
return lhs.name == rhs.name && lhs.nArg == rhs.nArg
|
||||
}
|
||||
}
|
||||
|
||||
/// The protocol for custom SQLite aggregates.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// struct MySum : DatabaseAggregate {
|
||||
/// var sum: Int = 0
|
||||
///
|
||||
/// mutating func step(_ dbValues: [DatabaseValue]) {
|
||||
/// if let int = Int.fromDatabaseValue(dbValues[0]) {
|
||||
/// sum += int
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// func finalize() -> DatabaseValueConvertible? {
|
||||
/// return sum
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// let dbQueue = DatabaseQueue()
|
||||
/// let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
|
||||
/// dbQueue.add(function: fn)
|
||||
/// try dbQueue.inDatabase { db in
|
||||
/// try db.execute("CREATE TABLE test(i)")
|
||||
/// try db.execute("INSERT INTO test(i) VALUES (1)")
|
||||
/// try db.execute("INSERT INTO test(i) VALUES (2)")
|
||||
/// try Int.fetchOne(db, "SELECT mysum(i) FROM test")! // 3
|
||||
/// }
|
||||
public protocol DatabaseAggregate {
|
||||
/// Creates an aggregate.
|
||||
init()
|
||||
|
||||
/// This method is called at each step of the aggregation.
|
||||
///
|
||||
/// The dbValues argument contains as many values as given to the SQL
|
||||
/// aggregate function.
|
||||
///
|
||||
/// -- One value
|
||||
/// SELECT maxLength(name) FROM persons
|
||||
///
|
||||
/// -- Two values
|
||||
/// SELECT maxFullNameLength(firstName, lastName) FROM persons
|
||||
///
|
||||
/// This method is never called after the finalize() method has been called.
|
||||
mutating func step(_ dbValues: [DatabaseValue]) throws
|
||||
|
||||
/// Returns the final result
|
||||
func finalize() throws -> DatabaseValueConvertible?
|
||||
}
|
||||
@@ -0,0 +1,599 @@
|
||||
import Foundation
|
||||
|
||||
#if os(iOS)
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import CSQLite
|
||||
#endif
|
||||
|
||||
/// A DatabasePool grants concurrent accesses to an SQLite database.
|
||||
public final class DatabasePool {
|
||||
|
||||
// MARK: - Initializers
|
||||
|
||||
/// Opens the SQLite database at path *path*.
|
||||
///
|
||||
/// let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
|
||||
///
|
||||
/// Database connections get closed when the database pool gets deallocated.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - path: The path to the database file.
|
||||
/// - configuration: A configuration.
|
||||
/// - maximumReaderCount: The maximum number of readers. Default is 5.
|
||||
/// - throws: A DatabaseError whenever an SQLite error occurs.
|
||||
public init(path: String, configuration: Configuration = Configuration()) throws {
|
||||
GRDBPrecondition(configuration.maximumReaderCount > 0, "configuration.maximumReaderCount must be at least 1")
|
||||
|
||||
// Writer and readers share the same database schema cache
|
||||
let sharedSchemaCache = SharedDatabaseSchemaCache()
|
||||
|
||||
// Writer
|
||||
writer = try SerializedDatabase(
|
||||
path: path,
|
||||
configuration: configuration,
|
||||
schemaCache: sharedSchemaCache)
|
||||
|
||||
// Activate WAL Mode unless readonly
|
||||
if !configuration.readonly {
|
||||
try writer.sync { db in
|
||||
let journalMode = try String.fetchOne(db, "PRAGMA journal_mode = WAL")
|
||||
guard journalMode == "wal" else {
|
||||
throw DatabaseError(message: "could not activate WAL Mode at path: \(path)")
|
||||
}
|
||||
|
||||
// https://www.sqlite.org/pragma.html#pragma_synchronous
|
||||
// > Many applications choose NORMAL when in WAL mode
|
||||
try db.execute("PRAGMA synchronous = NORMAL")
|
||||
|
||||
if !FileManager.default.fileExists(atPath: path + "-wal") {
|
||||
// Create the -wal file if it does not exist yet. This
|
||||
// avoids an SQLITE_CANTOPEN (14) error whenever a user
|
||||
// opens a pool to an existing non-WAL database, and
|
||||
// attempts to read from it.
|
||||
// See https://github.com/groue/GRDB.swift/issues/102
|
||||
try db.execute("CREATE TABLE grdb_issue_102 (id INTEGER PRIMARY KEY); DROP TABLE grdb_issue_102;")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Readers
|
||||
readerConfig = configuration
|
||||
readerConfig.readonly = true
|
||||
readerConfig.defaultTransactionKind = .deferred // Make it the default for readers. Other transaction kinds are forbidden by SQLite in read-only connections.
|
||||
readerPool = Pool(maximumCount: configuration.maximumReaderCount, makeElement: { [unowned self] in
|
||||
let reader = try SerializedDatabase(
|
||||
path: path,
|
||||
configuration: self.readerConfig,
|
||||
schemaCache: sharedSchemaCache)
|
||||
|
||||
reader.sync { db in
|
||||
for function in self.functions {
|
||||
db.add(function: function)
|
||||
}
|
||||
for collation in self.collations {
|
||||
db.add(collation: collation)
|
||||
}
|
||||
}
|
||||
|
||||
return reader
|
||||
})
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
deinit {
|
||||
// Undo job done in setupMemoryManagement()
|
||||
//
|
||||
// https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error
|
||||
// Explicit unregistration is required before iOS 9 and OS X 10.11.
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: - Configuration
|
||||
|
||||
/// The path to the database.
|
||||
public var path: String {
|
||||
return writer.path
|
||||
}
|
||||
|
||||
|
||||
// MARK: - WAL Management
|
||||
|
||||
/// Runs a WAL checkpoint
|
||||
///
|
||||
/// See https://www.sqlite.org/wal.html and
|
||||
/// https://www.sqlite.org/c3ref/wal_checkpoint_v2.html) for
|
||||
/// more information.
|
||||
///
|
||||
/// - parameter kind: The checkpoint mode (default passive)
|
||||
public func checkpoint(_ kind: Database.CheckpointMode = .passive) throws {
|
||||
try write { db in
|
||||
// TODO: read https://www.sqlite.org/c3ref/wal_checkpoint_v2.html and
|
||||
// check whether we need a busy handler on writer and/or readers
|
||||
// when kind is not .Passive.
|
||||
let code = sqlite3_wal_checkpoint_v2(db.sqliteConnection, nil, kind.rawValue, nil, nil)
|
||||
guard code == SQLITE_OK else {
|
||||
throw DatabaseError(resultCode: code, message: db.lastErrorMessage, sql: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Memory management
|
||||
|
||||
/// Free as much memory as possible.
|
||||
///
|
||||
/// This method blocks the current thread until all database accesses are completed.
|
||||
///
|
||||
/// See also setupMemoryManagement(application:)
|
||||
public func releaseMemory() {
|
||||
// TODO: test that this method blocks the current thread until all database accesses are completed.
|
||||
write { $0.releaseMemory() }
|
||||
readerPool.forEach { reader in
|
||||
reader.sync { $0.releaseMemory() }
|
||||
}
|
||||
readerPool.clear()
|
||||
}
|
||||
|
||||
|
||||
#if os(iOS)
|
||||
/// Listens to UIApplicationDidEnterBackgroundNotification and
|
||||
/// UIApplicationDidReceiveMemoryWarningNotification in order to release
|
||||
/// as much memory as possible.
|
||||
///
|
||||
/// - param application: The UIApplication that will start a background
|
||||
/// task to let the database pool release its memory when the application
|
||||
/// enters background.
|
||||
public func setupMemoryManagement(in application: UIApplication) {
|
||||
self.application = application
|
||||
let center = NotificationCenter.default
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidReceiveMemoryWarning(_:)), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
|
||||
}
|
||||
|
||||
private var application: UIApplication!
|
||||
|
||||
@objc private func applicationDidEnterBackground(_ notification: NSNotification) {
|
||||
guard let application = application else {
|
||||
return
|
||||
}
|
||||
|
||||
var task: UIBackgroundTaskIdentifier! = nil
|
||||
task = application.beginBackgroundTask(expirationHandler: nil)
|
||||
|
||||
if task == UIBackgroundTaskInvalid {
|
||||
// Perform releaseMemory() synchronously.
|
||||
releaseMemory()
|
||||
} else {
|
||||
// Perform releaseMemory() asynchronously.
|
||||
DispatchQueue.global().async {
|
||||
self.releaseMemory()
|
||||
application.endBackgroundTask(task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func applicationDidReceiveMemoryWarning(_ notification: NSNotification) {
|
||||
DispatchQueue.global().async {
|
||||
self.releaseMemory()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: - Not public
|
||||
|
||||
fileprivate let writer: SerializedDatabase
|
||||
fileprivate var readerConfig: Configuration
|
||||
fileprivate var readerPool: Pool<SerializedDatabase>! = nil // var and nil-initialized so that we can use `self` when creating readerPool in DatabasePool.init()
|
||||
|
||||
fileprivate var functions = Set<DatabaseFunction>()
|
||||
fileprivate var collations = Set<DatabaseCollation>()
|
||||
}
|
||||
|
||||
|
||||
// =========================================================================
|
||||
// MARK: - Encryption
|
||||
|
||||
#if SQLITE_HAS_CODEC
|
||||
extension DatabasePool {
|
||||
|
||||
/// Changes the passphrase of an encrypted database
|
||||
public func change(passphrase: String) throws {
|
||||
try readerPool.clear(andThen: {
|
||||
try write { try $0.change(passphrase: passphrase) }
|
||||
readerConfig.passphrase = passphrase
|
||||
})
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// =========================================================================
|
||||
// MARK: - DatabaseReader
|
||||
|
||||
extension DatabasePool : DatabaseReader {
|
||||
|
||||
// MARK: - Read From Database
|
||||
|
||||
/// Synchronously executes a read-only block in a protected dispatch queue,
|
||||
/// and returns its result. The block is wrapped in a deferred transaction.
|
||||
///
|
||||
/// let persons = try dbPool.read { db in
|
||||
/// try Person.fetchAll(...)
|
||||
/// }
|
||||
///
|
||||
/// The block is completely isolated. Eventual concurrent database updates
|
||||
/// are *not visible* inside the block:
|
||||
///
|
||||
/// try dbPool.read { db in
|
||||
/// // Those two values are guaranteed to be equal, even if the
|
||||
/// // `wines` table is modified between the two requests:
|
||||
/// let count1 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// }
|
||||
///
|
||||
/// try dbPool.read { db in
|
||||
/// // Now this value may be different:
|
||||
/// let count = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// }
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block, or any DatabaseError that would
|
||||
/// happen while establishing the read access to the database.
|
||||
public func read<T>(_ block: (Database) throws -> T) throws -> T {
|
||||
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
|
||||
return try readerPool.get { reader in
|
||||
try reader.sync { db in
|
||||
var result: T? = nil
|
||||
// The block isolation comes from the DEFERRED transaction.
|
||||
// See DatabasePoolTests.testReadMethodIsolationOfBlock().
|
||||
try db.inTransaction(.deferred) {
|
||||
result = try block(db)
|
||||
return .commit
|
||||
}
|
||||
return result!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Synchronously executes a read-only block in a protected dispatch queue,
|
||||
/// and returns its result.
|
||||
///
|
||||
/// The block argument is not isolated: eventual concurrent database updates
|
||||
/// are visible inside the block:
|
||||
///
|
||||
/// try dbPool.unsafeRead { db in
|
||||
/// // Those two values may be different because some other thread
|
||||
/// // may have inserted or deleted a wine between the two requests:
|
||||
/// let count1 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// }
|
||||
///
|
||||
/// Cursor iteration is safe, though:
|
||||
///
|
||||
/// try dbPool.unsafeRead { db in
|
||||
/// // No concurrent update can mess with this iteration:
|
||||
/// let rows = try Row.fetchCursor(db, "SELECT ...")
|
||||
/// while let row = try rows.next() { ... }
|
||||
/// }
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block, or any DatabaseError that would
|
||||
/// happen while establishing the read access to the database.
|
||||
public func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T {
|
||||
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
|
||||
return try readerPool.get { reader in
|
||||
try reader.sync(block)
|
||||
}
|
||||
}
|
||||
|
||||
/// Synchronously executes a read-only block in a protected dispatch queue,
|
||||
/// and returns its result.
|
||||
///
|
||||
/// The block argument is not isolated: eventual concurrent database updates
|
||||
/// are visible inside the block:
|
||||
///
|
||||
/// try dbPool.unsafeReentrantRead { db in
|
||||
/// // Those two values may be different because some other thread
|
||||
/// // may have inserted or deleted a wine between the two requests:
|
||||
/// let count1 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// }
|
||||
///
|
||||
/// Cursor iteration is safe, though:
|
||||
///
|
||||
/// try dbPool.unsafeReentrantRead { db in
|
||||
/// // No concurrent update can mess with this iteration:
|
||||
/// let rows = try Row.fetchCursor(db, "SELECT ...")
|
||||
/// while let row = try rows.next() { ... }
|
||||
/// }
|
||||
///
|
||||
/// This method is reentrant. It should be avoided because it fosters
|
||||
/// dangerous concurrency practices.
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block, or any DatabaseError that would
|
||||
/// happen while establishing the read access to the database.
|
||||
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
|
||||
if let reader = currentReader {
|
||||
return try reader.reentrantSync(block)
|
||||
} else {
|
||||
return try readerPool.get { reader in
|
||||
try reader.sync(block)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reader that can be used from the current dispatch queue,
|
||||
/// if any.
|
||||
private var currentReader: SerializedDatabase? {
|
||||
var readers: [SerializedDatabase] = []
|
||||
readerPool.forEach { reader in
|
||||
// We can't check for reader.onValidQueue here because
|
||||
// Pool.forEach() runs its closure argument in some arbitrary
|
||||
// dispatch queue. We thus extract the reader so that we can query
|
||||
// it below.
|
||||
readers.append(reader)
|
||||
}
|
||||
|
||||
// Now the readers array contains some readers. The pool readers may
|
||||
// already be different, because some other thread may have started
|
||||
// a new read, for example.
|
||||
//
|
||||
// This doesn't matter: the reader we are looking for is already on
|
||||
// its own dispatch queue. If it exists, is still in use, thus still
|
||||
// in the pool, and thus still relevant for our check:
|
||||
return readers.first { $0.onValidQueue }
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Functions
|
||||
|
||||
/// Add or redefine an SQL function.
|
||||
///
|
||||
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
|
||||
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
|
||||
/// return nil
|
||||
/// }
|
||||
/// return int + 1
|
||||
/// }
|
||||
/// dbPool.add(function: fn)
|
||||
/// try dbPool.read { db in
|
||||
/// try Int.fetchOne(db, "SELECT succ(1)") // 2
|
||||
/// }
|
||||
public func add(function: DatabaseFunction) {
|
||||
functions.update(with: function)
|
||||
write { $0.add(function: function) }
|
||||
readerPool.forEach { reader in
|
||||
reader.sync { $0.add(function: function) }
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove an SQL function.
|
||||
public func remove(function: DatabaseFunction) {
|
||||
functions.remove(function)
|
||||
write { $0.remove(function: function) }
|
||||
readerPool.forEach { reader in
|
||||
reader.sync { $0.remove(function: function) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Collations
|
||||
|
||||
/// Add or redefine a collation.
|
||||
///
|
||||
/// let collation = DatabaseCollation("localized_standard") { (string1, string2) in
|
||||
/// return (string1 as NSString).localizedStandardCompare(string2)
|
||||
/// }
|
||||
/// dbPool.add(collation: collation)
|
||||
/// try dbPool.write { db in
|
||||
/// try db.execute("CREATE TABLE files (name TEXT COLLATE LOCALIZED_STANDARD")
|
||||
/// }
|
||||
public func add(collation: DatabaseCollation) {
|
||||
collations.update(with: collation)
|
||||
write { $0.add(collation: collation) }
|
||||
readerPool.forEach { reader in
|
||||
reader.sync { $0.add(collation: collation) }
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove a collation.
|
||||
public func remove(collation: DatabaseCollation) {
|
||||
collations.remove(collation)
|
||||
write { $0.remove(collation: collation) }
|
||||
readerPool.forEach { reader in
|
||||
reader.sync { $0.remove(collation: collation) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// =========================================================================
|
||||
// MARK: - DatabaseWriter
|
||||
|
||||
extension DatabasePool : DatabaseWriter {
|
||||
|
||||
// MARK: - Writing in Database
|
||||
|
||||
/// Synchronously executes an update block in a protected dispatch queue,
|
||||
/// and returns its result.
|
||||
///
|
||||
/// Eventual concurrent database updates are postponed until the block
|
||||
/// has executed.
|
||||
///
|
||||
/// try dbPool.write { db in
|
||||
/// try db.execute(...)
|
||||
/// }
|
||||
///
|
||||
/// To maintain database integrity, and preserve eventual concurrent reads
|
||||
/// from seeing an inconsistent database state, prefer the
|
||||
/// writeInTransaction method.
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
///
|
||||
/// - parameters block: A block that executes SQL statements and return
|
||||
/// either .commit or .rollback.
|
||||
/// - throws: The error thrown by the block.
|
||||
public func write<T>(_ block: (Database) throws -> T) rethrows -> T {
|
||||
return try writer.sync(block)
|
||||
}
|
||||
|
||||
/// Synchronously executes a block in a protected dispatch queue, wrapped
|
||||
/// inside a transaction.
|
||||
///
|
||||
/// Eventual concurrent database updates are postponed until the block
|
||||
/// has executed.
|
||||
///
|
||||
/// If the block throws an error, the transaction is rollbacked and the
|
||||
/// error is rethrown. If the block returns .rollback, the transaction is
|
||||
/// also rollbacked, but no error is thrown.
|
||||
///
|
||||
/// try dbPool.writeInTransaction { db in
|
||||
/// db.execute(...)
|
||||
/// return .commit
|
||||
/// }
|
||||
///
|
||||
/// Eventual concurrent readers do not see partial changes:
|
||||
///
|
||||
/// dbPool.writeInTransaction { db in
|
||||
/// // Eventually preserve a zero balance
|
||||
/// try db.execute(db, "INSERT INTO credits ...", arguments: [amount])
|
||||
/// try db.execute(db, "INSERT INTO debits ...", arguments: [amount])
|
||||
/// }
|
||||
///
|
||||
/// dbPool.read { db in
|
||||
/// // Here the balance is guaranteed to be zero
|
||||
/// }
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - kind: The transaction type (default nil). If nil, the transaction
|
||||
/// type is configuration.defaultTransactionKind, which itself
|
||||
/// defaults to .immediate. See https://www.sqlite.org/lang_transaction.html
|
||||
/// for more information.
|
||||
/// - block: A block that executes SQL statements and return either
|
||||
/// .commit or .rollback.
|
||||
/// - throws: The error thrown by the block, or any error establishing the
|
||||
/// transaction.
|
||||
public func writeInTransaction(_ kind: Database.TransactionKind? = nil, _ block: (Database) throws -> Database.TransactionCompletion) throws {
|
||||
try write { db in
|
||||
try db.inTransaction(kind) {
|
||||
try block(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Synchronously executes an update block in a protected dispatch queue,
|
||||
/// and returns its result.
|
||||
///
|
||||
/// Eventual concurrent database updates are postponed until the block
|
||||
/// has executed.
|
||||
///
|
||||
/// try dbPool.unsafeReentrantWrite { db in
|
||||
/// try db.execute(...)
|
||||
/// }
|
||||
///
|
||||
/// This method is reentrant. It should be avoided because it fosters
|
||||
/// dangerous concurrency practices.
|
||||
public func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T {
|
||||
return try writer.reentrantSync(block)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Reading from Database
|
||||
|
||||
/// Asynchronously executes a read-only block in a protected dispatch queue,
|
||||
/// wrapped in a deferred transaction.
|
||||
///
|
||||
/// This method must be called from the writing dispatch queue.
|
||||
///
|
||||
/// The *block* argument is guaranteed to see the database in the last
|
||||
/// committed state at the moment this method is called. Eventual concurrent
|
||||
/// database updates are *not visible* inside the block.
|
||||
///
|
||||
/// try dbPool.write { db in
|
||||
/// try db.execute("DELETE FROM persons")
|
||||
/// try dbPool.readFromCurrentState { db in
|
||||
/// // Guaranteed to be zero
|
||||
/// try Int.fetchOne(db, "SELECT COUNT(*) FROM persons")!
|
||||
/// }
|
||||
/// try db.execute("INSERT INTO persons ...")
|
||||
/// }
|
||||
///
|
||||
/// This method blocks the current thread until the isolation guarantee has
|
||||
/// been established, and before the block argument has run.
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block, or any DatabaseError that would
|
||||
/// happen while establishing the read access to the database.
|
||||
public func readFromCurrentState(_ block: @escaping (Database) -> Void) throws {
|
||||
writer.preconditionValidQueue()
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
var readError: Error? = nil
|
||||
try readerPool.get { reader in
|
||||
reader.async { db in
|
||||
// https://www.sqlite.org/isolation.html
|
||||
//
|
||||
// > In WAL mode, SQLite exhibits "snapshot isolation". When a
|
||||
// > read transaction starts, that reader continues to see an
|
||||
// > unchanging "snapshot" of the database file as it existed at
|
||||
// > the moment in time when the read transaction started.
|
||||
// > Any write transactions that commit while the read
|
||||
// > transaction is active are still invisible to the read
|
||||
// > transaction, because the reader is seeing a snapshot of
|
||||
// > database file from a prior moment in time.
|
||||
//
|
||||
// This documentation is NOT accurate. SQLite actually defers
|
||||
// isolation until the first SELECT:
|
||||
//
|
||||
// Reader Writer
|
||||
// BEGIN DEFERRED TRANSACTION
|
||||
// UPDATE ... (1)
|
||||
// Here the change (1) is visible
|
||||
// SELECT ...
|
||||
// UPDATE ... (2)
|
||||
// Here the change (2) is not visible
|
||||
//
|
||||
// This is not the guarantee expected by this method: no change
|
||||
// at all should be visible.
|
||||
//
|
||||
// Workaround: perform an initial read before releasing the
|
||||
// writer queue:
|
||||
//
|
||||
// Reader Writer
|
||||
// BEGIN DEFERRED TRANSACTION
|
||||
// SELECT anything -- the work around
|
||||
// UPDATE ...
|
||||
// Here the change is not visible by GRDB user
|
||||
do {
|
||||
try db.beginTransaction(.deferred)
|
||||
assert(db.isInsideTransaction)
|
||||
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").cursor().next() // doesn't work with cached statement
|
||||
} catch {
|
||||
readError = error
|
||||
semaphore.signal() // Release the writer queue and rethrow error
|
||||
return
|
||||
}
|
||||
semaphore.signal() // We can release the writer queue now that we are isolated for good
|
||||
block(db)
|
||||
_ = try? db.commit() // Ignore commit error
|
||||
}
|
||||
}
|
||||
_ = semaphore.wait(timeout: .distantFuture)
|
||||
if let readError = readError {
|
||||
// TODO: write a test for this
|
||||
throw readError
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,374 @@
|
||||
import Foundation
|
||||
|
||||
#if os(iOS)
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
/// A DatabaseQueue serializes access to an SQLite database.
|
||||
public final class DatabaseQueue {
|
||||
|
||||
// MARK: - Initializers
|
||||
|
||||
/// Opens the SQLite database at path *path*.
|
||||
///
|
||||
/// let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
|
||||
///
|
||||
/// Database connections get closed when the database queue gets deallocated.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - path: The path to the database file.
|
||||
/// - configuration: A configuration.
|
||||
/// - throws: A DatabaseError whenever an SQLite error occurs.
|
||||
public init(path: String, configuration: Configuration = Configuration()) throws {
|
||||
serializedDatabase = try SerializedDatabase(
|
||||
path: path,
|
||||
configuration: configuration,
|
||||
schemaCache: SimpleDatabaseSchemaCache())
|
||||
}
|
||||
|
||||
/// Opens an in-memory SQLite database.
|
||||
///
|
||||
/// let dbQueue = DatabaseQueue()
|
||||
///
|
||||
/// Database memory is released when the database queue gets deallocated.
|
||||
///
|
||||
/// - parameter configuration: A configuration.
|
||||
public init(configuration: Configuration = Configuration()) {
|
||||
// Assume SQLite always succeeds creating an in-memory database
|
||||
serializedDatabase = try! SerializedDatabase(
|
||||
path: ":memory:",
|
||||
configuration: configuration,
|
||||
schemaCache: SimpleDatabaseSchemaCache())
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
deinit {
|
||||
// Undo job done in setupMemoryManagement()
|
||||
//
|
||||
// https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error
|
||||
// Explicit unregistration is required before iOS 9 and OS X 10.11.
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: - Configuration
|
||||
|
||||
/// The database configuration
|
||||
public var configuration: Configuration {
|
||||
return serializedDatabase.configuration
|
||||
}
|
||||
|
||||
/// The path to the database file; it is ":memory:" for in-memory databases.
|
||||
public var path: String {
|
||||
return serializedDatabase.path
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Database access
|
||||
|
||||
/// Synchronously executes a block in a protected dispatch queue, and
|
||||
/// returns its result.
|
||||
///
|
||||
/// let persons = try dbQueue.inDatabase { db in
|
||||
/// try Person.fetchAll(...)
|
||||
/// }
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block.
|
||||
public func inDatabase<T>(_ block: (Database) throws -> T) rethrows -> T {
|
||||
return try serializedDatabase.sync(block)
|
||||
}
|
||||
|
||||
/// Synchronously executes a block in a protected dispatch queue, wrapped
|
||||
/// inside a transaction.
|
||||
///
|
||||
/// If the block throws an error, the transaction is rollbacked and the
|
||||
/// error is rethrown. If the block returns .rollback, the transaction is
|
||||
/// also rollbacked, but no error is thrown.
|
||||
///
|
||||
/// try dbQueue.inTransaction { db in
|
||||
/// db.execute(...)
|
||||
/// return .commit
|
||||
/// }
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - kind: The transaction type (default nil). If nil, the transaction
|
||||
/// type is configuration.defaultTransactionKind, which itself
|
||||
/// defaults to .immediate. See https://www.sqlite.org/lang_transaction.html
|
||||
/// for more information.
|
||||
/// - block: A block that executes SQL statements and return either
|
||||
/// .commit or .rollback.
|
||||
/// - throws: The error thrown by the block.
|
||||
public func inTransaction(_ kind: Database.TransactionKind? = nil, _ block: (Database) throws -> Database.TransactionCompletion) throws {
|
||||
try inDatabase { db in
|
||||
try db.inTransaction(kind) {
|
||||
try block(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Memory management
|
||||
|
||||
/// Free as much memory as possible.
|
||||
///
|
||||
/// This method blocks the current thread until all database accesses are completed.
|
||||
///
|
||||
/// See also setupMemoryManagement(application:)
|
||||
public func releaseMemory() {
|
||||
inDatabase { $0.releaseMemory() }
|
||||
}
|
||||
|
||||
|
||||
#if os(iOS)
|
||||
/// Listens to UIApplicationDidEnterBackgroundNotification and
|
||||
/// UIApplicationDidReceiveMemoryWarningNotification in order to release
|
||||
/// as much memory as possible.
|
||||
///
|
||||
/// - param application: The UIApplication that will start a background
|
||||
/// task to let the database queue release its memory when the application
|
||||
/// enters background.
|
||||
public func setupMemoryManagement(in application: UIApplication) {
|
||||
self.application = application
|
||||
let center = NotificationCenter.default
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidReceiveMemoryWarning(_:)), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
|
||||
}
|
||||
|
||||
private var application: UIApplication?
|
||||
|
||||
@objc private func applicationDidEnterBackground(_ notification: NSNotification) {
|
||||
guard let application = application else {
|
||||
return
|
||||
}
|
||||
|
||||
var task: UIBackgroundTaskIdentifier! = nil
|
||||
task = application.beginBackgroundTask(expirationHandler: nil)
|
||||
|
||||
if task == UIBackgroundTaskInvalid {
|
||||
// Perform releaseMemory() synchronously.
|
||||
releaseMemory()
|
||||
} else {
|
||||
// Perform releaseMemory() asynchronously.
|
||||
DispatchQueue.global().async {
|
||||
self.releaseMemory()
|
||||
application.endBackgroundTask(task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func applicationDidReceiveMemoryWarning(_ notification: NSNotification) {
|
||||
DispatchQueue.global().async {
|
||||
self.releaseMemory()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: - Not public
|
||||
|
||||
// https://www.sqlite.org/isolation.html
|
||||
//
|
||||
// > Within a single database connection X, a SELECT statement always
|
||||
// > sees all changes to the database that are completed prior to the
|
||||
// > start of the SELECT statement, whether committed or uncommitted.
|
||||
// > And the SELECT statement obviously does not see any changes that
|
||||
// > occur after the SELECT statement completes. But what about changes
|
||||
// > that occur while the SELECT statement is running? What if a SELECT
|
||||
// > statement is started and the sqlite3_step() interface steps through
|
||||
// > roughly half of its output, then some UPDATE statements are run by
|
||||
// > the application that modify the table that the SELECT statement is
|
||||
// > reading, then more calls to sqlite3_step() are made to finish out
|
||||
// > the SELECT statement? Will the later steps of the SELECT statement
|
||||
// > see the changes made by the UPDATE or not? The answer is that this
|
||||
// > behavior is undefined.
|
||||
//
|
||||
// This is why we use a serialized database:
|
||||
fileprivate var serializedDatabase: SerializedDatabase
|
||||
}
|
||||
|
||||
|
||||
// =========================================================================
|
||||
// MARK: - Encryption
|
||||
|
||||
#if SQLITE_HAS_CODEC
|
||||
extension DatabaseQueue {
|
||||
|
||||
/// Changes the passphrase of an encrypted database
|
||||
public func change(passphrase: String) throws {
|
||||
try inDatabase { try $0.change(passphrase: passphrase) }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// =========================================================================
|
||||
// MARK: - DatabaseReader
|
||||
|
||||
extension DatabaseQueue : DatabaseReader {
|
||||
|
||||
// MARK: - DatabaseReader Protocol Adoption
|
||||
|
||||
/// Synchronously executes a read-only block in a protected dispatch queue,
|
||||
/// and returns its result.
|
||||
///
|
||||
/// let persons = try dbQueue.read { db in
|
||||
/// try Person.fetchAll(...)
|
||||
/// }
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
///
|
||||
/// Starting iOS 8.2, OSX 10.10, and with custom SQLite builds and
|
||||
/// SQLCipher, attempts to write in the database throw a DatabaseError whose
|
||||
/// resultCode is `SQLITE_READONLY`.
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block.
|
||||
public func read<T>(_ block: (Database) throws -> T) rethrows -> T {
|
||||
// query_only pragma was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
|
||||
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
return try inDatabase { try readOnly($0, block) }
|
||||
#else
|
||||
if #available(iOS 8.2, OSX 10.10, *) {
|
||||
return try inDatabase { try readOnly($0, block) }
|
||||
} else {
|
||||
return try inDatabase(block)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Alias for `inDatabase`. See `DatabaseReader.unsafeRead`.
|
||||
public func unsafeRead<T>(_ block: (Database) throws -> T) rethrows -> T {
|
||||
return try inDatabase(block)
|
||||
}
|
||||
|
||||
/// Synchronously executes a block in a protected dispatch queue, and
|
||||
/// returns its result.
|
||||
///
|
||||
/// try dbQueue.unsafeReentrantRead { db in
|
||||
/// try db.execute(...)
|
||||
/// }
|
||||
///
|
||||
/// This method is reentrant. It should be avoided because it fosters
|
||||
/// dangerous concurrency practices.
|
||||
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
|
||||
return try serializedDatabase.reentrantSync(block)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Functions
|
||||
|
||||
/// Add or redefine an SQL function.
|
||||
///
|
||||
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
|
||||
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
|
||||
/// return nil
|
||||
/// }
|
||||
/// return int + 1
|
||||
/// }
|
||||
/// dbQueue.add(function: fn)
|
||||
/// try dbQueue.inDatabase { db in
|
||||
/// try Int.fetchOne(db, "SELECT succ(1)") // 2
|
||||
/// }
|
||||
public func add(function: DatabaseFunction) {
|
||||
inDatabase { $0.add(function: function) }
|
||||
}
|
||||
|
||||
/// Remove an SQL function.
|
||||
public func remove(function: DatabaseFunction) {
|
||||
inDatabase { $0.remove(function: function) }
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Collations
|
||||
|
||||
/// Add or redefine a collation.
|
||||
///
|
||||
/// let collation = DatabaseCollation("localized_standard") { (string1, string2) in
|
||||
/// return (string1 as NSString).localizedStandardCompare(string2)
|
||||
/// }
|
||||
/// dbQueue.add(collation: collation)
|
||||
/// try dbQueue.inDatabase { db in
|
||||
/// try db.execute("CREATE TABLE files (name TEXT COLLATE LOCALIZED_STANDARD")
|
||||
/// }
|
||||
public func add(collation: DatabaseCollation) {
|
||||
inDatabase { $0.add(collation: collation) }
|
||||
}
|
||||
|
||||
/// Remove a collation.
|
||||
public func remove(collation: DatabaseCollation) {
|
||||
inDatabase { $0.remove(collation: collation) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// =========================================================================
|
||||
// MARK: - DatabaseWriter
|
||||
|
||||
extension DatabaseQueue : DatabaseWriter {
|
||||
|
||||
// MARK: - DatabaseWriter Protocol Adoption
|
||||
|
||||
/// Alias for `inDatabase`. See `DatabaseWriter.write`.
|
||||
public func write<T>(_ block: (Database) throws -> T) rethrows -> T {
|
||||
return try inDatabase(block)
|
||||
}
|
||||
|
||||
/// Synchronously executes *block*.
|
||||
///
|
||||
/// Starting iOS 8.2, OSX 10.10, and with custom SQLite builds and
|
||||
/// SQLCipher, attempts to write in the database throw a DatabaseError whose
|
||||
/// resultCode is `SQLITE_READONLY`.
|
||||
///
|
||||
/// This method must be called from the protected database dispatch queue.
|
||||
/// See `DatabaseWriter.readFromCurrentState`.
|
||||
public func readFromCurrentState(_ block: @escaping (Database) -> Void) {
|
||||
// query_only pragma was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
|
||||
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
serializedDatabase.execute { readOnly($0, block) }
|
||||
#else
|
||||
if #available(iOS 8.2, OSX 10.10, *) {
|
||||
serializedDatabase.execute { readOnly($0, block) }
|
||||
} else {
|
||||
serializedDatabase.execute(block)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Synchronously executes a block in a protected dispatch queue, and
|
||||
/// returns its result.
|
||||
///
|
||||
/// try dbQueue.unsafeReentrantWrite { db in
|
||||
/// try db.execute(...)
|
||||
/// }
|
||||
///
|
||||
/// This method is reentrant. It should be avoided because it fosters
|
||||
/// dangerous concurrency practices.
|
||||
public func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T {
|
||||
return try serializedDatabase.reentrantSync(block)
|
||||
}
|
||||
}
|
||||
|
||||
// Wraps the block between two `PRAGMA query_only` statements.
|
||||
//
|
||||
// This method is unsafe because the two calls to `PRAGMA query_only` are
|
||||
// not guaranteed to be serialized (some other thread could mess with this).
|
||||
private func readOnly<T>(_ db: Database, _ block: (Database) throws -> T) rethrows -> T {
|
||||
if db.configuration.readonly {
|
||||
return try block(db)
|
||||
} else {
|
||||
try! db.execute("PRAGMA query_only = 1") // Assume can't fail
|
||||
let result = try block(db)
|
||||
try! db.execute("PRAGMA query_only = 0") // Assume can't fail
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
#if SWIFT_PACKAGE
|
||||
import CSQLite
|
||||
#endif
|
||||
|
||||
/// The protocol for all types that can fetch values from a database.
|
||||
///
|
||||
/// It is adopted by DatabaseQueue and DatabasePool.
|
||||
///
|
||||
/// The protocol comes with isolation guarantees that describe the behavior of
|
||||
/// adopting types in a multithreaded application.
|
||||
///
|
||||
/// Types that adopt the protocol can provide in practice stronger guarantees.
|
||||
/// For example, DatabaseQueue provides a stronger isolation level
|
||||
/// than DatabasePool.
|
||||
///
|
||||
/// **Warning**: Isolation guarantees stand as long as there is no external
|
||||
/// connection to the database. Should you have to cope with external
|
||||
/// connections, protect yourself with transactions, and be ready to setup a
|
||||
/// [busy handler](https://www.sqlite.org/c3ref/busy_handler.html).
|
||||
public protocol DatabaseReader : class {
|
||||
|
||||
// MARK: - Read From Database
|
||||
|
||||
/// Synchronously executes a read-only block that takes a database
|
||||
/// connection, and returns its result.
|
||||
///
|
||||
/// Guarantee 1: the block argument is isolated. Eventual concurrent
|
||||
/// database updates are not visible inside the block:
|
||||
///
|
||||
/// try reader.read { db in
|
||||
/// // Those two values are guaranteed to be equal, even if the
|
||||
/// // `wines` table is modified between the two requests:
|
||||
/// let count1 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// }
|
||||
///
|
||||
/// try reader.read { db in
|
||||
/// // Now this value may be different:
|
||||
/// let count = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// }
|
||||
///
|
||||
/// Guarantee 2: Starting iOS 8.2, OSX 10.10, and with custom SQLite builds
|
||||
/// and SQLCipher, attempts to write in the database throw a DatabaseError
|
||||
/// whose resultCode is `SQLITE_READONLY`.
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block, or any DatabaseError that would
|
||||
/// happen while establishing the read access to the database.
|
||||
func read<T>(_ block: (Database) throws -> T) throws -> T
|
||||
|
||||
/// Synchronously executes a read-only block that takes a database
|
||||
/// connection, and returns its result.
|
||||
///
|
||||
/// The two guarantees of the safe `read` method are lifted:
|
||||
///
|
||||
/// The block argument is not isolated: eventual concurrent database updates
|
||||
/// are visible inside the block:
|
||||
///
|
||||
/// try reader.unsafeRead { db in
|
||||
/// // Those two values may be different because some other thread
|
||||
/// // may have inserted or deleted a wine between the two requests:
|
||||
/// let count1 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// }
|
||||
///
|
||||
/// Cursor iterations are isolated, though:
|
||||
///
|
||||
/// try reader.unsafeRead { db in
|
||||
/// // No concurrent update can mess with this iteration:
|
||||
/// let rows = try Row.fetchCursor(db, "SELECT ...")
|
||||
/// while let row = try rows.next() { ... }
|
||||
/// }
|
||||
///
|
||||
/// The block argument is not prevented from writing (DatabaseQueue, in
|
||||
/// particular, will accept database modifications in `unsafeRead`).
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block, or any DatabaseError that would
|
||||
/// happen while establishing the read access to the database.
|
||||
func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T
|
||||
|
||||
/// Synchronously executes a block that takes a database connection, and
|
||||
/// returns its result.
|
||||
///
|
||||
/// The two guarantees of the safe `read` method are lifted:
|
||||
///
|
||||
/// The block argument is not isolated: eventual concurrent database updates
|
||||
/// are visible inside the block:
|
||||
///
|
||||
/// try reader.unsafeReentrantRead { db in
|
||||
/// // Those two values may be different because some other thread
|
||||
/// // may have inserted or deleted a wine between the two requests:
|
||||
/// let count1 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
|
||||
/// }
|
||||
///
|
||||
/// Cursor iterations are isolated, though:
|
||||
///
|
||||
/// try reader.unsafeReentrantRead { db in
|
||||
/// // No concurrent update can mess with this iteration:
|
||||
/// let rows = try Row.fetchCursor(db, "SELECT ...")
|
||||
/// while let row = try rows.next() { ... }
|
||||
/// }
|
||||
///
|
||||
/// The block argument is not prevented from writing (DatabaseQueue, in
|
||||
/// particular, will accept database modifications in `unsafeReentrantRead`).
|
||||
///
|
||||
/// - parameter block: A block that accesses the database.
|
||||
/// - throws: The error thrown by the block, or any DatabaseError that would
|
||||
/// happen while establishing the read access to the database.
|
||||
///
|
||||
/// This method is reentrant. It should be avoided because it fosters
|
||||
/// dangerous concurrency practices.
|
||||
func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T
|
||||
|
||||
|
||||
// MARK: - Functions
|
||||
|
||||
/// Add or redefine an SQL function.
|
||||
///
|
||||
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
|
||||
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
|
||||
/// return nil
|
||||
/// }
|
||||
/// return int + 1
|
||||
/// }
|
||||
/// reader.add(function: fn)
|
||||
/// try reader.read { db in
|
||||
/// try Int.fetchOne(db, "SELECT succ(1)")! // 2
|
||||
/// }
|
||||
func add(function: DatabaseFunction)
|
||||
|
||||
/// Remove an SQL function.
|
||||
func remove(function: DatabaseFunction)
|
||||
|
||||
|
||||
// MARK: - Collations
|
||||
|
||||
/// Add or redefine a collation.
|
||||
///
|
||||
/// let collation = DatabaseCollation("localized_standard") { (string1, string2) in
|
||||
/// return (string1 as NSString).localizedStandardCompare(string2)
|
||||
/// }
|
||||
/// reader.add(collation: collation)
|
||||
/// try reader.execute("SELECT * FROM files ORDER BY name COLLATE localized_standard")
|
||||
func add(collation: DatabaseCollation)
|
||||
|
||||
/// Remove a collation.
|
||||
func remove(collation: DatabaseCollation)
|
||||
}
|
||||
|
||||
extension DatabaseReader {
|
||||
|
||||
// MARK: - Backup
|
||||
|
||||
/// Copies the database contents into another database.
|
||||
///
|
||||
/// The `backup` method blocks the current thread until the destination
|
||||
/// database contains the same contents as the source database.
|
||||
///
|
||||
/// When the source is a DatabasePool, concurrent writes can happen during
|
||||
/// the backup. Those writes may, or may not, be reflected in the backup,
|
||||
/// but they won't trigger any error.
|
||||
public func backup(to writer: DatabaseWriter) throws {
|
||||
try backup(to: writer, afterBackupInit: nil, afterBackupStep: nil)
|
||||
}
|
||||
|
||||
func backup(to writer: DatabaseWriter, afterBackupInit: (() -> ())?, afterBackupStep: (() -> ())?) throws {
|
||||
try read { dbFrom in
|
||||
try writer.write { dbDest in
|
||||
guard let backup = sqlite3_backup_init(dbDest.sqliteConnection, "main", dbFrom.sqliteConnection, "main") else {
|
||||
throw DatabaseError(resultCode: dbDest.lastErrorCode, message: dbDest.lastErrorMessage)
|
||||
}
|
||||
guard Int(bitPattern: backup) != Int(SQLITE_ERROR) else {
|
||||
throw DatabaseError(resultCode: .SQLITE_ERROR)
|
||||
}
|
||||
|
||||
afterBackupInit?()
|
||||
|
||||
do {
|
||||
backupLoop: while true {
|
||||
switch sqlite3_backup_step(backup, -1) {
|
||||
case SQLITE_DONE:
|
||||
afterBackupStep?()
|
||||
break backupLoop
|
||||
case SQLITE_OK:
|
||||
afterBackupStep?()
|
||||
case let code:
|
||||
throw DatabaseError(resultCode: code, message: dbDest.lastErrorMessage)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
sqlite3_backup_finish(backup)
|
||||
throw error
|
||||
}
|
||||
|
||||
switch sqlite3_backup_finish(backup) {
|
||||
case SQLITE_OK:
|
||||
break
|
||||
case let code:
|
||||
throw DatabaseError(resultCode: code, message: dbDest.lastErrorMessage)
|
||||
}
|
||||
|
||||
dbDest.clearSchemaCache()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/// The protocol for schema cache.
|
||||
///
|
||||
/// This protocol must not contain values that are valid for a single connection
|
||||
/// only, because several connections can share the same schema cache.
|
||||
///
|
||||
/// Statements can't be cached here, for example.
|
||||
protocol DatabaseSchemaCache {
|
||||
mutating func clear()
|
||||
|
||||
func primaryKey(_ table: String) -> PrimaryKeyInfo??
|
||||
mutating func set(primaryKey: PrimaryKeyInfo?, forTable table: String)
|
||||
|
||||
func columns(in table: String) -> [ColumnInfo]?
|
||||
mutating func set(columns: [ColumnInfo], forTable table: String)
|
||||
|
||||
func indexes(on table: String) -> [IndexInfo]?
|
||||
mutating func set(indexes: [IndexInfo], forTable table: String)
|
||||
|
||||
func foreignKeys(on table: String) -> [ForeignKeyInfo]?
|
||||
mutating func set(foreignKeys: [ForeignKeyInfo], forTable table: String)
|
||||
}
|
||||
|
||||
/// A thread-unsafe database schema cache
|
||||
final class SimpleDatabaseSchemaCache: DatabaseSchemaCache {
|
||||
private var primaryKeys: [String: PrimaryKeyInfo?] = [:]
|
||||
private var columns: [String: [ColumnInfo]] = [:]
|
||||
private var indexes: [String: [IndexInfo]] = [:]
|
||||
private var foreignKeys: [String: [ForeignKeyInfo]] = [:]
|
||||
|
||||
func clear() {
|
||||
primaryKeys = [:]
|
||||
columns = [:]
|
||||
indexes = [:]
|
||||
foreignKeys = [:]
|
||||
}
|
||||
|
||||
func primaryKey(_ table: String) -> PrimaryKeyInfo?? {
|
||||
return primaryKeys[table]
|
||||
}
|
||||
|
||||
func set(primaryKey: PrimaryKeyInfo?, forTable table: String) {
|
||||
primaryKeys[table] = primaryKey
|
||||
}
|
||||
|
||||
func columns(in table: String) -> [ColumnInfo]? {
|
||||
return columns[table]
|
||||
}
|
||||
|
||||
func set(columns: [ColumnInfo], forTable table: String) {
|
||||
self.columns[table] = columns
|
||||
}
|
||||
|
||||
func indexes(on table: String) -> [IndexInfo]? {
|
||||
return indexes[table]
|
||||
}
|
||||
|
||||
func set(indexes: [IndexInfo], forTable table: String) {
|
||||
self.indexes[table] = indexes
|
||||
}
|
||||
|
||||
func foreignKeys(on table: String) -> [ForeignKeyInfo]? {
|
||||
return foreignKeys[table]
|
||||
}
|
||||
|
||||
func set(foreignKeys: [ForeignKeyInfo], forTable table: String) {
|
||||
self.foreignKeys[table] = foreignKeys
|
||||
}
|
||||
}
|
||||
|
||||
/// A thread-safe database schema cache
|
||||
final class SharedDatabaseSchemaCache: DatabaseSchemaCache {
|
||||
private let cache = ReadWriteBox(SimpleDatabaseSchemaCache())
|
||||
|
||||
func clear() {
|
||||
cache.write { $0.clear() }
|
||||
}
|
||||
|
||||
func primaryKey(_ table: String) -> PrimaryKeyInfo?? {
|
||||
return cache.read { $0.primaryKey(table) }
|
||||
}
|
||||
|
||||
func set(primaryKey: PrimaryKeyInfo?, forTable table: String) {
|
||||
cache.write { $0.set(primaryKey: primaryKey, forTable: table) }
|
||||
}
|
||||
|
||||
func columns(in table: String) -> [ColumnInfo]? {
|
||||
return cache.read { $0.columns(in: table) }
|
||||
}
|
||||
|
||||
func set(columns: [ColumnInfo], forTable table: String) {
|
||||
cache.write { $0.set(columns: columns, forTable: table) }
|
||||
}
|
||||
|
||||
func indexes(on table: String) -> [IndexInfo]? {
|
||||
return cache.read { $0.indexes(on: table) }
|
||||
}
|
||||
|
||||
func set(indexes: [IndexInfo], forTable table: String) {
|
||||
cache.write { $0.set(indexes: indexes, forTable: table) }
|
||||
}
|
||||
|
||||
func foreignKeys(on table: String) -> [ForeignKeyInfo]? {
|
||||
return cache.read { $0.foreignKeys(on: table) }
|
||||
}
|
||||
|
||||
func set(foreignKeys: [ForeignKeyInfo], forTable table: String) {
|
||||
cache.write { $0.set(foreignKeys: foreignKeys, forTable: table) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
import Foundation
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import CSQLite
|
||||
#endif
|
||||
|
||||
// MARK: - DatabaseValue
|
||||
|
||||
/// DatabaseValue is the intermediate type between SQLite and your values.
|
||||
///
|
||||
/// See https://www.sqlite.org/datatype3.html
|
||||
public struct DatabaseValue {
|
||||
|
||||
/// An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).
|
||||
public enum Storage : Equatable {
|
||||
/// The NULL storage class.
|
||||
case null
|
||||
|
||||
/// The INTEGER storage class, wrapping an Int64.
|
||||
case int64(Int64)
|
||||
|
||||
/// The REAL storage class, wrapping a Double.
|
||||
case double(Double)
|
||||
|
||||
/// The TEXT storage class, wrapping a String.
|
||||
case string(String)
|
||||
|
||||
/// The BLOB storage class, wrapping Data.
|
||||
case blob(Data)
|
||||
|
||||
/// Returns Int64, Double, String, Data or nil.
|
||||
public var value: DatabaseValueConvertible? {
|
||||
switch self {
|
||||
case .null:
|
||||
return nil
|
||||
case .int64(let int64):
|
||||
return int64
|
||||
case .double(let double):
|
||||
return double
|
||||
case .string(let string):
|
||||
return string
|
||||
case .blob(let data):
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
/// Return true if the storages are identical.
|
||||
///
|
||||
/// Unlike DatabaseValue equality that considers the integer 1 to be
|
||||
/// equal to the 1.0 double (as SQLite does), int64 and double storages
|
||||
/// are never equal.
|
||||
public static func == (_ lhs: Storage, _ rhs: Storage) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (.null, .null): return true
|
||||
case (.int64(let lhs), .int64(let rhs)): return lhs == rhs
|
||||
case (.double(let lhs), .double(let rhs)): return lhs == rhs
|
||||
case (.string(let lhs), .string(let rhs)): return lhs == rhs
|
||||
case (.blob(let lhs), .blob(let rhs)): return lhs == rhs
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The SQLite storage
|
||||
public let storage: Storage
|
||||
|
||||
/// The NULL DatabaseValue.
|
||||
public static let null = DatabaseValue(storage: .null)
|
||||
|
||||
/// Creates a DatabaseValue from Any.
|
||||
///
|
||||
/// The result is nil unless object adopts DatabaseValueConvertible.
|
||||
public init?(value: Any) {
|
||||
guard let convertible = value as? DatabaseValueConvertible else {
|
||||
return nil
|
||||
}
|
||||
self = convertible.databaseValue
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Extracting Value
|
||||
|
||||
/// Returns true if databaseValue is NULL.
|
||||
public var isNull: Bool {
|
||||
switch storage {
|
||||
case .null:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Not Public
|
||||
|
||||
init(storage: Storage) {
|
||||
// This initializer is not public because Storage is not a safe type:
|
||||
// one can create a Storage of zero-length Data, which is invalid
|
||||
// because SQLite can't store zero-length blobs.
|
||||
self.storage = storage
|
||||
}
|
||||
|
||||
// SQLite function argument
|
||||
init(sqliteValue: SQLiteValue) {
|
||||
switch sqlite3_value_type(sqliteValue) {
|
||||
case SQLITE_NULL:
|
||||
storage = .null
|
||||
case SQLITE_INTEGER:
|
||||
storage = .int64(sqlite3_value_int64(sqliteValue))
|
||||
case SQLITE_FLOAT:
|
||||
storage = .double(sqlite3_value_double(sqliteValue))
|
||||
case SQLITE_TEXT:
|
||||
storage = .string(String(cString: sqlite3_value_text(sqliteValue)!))
|
||||
case SQLITE_BLOB:
|
||||
let bytes = unsafeBitCast(sqlite3_value_blob(sqliteValue), to: UnsafePointer<UInt8>.self)
|
||||
let count = Int(sqlite3_value_bytes(sqliteValue))
|
||||
storage = .blob(Data(bytes: bytes, count: count)) // copy bytes
|
||||
case let type:
|
||||
// Assume a GRDB bug: there is no point throwing any error.
|
||||
fatalError("Unexpected SQLite value type: \(type)")
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a DatabaseValue initialized from a raw SQLite statement pointer.
|
||||
init(sqliteStatement: SQLiteStatement, index: Int32) {
|
||||
switch sqlite3_column_type(sqliteStatement, Int32(index)) {
|
||||
case SQLITE_NULL:
|
||||
storage = .null
|
||||
case SQLITE_INTEGER:
|
||||
storage = .int64(sqlite3_column_int64(sqliteStatement, Int32(index)))
|
||||
case SQLITE_FLOAT:
|
||||
storage = .double(sqlite3_column_double(sqliteStatement, Int32(index)))
|
||||
case SQLITE_TEXT:
|
||||
storage = .string(String(cString: sqlite3_column_text(sqliteStatement, Int32(index))))
|
||||
case SQLITE_BLOB:
|
||||
let bytes = unsafeBitCast(sqlite3_column_blob(sqliteStatement, Int32(index)), to: UnsafePointer<UInt8>.self)
|
||||
let count = Int(sqlite3_column_bytes(sqliteStatement, Int32(index)))
|
||||
storage = .blob(Data(bytes: bytes, count: count)) // copy bytes
|
||||
case let type:
|
||||
// Assume a GRDB bug: there is no point throwing any error.
|
||||
fatalError("Unexpected SQLite column type: \(type)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Hashable & Equatable
|
||||
|
||||
/// DatabaseValue adopts Hashable.
|
||||
extension DatabaseValue : Hashable {
|
||||
|
||||
/// The hash value
|
||||
public var hashValue: Int {
|
||||
switch storage {
|
||||
case .null:
|
||||
return 0
|
||||
case .int64(let int64):
|
||||
// 1 == 1.0, hence 1 and 1.0 must have the same hash:
|
||||
return Double(int64).hashValue
|
||||
case .double(let double):
|
||||
return double.hashValue
|
||||
case .string(let string):
|
||||
return string.hashValue
|
||||
case .blob(let data):
|
||||
return data.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns whether two DatabaseValues are equal.
|
||||
///
|
||||
/// 1.databaseValue == "foo".databaseValue // false
|
||||
/// 1.databaseValue == 1.databaseValue // true
|
||||
///
|
||||
/// When comparing integers and doubles, the result is true if and only
|
||||
/// values are equal, and if converting one type to the other does
|
||||
/// not lose information:
|
||||
///
|
||||
/// 1.databaseValue == 1.0.databaseValue // true
|
||||
///
|
||||
/// For a comparison that distinguishes integer and doubles, compare
|
||||
/// storages instead:
|
||||
///
|
||||
/// 1.databaseValue.storage == 1.0.databaseValue.storage // false
|
||||
public static func == (lhs: DatabaseValue, rhs: DatabaseValue) -> Bool {
|
||||
switch (lhs.storage, rhs.storage) {
|
||||
case (.null, .null):
|
||||
return true
|
||||
case (.int64(let lhs), .int64(let rhs)):
|
||||
return lhs == rhs
|
||||
case (.double(let lhs), .double(let rhs)):
|
||||
return lhs == rhs
|
||||
case (.int64(let lhs), .double(let rhs)):
|
||||
return int64EqualDouble(lhs, rhs)
|
||||
case (.double(let lhs), .int64(let rhs)):
|
||||
return int64EqualDouble(rhs, lhs)
|
||||
case (.string(let lhs), .string(let rhs)):
|
||||
return lhs == rhs
|
||||
case (.blob(let lhs), .blob(let rhs)):
|
||||
return lhs == rhs
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if i and d hold exactly the same value, and if converting one
|
||||
/// type to the other does not lose any information.
|
||||
private func int64EqualDouble(_ i: Int64, _ d: Double) -> Bool {
|
||||
// See http://stackoverflow.com/questions/33719132/how-to-test-for-lossless-double-integer-conversion/33784296#33784296
|
||||
return (d >= Double(Int64.min))
|
||||
&& (d < Double(Int64.max))
|
||||
&& (round(d) == d)
|
||||
&& (i == Int64(d))
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Lossless conversions
|
||||
|
||||
extension DatabaseValue {
|
||||
/// Converts the database value to the type T.
|
||||
///
|
||||
/// let dbValue = "foo".databaseValue
|
||||
/// let string = dbValue.losslessConvert() as String // "foo"
|
||||
///
|
||||
/// Conversion is successful if and only if T.fromDatabaseValue returns a
|
||||
/// non-nil value.
|
||||
///
|
||||
/// This method crashes with a fatal error when conversion fails.
|
||||
///
|
||||
/// let dbValue = "foo".databaseValue
|
||||
/// let int = dbValue.losslessConvert() as Int // fatalError
|
||||
///
|
||||
/// - parameters:
|
||||
/// - sql: Optional SQL statement that enhances the eventual
|
||||
/// conversion error
|
||||
/// - arguments: Optional statement arguments that enhances the eventual
|
||||
/// conversion error
|
||||
public func losslessConvert<T>(sql: String? = nil, arguments: StatementArguments? = nil) -> T where T : DatabaseValueConvertible {
|
||||
if let value = T.fromDatabaseValue(self) {
|
||||
return value
|
||||
}
|
||||
// Failed conversion: this is data loss, a programmer error.
|
||||
var error = "could not convert database value \(self) to \(T.self)"
|
||||
if let sql = sql {
|
||||
error += " with statement `\(sql)`"
|
||||
}
|
||||
if let arguments = arguments, !arguments.isEmpty {
|
||||
error += " arguments \(arguments)"
|
||||
}
|
||||
fatalError(error)
|
||||
}
|
||||
|
||||
/// Converts the database value to the type Optional<T>.
|
||||
///
|
||||
/// let dbValue = "foo".databaseValue
|
||||
/// let string = dbValue.losslessConvert() as String? // "foo"
|
||||
/// let null = DatabaseValue.null.losslessConvert() as String? // nil
|
||||
///
|
||||
/// Conversion is successful if and only if T.fromDatabaseValue returns a
|
||||
/// non-nil value.
|
||||
///
|
||||
/// This method crashes with a fatal error when conversion fails.
|
||||
///
|
||||
/// let dbValue = "foo".databaseValue
|
||||
/// let int = dbValue.losslessConvert() as Int? // fatalError
|
||||
///
|
||||
/// - parameters:
|
||||
/// - sql: Optional SQL statement that enhances the eventual
|
||||
/// conversion error
|
||||
/// - arguments: Optional statement arguments that enhances the eventual
|
||||
/// conversion error
|
||||
public func losslessConvert<T>(sql: String? = nil, arguments: StatementArguments? = nil) -> T? where T : DatabaseValueConvertible {
|
||||
// Use fromDatabaseValue first: this allows DatabaseValue to convert NULL to .null.
|
||||
if let value = T.fromDatabaseValue(self) {
|
||||
return value
|
||||
}
|
||||
if isNull {
|
||||
// Failed conversion from null: ok
|
||||
return nil
|
||||
} else {
|
||||
// Failed conversion from a non-null database value: this is data
|
||||
// loss, a programmer error.
|
||||
var error = "could not convert database value \(self) to \(T.self)"
|
||||
if let sql = sql {
|
||||
error += " with statement `\(sql)`"
|
||||
}
|
||||
if let arguments = arguments, !arguments.isEmpty {
|
||||
error += " arguments \(arguments)"
|
||||
}
|
||||
fatalError(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - DatabaseValueConvertible & SQLExpressible & SQLExpression
|
||||
|
||||
/// DatabaseValue adopts DatabaseValueConvertible.
|
||||
extension DatabaseValue : DatabaseValueConvertible {
|
||||
/// Returns self
|
||||
public var databaseValue: DatabaseValue {
|
||||
return self
|
||||
}
|
||||
|
||||
/// Returns the database value
|
||||
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> DatabaseValue? {
|
||||
return dbValue
|
||||
}
|
||||
}
|
||||
|
||||
extension DatabaseValue : SQLExpressible {
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
public var sqlExpression: SQLExpression {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
/// DatabaseValue adopts SQLExpression.
|
||||
extension DatabaseValue : SQLExpression {
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
public func expressionSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
// fast path for NULL
|
||||
if isNull {
|
||||
return "NULL"
|
||||
}
|
||||
|
||||
if arguments != nil {
|
||||
arguments!.values.append(self)
|
||||
return "?"
|
||||
} else {
|
||||
// Correctness above all: use SQLite to quote the value.
|
||||
// Assume that the Quote function always succeeds
|
||||
return DatabaseQueue().inDatabase { try! String.fetchOne($0, "SELECT QUOTE(?)", arguments: [self])! }
|
||||
}
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
public var negated: SQLExpression {
|
||||
switch storage {
|
||||
case .null:
|
||||
// SELECT NOT NULL -- NULL
|
||||
return DatabaseValue.null
|
||||
case .int64(let int64):
|
||||
return (int64 == 0).sqlExpression
|
||||
case .double(let double):
|
||||
return (double == 0.0).sqlExpression
|
||||
case .string:
|
||||
// We can't assume all strings are true, and return false:
|
||||
//
|
||||
// SELECT NOT '1' -- 0 (because '1' is turned into the integer 1, which is negated into 0)
|
||||
// SELECT NOT '0' -- 1 (because '0' is turned into the integer 0, which is negated into 1)
|
||||
return SQLExpressionNot(self)
|
||||
case .blob:
|
||||
// We can't assume all blobs are true, and return false:
|
||||
//
|
||||
// SELECT NOT X'31' -- 0 (because X'31' is turned into the string '1', then into integer 1, which is negated into 0)
|
||||
// SELECT NOT X'30' -- 1 (because X'30' is turned into the string '0', then into integer 0, which is negated into 1)
|
||||
return SQLExpressionNot(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CustomStringConvertible
|
||||
|
||||
/// DatabaseValue adopts CustomStringConvertible.
|
||||
extension DatabaseValue : CustomStringConvertible {
|
||||
/// A textual representation of `self`.
|
||||
public var description: String {
|
||||
switch storage {
|
||||
case .null:
|
||||
return "NULL"
|
||||
case .int64(let int64):
|
||||
return String(int64)
|
||||
case .double(let double):
|
||||
return String(double)
|
||||
case .string(let string):
|
||||
return String(reflecting: string)
|
||||
case .blob(let data):
|
||||
return data.description
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
// MARK: - DatabaseValueConvertible
|
||||
|
||||
/// Types that adopt DatabaseValueConvertible can be initialized from
|
||||
/// database values.
|
||||
///
|
||||
/// The protocol comes with built-in methods that allow to fetch cursors,
|
||||
/// arrays, or single values:
|
||||
///
|
||||
/// try String.fetchCursor(db, "SELECT name FROM ...", arguments:...) // DatabaseCursor<String>
|
||||
/// try String.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String]
|
||||
/// try String.fetchOne(db, "SELECT name FROM ...", arguments:...) // String?
|
||||
///
|
||||
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
|
||||
/// try String.fetchCursor(statement, arguments:...) // DatabaseCursor<String>
|
||||
/// try String.fetchAll(statement, arguments:...) // [String]
|
||||
/// try String.fetchOne(statement, arguments:...) // String?
|
||||
///
|
||||
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
|
||||
public protocol DatabaseValueConvertible : SQLExpressible {
|
||||
/// Returns a value that can be stored in the database.
|
||||
var databaseValue: DatabaseValue { get }
|
||||
|
||||
/// Returns a value initialized from *dbValue*, if possible.
|
||||
static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self?
|
||||
}
|
||||
|
||||
// SQLExpressible adoption
|
||||
extension DatabaseValueConvertible {
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
public var sqlExpression: SQLExpression {
|
||||
return databaseValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// DatabaseValueConvertible comes with built-in methods that allow to fetch
|
||||
/// cursors, arrays, or single values:
|
||||
///
|
||||
/// try String.fetchCursor(db, "SELECT name FROM ...", arguments:...) // DatabaseCursor<String>
|
||||
/// try String.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String]
|
||||
/// try String.fetchOne(db, "SELECT name FROM ...", arguments:...) // String?
|
||||
///
|
||||
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
|
||||
/// try String.fetchCursor(statement, arguments:...) // DatabaseCursor<String>
|
||||
/// try String.fetchAll(statement, arguments:...) // [String]
|
||||
/// try String.fetchOne(statement, arguments:...) // String
|
||||
///
|
||||
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
|
||||
extension DatabaseValueConvertible {
|
||||
|
||||
|
||||
// MARK: Fetching From SelectStatement
|
||||
|
||||
/// Returns a cursor over values fetched from a prepared statement.
|
||||
///
|
||||
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
|
||||
/// let names = try String.fetchCursor(statement) // DatabaseCursor<String>
|
||||
/// while let name = try names.next() { // String
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - statement: The statement to run.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: A cursor over fetched values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchCursor(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DatabaseCursor<Self> {
|
||||
// Reuse a single mutable row for performance
|
||||
let row = try Row(statement: statement).adapted(with: adapter, layout: statement)
|
||||
return statement.cursor(arguments: arguments, next: {
|
||||
let dbValue: DatabaseValue = row.value(atIndex: 0)
|
||||
return dbValue.losslessConvert(sql: statement.sql, arguments: arguments) as Self
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an array of values fetched from a prepared statement.
|
||||
///
|
||||
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
|
||||
/// let names = try String.fetchAll(statement) // [String]
|
||||
///
|
||||
/// - parameters:
|
||||
/// - statement: The statement to run.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: An array.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchAll(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Self] {
|
||||
return try Array(fetchCursor(statement, arguments: arguments, adapter: adapter))
|
||||
}
|
||||
|
||||
/// Returns a single value fetched from a prepared statement.
|
||||
///
|
||||
/// The result is nil if the query returns no row, or if no value can be
|
||||
/// extracted from the first row.
|
||||
///
|
||||
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
|
||||
/// let name = try String.fetchOne(statement) // String?
|
||||
///
|
||||
/// - parameters:
|
||||
/// - statement: The statement to run.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: An optional value.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchOne(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? {
|
||||
// Reuse a single mutable row for performance
|
||||
let row = try Row(statement: statement).adapted(with: adapter, layout: statement)
|
||||
let cursor: DatabaseCursor<Self?> = statement.cursor(arguments: arguments, next: {
|
||||
let dbValue: DatabaseValue = row.value(atIndex: 0)
|
||||
return dbValue.losslessConvert(sql: statement.sql, arguments: arguments) as Self?
|
||||
})
|
||||
return try cursor.next() ?? nil
|
||||
}
|
||||
}
|
||||
|
||||
extension DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching From Request
|
||||
|
||||
/// Returns a cursor over values fetched from a fetch request.
|
||||
///
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn)
|
||||
/// let names = try String.fetchCursor(db, request) // DatabaseCursor<String>
|
||||
/// for let name = try names.next() { // String
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - db: A database connection.
|
||||
/// - request: A fetch request.
|
||||
/// - returns: A cursor over fetched values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchCursor(_ db: Database, _ request: Request) throws -> DatabaseCursor<Self> {
|
||||
let (statement, adapter) = try request.prepare(db)
|
||||
return try fetchCursor(statement, adapter: adapter)
|
||||
}
|
||||
|
||||
/// Returns an array of values fetched from a fetch request.
|
||||
///
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn)
|
||||
/// let names = try String.fetchAll(db, request) // [String]
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchAll(_ db: Database, _ request: Request) throws -> [Self] {
|
||||
let (statement, adapter) = try request.prepare(db)
|
||||
return try fetchAll(statement, adapter: adapter)
|
||||
}
|
||||
|
||||
/// Returns a single value fetched from a fetch request.
|
||||
///
|
||||
/// The result is nil if the query returns no row, or if no value can be
|
||||
/// extracted from the first row.
|
||||
///
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn)
|
||||
/// let name = try String.fetchOne(db, request) // String?
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchOne(_ db: Database, _ request: Request) throws -> Self? {
|
||||
let (statement, adapter) = try request.prepare(db)
|
||||
return try fetchOne(statement, adapter: adapter)
|
||||
}
|
||||
}
|
||||
|
||||
extension DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching From SQL
|
||||
|
||||
/// Returns a cursor over values fetched from an SQL query.
|
||||
///
|
||||
/// let names = try String.fetchCursor(db, "SELECT name FROM ...") // DatabaseCursor<String>
|
||||
/// while let name = try name.next() { // String
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - db: A database connection.
|
||||
/// - sql: An SQL query.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: A cursor over fetched values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DatabaseCursor<Self> {
|
||||
return try fetchCursor(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
|
||||
}
|
||||
|
||||
/// Returns an array of values fetched from an SQL query.
|
||||
///
|
||||
/// let names = try String.fetchAll(db, "SELECT name FROM ...") // [String]
|
||||
///
|
||||
/// - parameters:
|
||||
/// - db: A database connection.
|
||||
/// - sql: An SQL query.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: An array.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Self] {
|
||||
return try fetchAll(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
|
||||
}
|
||||
|
||||
/// Returns a single value fetched from an SQL query.
|
||||
///
|
||||
/// The result is nil if the query returns no row, or if no value can be
|
||||
/// extracted from the first row.
|
||||
///
|
||||
/// let name = try String.fetchOne(db, "SELECT name FROM ...") // String?
|
||||
///
|
||||
/// - parameters:
|
||||
/// - db: A database connection.
|
||||
/// - sql: An SQL query.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: An optional value.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? {
|
||||
return try fetchOne(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Swift's Optional comes with built-in methods that allow to fetch cursors
|
||||
/// and arrays of optional DatabaseValueConvertible:
|
||||
///
|
||||
/// try Optional<String>.fetchCursor(db, "SELECT name FROM ...", arguments:...) // DatabaseCursor<String?>
|
||||
/// try Optional<String>.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String?]
|
||||
///
|
||||
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
|
||||
/// try Optional<String>.fetchCursor(statement, arguments:...) // DatabaseCursor<String?>
|
||||
/// try Optional<String>.fetchAll(statement, arguments:...) // [String?]
|
||||
///
|
||||
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
|
||||
extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching From SelectStatement
|
||||
|
||||
/// Returns a cursor over optional values fetched from a prepared statement.
|
||||
///
|
||||
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
|
||||
/// let names = try Optional<String>.fetchCursor(statement) // DatabaseCursor<String?>
|
||||
/// while let name = try names.next() { // String?
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - statement: The statement to run.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: A cursor over fetched optional values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchCursor(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DatabaseCursor<Wrapped?> {
|
||||
// Reuse a single mutable row for performance
|
||||
let row = try Row(statement: statement).adapted(with: adapter, layout: statement)
|
||||
return statement.cursor(arguments: arguments, next: {
|
||||
let dbValue: DatabaseValue = row.value(atIndex: 0)
|
||||
return dbValue.losslessConvert(sql: statement.sql, arguments: arguments) as Wrapped?
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an array of optional values fetched from a prepared statement.
|
||||
///
|
||||
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
|
||||
/// let names = try Optional<String>.fetchAll(statement) // [String?]
|
||||
///
|
||||
/// - parameters:
|
||||
/// - statement: The statement to run.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: An array of optional values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchAll(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Wrapped?] {
|
||||
return try Array(fetchCursor(statement, arguments: arguments, adapter: adapter))
|
||||
}
|
||||
}
|
||||
|
||||
extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching From Request
|
||||
|
||||
/// Returns a cursor over optional values fetched from a fetch request.
|
||||
///
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn)
|
||||
/// let names = try Optional<String>.fetchCursor(db, request) // DatabaseCursor<String?>
|
||||
/// while let name = try names.next() { // String?
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - db: A database connection.
|
||||
/// - requet: A fetch request.
|
||||
/// - returns: A cursor over fetched optional values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchCursor(_ db: Database, _ request: Request) throws -> DatabaseCursor<Wrapped?> {
|
||||
let (statement, adapter) = try request.prepare(db)
|
||||
return try fetchCursor(statement, adapter: adapter)
|
||||
}
|
||||
|
||||
/// Returns an array of optional values fetched from a fetch request.
|
||||
///
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn)
|
||||
/// let names = try Optional<String>.fetchAll(db, request) // [String?]
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchAll(_ db: Database, _ request: Request) throws -> [Wrapped?] {
|
||||
let (statement, adapter) = try request.prepare(db)
|
||||
return try fetchAll(statement, adapter: adapter)
|
||||
}
|
||||
}
|
||||
|
||||
extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching From SQL
|
||||
|
||||
/// Returns a cursor over optional values fetched from an SQL query.
|
||||
///
|
||||
/// let names = try Optional<String>.fetchCursor(db, "SELECT name FROM ...") // DatabaseCursor<String?>
|
||||
/// while let name = try names.next() { // String?
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - db: A database connection.
|
||||
/// - sql: An SQL query.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: A cursor over fetched optional values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DatabaseCursor<Wrapped?> {
|
||||
return try fetchCursor(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
|
||||
}
|
||||
|
||||
/// Returns an array of optional values fetched from an SQL query.
|
||||
///
|
||||
/// let names = try String.fetchAll(db, "SELECT name FROM ...") // [String?]
|
||||
///
|
||||
/// - parameters:
|
||||
/// - db: A database connection.
|
||||
/// - sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter
|
||||
/// - returns: An array of optional values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Wrapped?] {
|
||||
return try fetchAll(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/// The protocol for all types that can update a database.
|
||||
///
|
||||
/// It is adopted by DatabaseQueue and DatabasePool.
|
||||
///
|
||||
/// The protocol comes with isolation guarantees that describe the behavior of
|
||||
/// adopting types in a multithreaded application.
|
||||
///
|
||||
/// Types that adopt the protocol can in practice provide stronger guarantees.
|
||||
/// For example, DatabaseQueue provides a stronger isolation level
|
||||
/// than DatabasePool.
|
||||
///
|
||||
/// **Warning**: Isolation guarantees stand as long as there is no external
|
||||
/// connection to the database. Should you have to cope with external
|
||||
/// connections, protect yourself with transactions, and be ready to setup a
|
||||
/// [busy handler](https://www.sqlite.org/c3ref/busy_handler.html).
|
||||
public protocol DatabaseWriter : DatabaseReader {
|
||||
|
||||
// MARK: - Writing in Database
|
||||
|
||||
/// Synchronously executes a block that takes a database connection, and
|
||||
/// returns its result.
|
||||
///
|
||||
/// Eventual concurrent database updates are postponed until the block
|
||||
/// has executed.
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
func write<T>(_ block: (Database) throws -> T) rethrows -> T
|
||||
|
||||
/// Synchronously executes a block that takes a database connection, and
|
||||
/// returns its result.
|
||||
///
|
||||
/// Eventual concurrent database updates are postponed until the block
|
||||
/// has executed.
|
||||
///
|
||||
/// This method is reentrant. It should be avoided because it fosters
|
||||
/// dangerous concurrency practices.
|
||||
func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T
|
||||
|
||||
// MARK: - Reading from Database
|
||||
|
||||
/// Synchronously or asynchronously executes a read-only block that takes a
|
||||
/// database connection.
|
||||
///
|
||||
/// This method must be called from a writing dispatch queue.
|
||||
///
|
||||
/// The *block* argument is guaranteed to see the database in the state it
|
||||
/// has at the moment this method is called (see below). Eventual concurrent
|
||||
/// database updates are *not visible* inside the block.
|
||||
///
|
||||
/// What is the "current state" of the database?
|
||||
///
|
||||
/// - When this method is called outside of any transaction, the current
|
||||
/// state is the last committed state.
|
||||
///
|
||||
/// try writer.write { db in
|
||||
/// try db.execute("DELETE FROM persons")
|
||||
/// try writer.readFromCurrentState { db in
|
||||
/// // Guaranteed to be zero
|
||||
/// try Int.fetchOne(db, "SELECT COUNT(*) FROM persons")!
|
||||
/// }
|
||||
/// try db.execute("INSERT INTO persons ...")
|
||||
/// }
|
||||
///
|
||||
/// - When this method is called inside an uncommitted transation, the
|
||||
/// current state depends on the caller:
|
||||
///
|
||||
/// DatabasePool.readFromCurrentState runs *block* asynchronously in a
|
||||
/// concurrent reader dispatch queue, and release the writing dispatch
|
||||
/// queue early, before the block has finished. In the example below,
|
||||
/// the insertion runs concurrently with the select, and the select sees
|
||||
/// the database in its last committed state.
|
||||
///
|
||||
/// try dbPool.write { db in
|
||||
/// try db.execute("DELETE FROM persons")
|
||||
/// db.inTransaction {
|
||||
/// try db.execute("INSERT INTO persons ...")
|
||||
/// try dbPool.readFromCurrentState { db in
|
||||
/// // Zero
|
||||
/// try Int.fetchOne(db, "SELECT COUNT(*) FROM persons")!
|
||||
/// }
|
||||
/// return .commit
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// DatabaseQueue.readFromCurrentState simply runs *block* synchronously,
|
||||
/// and returns when the block has completed. In the example below, the
|
||||
/// select sees the uncommitted state of the database, and the insertion
|
||||
/// is run after the select.
|
||||
///
|
||||
/// try dbQueue.write { db in
|
||||
/// try db.execute("DELETE FROM persons")
|
||||
/// db.inTransaction {
|
||||
/// try db.execute("INSERT INTO persons ...")
|
||||
/// try dbQueue.readFromCurrentState { db in
|
||||
/// // One
|
||||
/// try Int.fetchOne(db, "SELECT COUNT(*) FROM persons")!
|
||||
/// }
|
||||
/// return .commit
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
func readFromCurrentState(_ block: @escaping (Database) -> Void) throws
|
||||
}
|
||||
|
||||
extension DatabaseWriter {
|
||||
|
||||
// MARK: - Transaction Observers
|
||||
|
||||
/// Add a transaction observer, so that it gets notified of
|
||||
/// database changes.
|
||||
///
|
||||
/// - parameter transactionObserver: A transaction observer.
|
||||
/// - parameter extent: The duration of the observation. The default is
|
||||
/// the observer lifetime (observation lasts until observer
|
||||
/// is deallocated).
|
||||
public func add(transactionObserver: TransactionObserver, extent: Database.TransactionObservationExtent = .observerLifetime) {
|
||||
write { $0.add(transactionObserver: transactionObserver, extent: extent) }
|
||||
}
|
||||
|
||||
/// Remove a transaction observer.
|
||||
public func remove(transactionObserver: TransactionObserver) {
|
||||
write { $0.remove(transactionObserver: transactionObserver) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,519 @@
|
||||
/// The protocol for all types that define a way to fetch database rows.
|
||||
///
|
||||
/// Requests can feed the fetching methods of any fetchable type (Row,
|
||||
/// value, record):
|
||||
///
|
||||
/// let request: Request = ...
|
||||
/// try Row.fetchCursor(db, request) // DatabaseCursor<Row>
|
||||
/// try String.fetchAll(db, request) // [String]
|
||||
/// try Person.fetchOne(db, request) // Person?
|
||||
public protocol Request {
|
||||
/// A tuple that contains a prepared statement that is ready to be
|
||||
/// executed, and an eventual row adapter.
|
||||
func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?)
|
||||
|
||||
/// The number of rows fetched by the request.
|
||||
///
|
||||
/// Default implementation builds a naive SQL query based on the statement
|
||||
/// returned by the `prepare` method: `SELECT COUNT(*) FROM (...)`.
|
||||
///
|
||||
/// Adopting types can refine this countRequest method and return more
|
||||
/// efficient SQL.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
func fetchCount(_ db: Database) throws -> Int
|
||||
}
|
||||
|
||||
extension Request {
|
||||
/// The number of rows fetched by the request.
|
||||
///
|
||||
/// This default implementation builds a naive SQL query based on the
|
||||
/// statement returned by the `prepare` method: `SELECT COUNT(*) FROM (...)`.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
public func fetchCount(_ db: Database) throws -> Int {
|
||||
let (statement, _) = try prepare(db)
|
||||
let sql = "SELECT COUNT(*) FROM (\(statement.sql))"
|
||||
return try Int.fetchOne(db, sql, arguments: statement.arguments)!
|
||||
}
|
||||
}
|
||||
|
||||
extension Request {
|
||||
/// Returns a request bound to type T.
|
||||
///
|
||||
/// The returned request can fetch if the type T is fetchable (Row,
|
||||
/// value, record).
|
||||
///
|
||||
/// // minHeight in Double?
|
||||
/// let minHeight = Person
|
||||
/// .select(min(heightColumn))
|
||||
/// .asRequest(of: Double.self) // <--
|
||||
/// .fetchOne(db)
|
||||
///
|
||||
/// - parameter type: The fetched type T
|
||||
/// - returns: A typed request bound to type T.
|
||||
public func asRequest<T>(of type: T.Type) -> AnyTypedRequest<T> {
|
||||
return AnyTypedRequest { try self.prepare($0) }
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// Returns an adapted request.
|
||||
public func adapted(_ adapter: @escaping (Database) throws -> RowAdapter) -> AdaptedRequest<Self> {
|
||||
return AdaptedRequest(self, adapter)
|
||||
}
|
||||
}
|
||||
|
||||
/// An adapted request.
|
||||
public struct AdaptedRequest<Base: Request> : Request {
|
||||
/// Creates an adapted request from a base request and a closure that builds
|
||||
/// a row adapter from a database connection.
|
||||
init(_ base: Base, _ adapter: @escaping (Database) throws -> RowAdapter) {
|
||||
self.base = base
|
||||
self.adapter = adapter
|
||||
}
|
||||
|
||||
/// A tuple that contains a prepared statement that is ready to be
|
||||
/// executed, and an eventual row adapter.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
|
||||
let (statement, baseAdapter) = try base.prepare(db)
|
||||
if let baseAdapter = baseAdapter {
|
||||
return try (statement, ChainedAdapter(first: baseAdapter, second: adapter(db)))
|
||||
} else {
|
||||
return try (statement, adapter(db))
|
||||
}
|
||||
}
|
||||
|
||||
/// The number of rows fetched by the request.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
public func fetchCount(_ db: Database) throws -> Int {
|
||||
return try base.fetchCount(db)
|
||||
}
|
||||
|
||||
private let base: Base
|
||||
private let adapter: (Database) throws -> RowAdapter
|
||||
}
|
||||
|
||||
/// A type-erased Request.
|
||||
///
|
||||
/// An instance of AnyRequest forwards its operations to an underlying request,
|
||||
/// hiding its specifics.
|
||||
public struct AnyRequest : Request {
|
||||
/// Creates a new request that wraps and forwards operations to `request`.
|
||||
public init(_ request: Request) {
|
||||
self._prepare = { try request.prepare($0) }
|
||||
}
|
||||
|
||||
/// Creates a new request whose `prepare()` method wraps and forwards
|
||||
/// operations the argument closure.
|
||||
public init(_ prepare: @escaping (Database) throws -> (SelectStatement, RowAdapter?)) {
|
||||
_prepare = prepare
|
||||
}
|
||||
|
||||
/// A tuple that contains a prepared statement that is ready to be
|
||||
/// executed, and an eventual row adapter.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
|
||||
return try _prepare(db)
|
||||
}
|
||||
|
||||
private let _prepare: (Database) throws -> (SelectStatement, RowAdapter?)
|
||||
}
|
||||
|
||||
/// A Request built from raw SQL.
|
||||
public struct SQLRequest : Request {
|
||||
/// Creates a new request from an SQL string, optional arguments, and
|
||||
/// optional row adapter.
|
||||
///
|
||||
/// let request = SQLRequest("SELECT * FROM persons")
|
||||
/// let request = SQLRequest("SELECT * FROM persons WHERE id = ?", arguments: [1])
|
||||
///
|
||||
/// - parameters:
|
||||
/// - sql: An SQL query.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter.
|
||||
/// - cached: Defaults to false. If true, the request reuses a cached
|
||||
/// prepared statement.
|
||||
/// - returns: A SQLRequest
|
||||
public init(_ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, cached: Bool = false) {
|
||||
self.init(sql, arguments: arguments, adapter: adapter, fromCache: cached ? .user : nil)
|
||||
}
|
||||
|
||||
/// Creates a new request from an SQL string, optional arguments, and
|
||||
/// optional row adapter.
|
||||
///
|
||||
/// let request = SQLRequest("SELECT * FROM persons")
|
||||
/// let request = SQLRequest("SELECT * FROM persons WHERE id = ?", arguments: [1])
|
||||
///
|
||||
/// - parameters:
|
||||
/// - sql: An SQL query.
|
||||
/// - arguments: Optional statement arguments.
|
||||
/// - adapter: Optional RowAdapter.
|
||||
/// - statementCacheName: Optional statement cache name.
|
||||
/// - returns: A SQLRequest
|
||||
init(_ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, fromCache statementCacheName: Database.StatementCacheName?) {
|
||||
self.sql = sql
|
||||
self.arguments = arguments
|
||||
self.adapter = adapter
|
||||
self.statementCacheName = statementCacheName
|
||||
}
|
||||
|
||||
/// A tuple that contains a prepared statement that is ready to be
|
||||
/// executed, and an eventual row adapter.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
|
||||
let statement: SelectStatement
|
||||
if let statementCacheName = statementCacheName {
|
||||
statement = try db.selectStatement(sql, fromCache: statementCacheName)
|
||||
} else {
|
||||
statement = try db.makeSelectStatement(sql)
|
||||
}
|
||||
if let arguments = arguments {
|
||||
try statement.setArgumentsWithValidation(arguments)
|
||||
}
|
||||
return (statement, adapter)
|
||||
}
|
||||
|
||||
private let sql: String
|
||||
private let arguments: StatementArguments?
|
||||
private let adapter: RowAdapter?
|
||||
private let statementCacheName: Database.StatementCacheName?
|
||||
}
|
||||
|
||||
/// The protocol for requests that know how to decode database rows.
|
||||
///
|
||||
/// Typed requests can fetch if their associated type RowDecoder is able to
|
||||
/// decode rows (Row, value, record)
|
||||
///
|
||||
/// struct Person: RowConvertible { ... }
|
||||
/// let request: ... // Some TypedRequest that fetches Person
|
||||
/// try request.fetchCursor(db) // DatabaseCursor<Person>
|
||||
/// try request.fetchAll(db) // [Person]
|
||||
/// try request.fetchOne(db) // Person?
|
||||
public protocol TypedRequest : Request {
|
||||
|
||||
/// The type that can convert raw database rows to fetched values
|
||||
associatedtype RowDecoder
|
||||
}
|
||||
|
||||
extension TypedRequest {
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// Returns an adapted typed request.
|
||||
public func adapted(_ adapter: @escaping (Database) throws -> RowAdapter) -> AdaptedTypedRequest<Self> {
|
||||
return AdaptedTypedRequest(self, adapter)
|
||||
}
|
||||
}
|
||||
|
||||
/// An adapted typed request.
|
||||
public struct AdaptedTypedRequest<Base: TypedRequest> : TypedRequest {
|
||||
|
||||
/// The type that can convert raw database rows to fetched values
|
||||
public typealias RowDecoder = Base.RowDecoder
|
||||
|
||||
/// Creates an adapted request from a base request and a closure that builds
|
||||
/// a row adapter from a database connection.
|
||||
init(_ base: Base, _ adapter: @escaping (Database) throws -> RowAdapter) {
|
||||
adaptedRequest = AdaptedRequest(base, adapter)
|
||||
}
|
||||
|
||||
/// A tuple that contains a prepared statement that is ready to be
|
||||
/// executed, and an eventual row adapter.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
|
||||
return try adaptedRequest.prepare(db)
|
||||
}
|
||||
|
||||
/// The number of rows fetched by the request.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
public func fetchCount(_ db: Database) throws -> Int {
|
||||
return try adaptedRequest.fetchCount(db)
|
||||
}
|
||||
|
||||
private let adaptedRequest: AdaptedRequest<Base>
|
||||
}
|
||||
|
||||
/// A type-erased TypedRequest.
|
||||
///
|
||||
/// An instance of AnyTypedRequest forwards its operations to an underlying
|
||||
/// typed request, hiding its specifics.
|
||||
public struct AnyTypedRequest<T> : TypedRequest {
|
||||
/// The type that can convert raw database rows to fetched values
|
||||
public typealias RowDecoder = T
|
||||
|
||||
/// Creates a new request that wraps and forwards operations to `request`.
|
||||
public init<Request>(_ request: Request) where Request: TypedRequest, Request.RowDecoder == RowDecoder {
|
||||
self._prepare = { try request.prepare($0) }
|
||||
}
|
||||
|
||||
/// Creates a new request whose `prepare()` method wraps and forwards
|
||||
/// operations the argument closure.
|
||||
public init(_ prepare: @escaping (Database) throws -> (SelectStatement, RowAdapter?)) {
|
||||
_prepare = prepare
|
||||
}
|
||||
|
||||
/// A tuple that contains a prepared statement that is ready to be
|
||||
/// executed, and an eventual row adapter.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
|
||||
return try _prepare(db)
|
||||
}
|
||||
|
||||
private let _prepare: (Database) throws -> (SelectStatement, RowAdapter?)
|
||||
}
|
||||
|
||||
extension TypedRequest where RowDecoder: RowConvertible {
|
||||
|
||||
// MARK: Fetching Record and RowConvertible
|
||||
|
||||
/// A cursor over fetched records.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches Person
|
||||
/// let persons = try request.fetchCursor(db) // DatabaseCursor<Person>
|
||||
/// while let person = try persons.next() { // Person
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: A cursor over fetched records.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchCursor(_ db: Database) throws -> DatabaseCursor<RowDecoder> {
|
||||
return try RowDecoder.fetchCursor(db, self)
|
||||
}
|
||||
|
||||
/// An array of fetched records.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches Person
|
||||
/// let persons = try request.fetchAll(db) // [Person]
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: An array of records.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchAll(_ db: Database) throws -> [RowDecoder] {
|
||||
return try RowDecoder.fetchAll(db, self)
|
||||
}
|
||||
|
||||
/// The first fetched record.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches Person
|
||||
/// let person = try request.fetchOne(db) // Person?
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: An optional record.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchOne(_ db: Database) throws -> RowDecoder? {
|
||||
return try RowDecoder.fetchOne(db, self)
|
||||
}
|
||||
}
|
||||
|
||||
extension TypedRequest where RowDecoder: DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching Values
|
||||
|
||||
/// A cursor over fetched values.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches String
|
||||
/// let strings = try request.fetchCursor(db) // DatabaseCursor<String>
|
||||
/// while let string = try strings.next() { // String
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: A cursor over fetched values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchCursor(_ db: Database) throws -> DatabaseCursor<RowDecoder> {
|
||||
return try RowDecoder.fetchCursor(db, self)
|
||||
}
|
||||
|
||||
/// An array of fetched values.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches String
|
||||
/// let strings = try request.fetchAll(db) // [String]
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: An array of values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchAll(_ db: Database) throws -> [RowDecoder] {
|
||||
return try RowDecoder.fetchAll(db, self)
|
||||
}
|
||||
|
||||
/// The first fetched value.
|
||||
///
|
||||
/// The result is nil if the request returns no row, or if no value can be
|
||||
/// extracted from the first row.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches String
|
||||
/// let string = try request.fetchOne(db) // String?
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: An optional value.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchOne(_ db: Database) throws -> RowDecoder? {
|
||||
return try RowDecoder.fetchOne(db, self)
|
||||
}
|
||||
}
|
||||
|
||||
extension TypedRequest where RowDecoder: DatabaseValueConvertible & StatementColumnConvertible {
|
||||
|
||||
// MARK: Fetching Values
|
||||
|
||||
/// A cursor over fetched values.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches String
|
||||
/// let strings = try request.fetchCursor(db) // DatabaseCursor<String>
|
||||
/// while let string = try strings.next() { // String
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: A cursor over fetched values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchCursor(_ db: Database) throws -> DatabaseCursor<RowDecoder> {
|
||||
return try RowDecoder.fetchCursor(db, self)
|
||||
}
|
||||
|
||||
/// An array of fetched values.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches String
|
||||
/// let strings = try request.fetchAll(db) // [String]
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: An array of values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchAll(_ db: Database) throws -> [RowDecoder] {
|
||||
return try RowDecoder.fetchAll(db, self)
|
||||
}
|
||||
|
||||
/// The first fetched value.
|
||||
///
|
||||
/// The result is nil if the request returns no row, or if no value can be
|
||||
/// extracted from the first row.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches String
|
||||
/// let string = try request.fetchOne(db) // String?
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: An optional value.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchOne(_ db: Database) throws -> RowDecoder? {
|
||||
return try RowDecoder.fetchOne(db, self)
|
||||
}
|
||||
}
|
||||
|
||||
extension TypedRequest where RowDecoder: _OptionalProtocol, RowDecoder._Wrapped: DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching Optional values
|
||||
|
||||
/// A cursor over fetched optional values.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches Optional<String>
|
||||
/// let strings = try request.fetchCursor(db) // DatabaseCursor<String?>
|
||||
/// while let string = try strings.next() { // String?
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: A cursor over fetched values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchCursor(_ db: Database) throws -> DatabaseCursor<RowDecoder._Wrapped?> {
|
||||
return try Optional<RowDecoder._Wrapped>.fetchCursor(db, self)
|
||||
}
|
||||
|
||||
/// An array of fetched optional values.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches Optional<String>
|
||||
/// let strings = try request.fetchAll(db) // [String?]
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: An array of values.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchAll(_ db: Database) throws -> [RowDecoder._Wrapped?] {
|
||||
return try Optional<RowDecoder._Wrapped>.fetchAll(db, self)
|
||||
}
|
||||
}
|
||||
|
||||
extension TypedRequest where RowDecoder: Row {
|
||||
|
||||
// MARK: Fetching Rows
|
||||
|
||||
/// A cursor over fetched rows.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches Row
|
||||
/// let rows = try request.fetchCursor(db) // DatabaseCursor<Row>
|
||||
/// while let row = try rows.next() { // Row
|
||||
/// let id: Int64 = row.value(atIndex: 0)
|
||||
/// let name: String = row.value(atIndex: 1)
|
||||
/// }
|
||||
///
|
||||
/// Fetched rows are reused during the cursor iteration: don't turn a row
|
||||
/// cursor into an array with `Array(rows)` or `rows.filter { ... }` since
|
||||
/// you would not get the distinct rows you expect. Use `Row.fetchAll(...)`
|
||||
/// instead.
|
||||
///
|
||||
/// For the same reason, make sure you make a copy whenever you extract a
|
||||
/// row for later use: `row.copy()`.
|
||||
///
|
||||
/// If the database is modified during the cursor iteration, the remaining
|
||||
/// elements are undefined.
|
||||
///
|
||||
/// The cursor must be iterated in a protected dispath queue.
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: A cursor over fetched rows.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchCursor(_ db: Database) throws -> DatabaseCursor<Row> {
|
||||
return try Row.fetchCursor(db, self)
|
||||
}
|
||||
|
||||
/// An array of fetched rows.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches Row
|
||||
/// let rows = try request.fetchAll(db)
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: An array of fetched rows.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchAll(_ db: Database) throws -> [Row] {
|
||||
return try Row.fetchAll(db, self)
|
||||
}
|
||||
|
||||
/// The first fetched row.
|
||||
///
|
||||
/// let request: ... // Some TypedRequest that fetches Row
|
||||
/// let row = try request.fetchOne(db)
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: A,n optional rows.
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public func fetchOne(_ db: Database) throws -> Row? {
|
||||
return try Row.fetchOne(db, self)
|
||||
}
|
||||
}
|
||||
Loaded 100 of 403 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user