motion-yapper 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +3 -1
  4. data/lib/yapper.rb +3 -3
  5. data/lib/yapper/db.rb +61 -4
  6. data/lib/yapper/document/persistence.rb +4 -0
  7. data/lib/yapper/document/selection.rb +13 -0
  8. data/lib/yapper/version.rb +1 -1
  9. data/motion-yapper.gemspec +1 -1
  10. data/spec/integration/search_spec.rb +111 -0
  11. data/vendor/Podfile.lock +11 -7
  12. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -2
  13. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +10 -7
  14. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -2
  15. metadata +19 -297
  16. data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
  17. data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
  18. data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
  19. data/vendor/Pods/.build/libPods.a +0 -0
  20. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +0 -41
  21. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +0 -102
  22. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h +0 -63
  23. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDDispatchQueueLogFormatter.h +0 -128
  24. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +0 -369
  25. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +0 -99
  26. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +0 -634
  27. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +0 -30
  28. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +0 -181
  29. data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  30. data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +0 -8
  31. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +0 -91
  32. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +0 -23
  33. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +0 -547
  34. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +0 -449
  35. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +0 -29
  36. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +0 -37
  37. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +0 -15
  38. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +0 -11
  39. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +0 -444
  40. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +0 -11
  41. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +0 -81
  42. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +0 -12
  43. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -17
  44. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +0 -39
  45. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +0 -32
  46. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +0 -89
  47. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +0 -32
  48. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -77
  49. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  50. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +0 -68
  51. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +0 -158
  52. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +0 -17
  53. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +0 -446
  54. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +0 -42
  55. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +0 -35
  56. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +0 -29
  57. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +0 -163
  58. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +0 -79
  59. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +0 -99
  60. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +0 -59
  61. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +0 -125
  62. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +0 -384
  63. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +0 -149
  64. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +0 -33
  65. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -83
  66. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +0 -33
  67. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +0 -18
  68. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +0 -58
  69. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +0 -13
  70. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +0 -121
  71. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +0 -651
  72. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +0 -127
  73. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +0 -272
  74. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
  75. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +0 -116
  76. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +0 -842
  77. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
  78. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +0 -63
  79. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +0 -36
  80. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
  81. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +0 -170
  82. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +0 -330
  83. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  84. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +0 -498
  85. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +0 -99
  86. data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +0 -74
  87. data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +0 -17
  88. data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +0 -41
  89. data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +0 -15
  90. data/vendor/Pods/CocoaLumberjack/LICENSE.txt +0 -18
  91. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +0 -41
  92. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +0 -100
  93. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +0 -102
  94. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +0 -727
  95. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +0 -369
  96. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +0 -1539
  97. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +0 -99
  98. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +0 -634
  99. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +0 -1208
  100. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +0 -181
  101. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +0 -1520
  102. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h +0 -63
  103. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.m +0 -191
  104. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.h +0 -128
  105. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +0 -253
  106. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +0 -30
  107. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +0 -127
  108. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +0 -7
  109. data/vendor/Pods/CocoaLumberjack/README.markdown +0 -74
  110. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +0 -41
  111. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +0 -102
  112. data/vendor/Pods/Headers/CocoaLumberjack/DDContextFilterLogFormatter.h +0 -63
  113. data/vendor/Pods/Headers/CocoaLumberjack/DDDispatchQueueLogFormatter.h +0 -128
  114. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +0 -369
  115. data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +0 -99
  116. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +0 -634
  117. data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +0 -30
  118. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +0 -181
  119. data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  120. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +0 -23
  121. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +0 -547
  122. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +0 -449
  123. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +0 -15
  124. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +0 -11
  125. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +0 -11
  126. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +0 -81
  127. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +0 -12
  128. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +0 -39
  129. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +0 -32
  130. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +0 -89
  131. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +0 -32
  132. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  133. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +0 -68
  134. data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +0 -42
  135. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +0 -35
  136. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +0 -29
  137. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +0 -163
  138. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +0 -99
  139. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +0 -59
  140. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +0 -384
  141. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +0 -149
  142. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +0 -33
  143. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +0 -33
  144. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +0 -58
  145. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +0 -651
  146. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +0 -127
  147. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +0 -272
  148. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +0 -116
  149. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +0 -842
  150. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +0 -63
  151. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +0 -330
  152. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +0 -498
  153. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +0 -99
  154. data/vendor/Pods/Headers/YapDatabase/YapSet.h +0 -41
  155. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +0 -7
  156. data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +0 -5
  157. data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +0 -5
  158. data/vendor/Pods/Headers/____Pods-environment.h +0 -38
  159. data/vendor/Pods/Manifest.lock +0 -22
  160. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  161. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +0 -39
  162. data/vendor/Pods/NSData+MD5Digest/README.md +0 -11
  163. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +0 -5
  164. data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +0 -5
  165. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +0 -7
  166. data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
  167. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +0 -5
  168. data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +0 -5
  169. data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +0 -5
  170. data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
  171. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +0 -5
  172. data/vendor/Pods/Pods-YapDatabase-dummy.m +0 -5
  173. data/vendor/Pods/Pods-YapDatabase-prefix.pch +0 -5
  174. data/vendor/Pods/Pods-YapDatabase.xcconfig +0 -1
  175. data/vendor/Pods/Pods-acknowledgements.markdown +0 -59
  176. data/vendor/Pods/Pods-acknowledgements.plist +0 -97
  177. data/vendor/Pods/Pods-dummy.m +0 -5
  178. data/vendor/Pods/Pods-environment.h +0 -38
  179. data/vendor/Pods/Pods-resources.sh +0 -68
  180. data/vendor/Pods/Pods.xcconfig +0 -5
  181. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +0 -4807
  182. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +0 -59
  183. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +0 -59
  184. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +0 -59
  185. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +0 -59
  186. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +0 -31
  187. data/vendor/Pods/YapDatabase/LICENSE.txt +0 -18
  188. data/vendor/Pods/YapDatabase/README.md +0 -32
  189. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -17
  190. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +0 -81
  191. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +0 -159
  192. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +0 -12
  193. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +0 -41
  194. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +0 -39
  195. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +0 -1235
  196. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +0 -32
  197. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +0 -77
  198. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +0 -89
  199. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +0 -146
  200. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +0 -32
  201. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +0 -298
  202. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  203. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +0 -95
  204. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +0 -68
  205. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +0 -1403
  206. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +0 -444
  207. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +0 -15
  208. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +0 -83
  209. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +0 -11
  210. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +0 -46
  211. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +0 -11
  212. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +0 -204
  213. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +0 -79
  214. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +0 -125
  215. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +0 -35
  216. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +0 -129
  217. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +0 -29
  218. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +0 -802
  219. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +0 -163
  220. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +0 -408
  221. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +0 -99
  222. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +0 -59
  223. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +0 -29
  224. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +0 -384
  225. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +0 -5254
  226. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +0 -83
  227. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +0 -18
  228. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +0 -149
  229. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +0 -161
  230. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +0 -33
  231. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +0 -331
  232. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +0 -33
  233. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +0 -245
  234. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +0 -58
  235. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +0 -1269
  236. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +0 -94
  237. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +0 -72
  238. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +0 -36
  239. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +0 -296
  240. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +0 -27
  241. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +0 -28
  242. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +0 -170
  243. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  244. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +0 -272
  245. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +0 -2500
  246. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +0 -842
  247. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +0 -1714
  248. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +0 -330
  249. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +0 -141
  250. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +0 -127
  251. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +0 -194
  252. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +0 -116
  253. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +0 -888
  254. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +0 -63
  255. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +0 -27
  256. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +0 -498
  257. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +0 -4986
  258. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +0 -99
  259. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +0 -8
  260. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +0 -19
  261. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +0 -91
  262. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +0 -465
  263. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +0 -29
  264. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +0 -48
  265. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +0 -37
  266. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +0 -83
  267. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +0 -158
  268. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +0 -73
  269. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +0 -17
  270. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +0 -56
  271. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +0 -446
  272. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +0 -13
  273. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +0 -26
  274. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +0 -121
  275. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +0 -74
  276. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +0 -603
  277. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +0 -17
  278. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +0 -35
  279. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +0 -15
  280. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +0 -31
  281. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +0 -23
  282. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +0 -199
  283. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +0 -42
  284. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +0 -96
  285. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +0 -41
  286. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +0 -82
  287. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +0 -547
  288. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +0 -2013
  289. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +0 -449
  290. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +0 -4046
  291. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +0 -651
  292. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +0 -5602
  293. data/vendor/Pods/build-iPhoneSimulator/Pods.bridgesupport +0 -3172
  294. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
@@ -1,33 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- @class YapDatabaseSecondaryIndexColumn;
4
-
5
- typedef enum {
6
- YapDatabaseSecondaryIndexTypeInteger,
7
- YapDatabaseSecondaryIndexTypeReal,
8
- YapDatabaseSecondaryIndexTypeText
9
- } YapDatabaseSecondaryIndexType;
10
-
11
-
12
- @interface YapDatabaseSecondaryIndexSetup : NSObject <NSCopying, NSFastEnumeration>
13
-
14
- - (id)init;
15
- - (id)initWithCapacity:(NSUInteger)capacity;
16
-
17
- - (void)addColumn:(NSString *)name withType:(YapDatabaseSecondaryIndexType)type;
18
-
19
- - (NSUInteger)count;
20
- - (YapDatabaseSecondaryIndexColumn *)columnAtIndex:(NSUInteger)index;
21
-
22
- - (NSArray *)columnNames;
23
-
24
- @end
25
-
26
- #pragma mark -
27
-
28
- @interface YapDatabaseSecondaryIndexColumn : NSObject
29
-
30
- @property (nonatomic, copy, readonly) NSString *name;
31
- @property (nonatomic, assign, readonly) YapDatabaseSecondaryIndexType type;
32
-
33
- @end
@@ -1,245 +0,0 @@
1
- #import "YapDatabaseSecondaryIndexSetup.h"
2
- #import "YapDatabaseLogging.h"
3
-
4
- #if ! __has_feature(objc_arc)
5
- #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
6
- #endif
7
-
8
- /**
9
- * Define log level for this file: OFF, ERROR, WARN, INFO, VERBOSE
10
- * See YapDatabaseLogging.h for more information.
11
- **/
12
- #if DEBUG
13
- static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
14
- #else
15
- static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
16
- #endif
17
-
18
-
19
- @interface YapDatabaseSecondaryIndexColumn ()
20
- - (id)initWithName:(NSString *)name type:(YapDatabaseSecondaryIndexType)type;
21
- @end
22
-
23
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
24
- #pragma mark -
25
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26
-
27
- @implementation YapDatabaseSecondaryIndexSetup
28
- {
29
- NSMutableArray *setup;
30
- }
31
-
32
- - (id)init
33
- {
34
- return [self initWithCapacity:0];
35
- }
36
-
37
- - (id)initWithCapacity:(NSUInteger)capacity
38
- {
39
- if ((self = [super init]))
40
- {
41
- if (capacity > 0)
42
- setup = [[NSMutableArray alloc] initWithCapacity:capacity];
43
- else
44
- setup = [[NSMutableArray alloc] init];
45
- }
46
- return self;
47
- }
48
-
49
- - (id)initForCopy
50
- {
51
- self = [super init];
52
- return self;
53
- }
54
-
55
- - (BOOL)isReservedName:(NSString *)columnName
56
- {
57
- if ([columnName caseInsensitiveCompare:@"rowid"] == NSOrderedSame)
58
- return YES;
59
-
60
- if ([columnName caseInsensitiveCompare:@"oid"] == NSOrderedSame)
61
- return YES;
62
-
63
- if ([columnName caseInsensitiveCompare:@"_rowid_"] == NSOrderedSame)
64
- return YES;
65
-
66
- return NO;
67
- }
68
-
69
- - (BOOL)isExistingName:(NSString *)columnName
70
- {
71
- // SQLite column names are not case sensitive.
72
-
73
- for (YapDatabaseSecondaryIndexColumn *column in setup)
74
- {
75
- if ([column.name caseInsensitiveCompare:columnName] == NSOrderedSame)
76
- {
77
- return YES;
78
- }
79
- }
80
-
81
- return NO;
82
- }
83
-
84
- - (void)addColumn:(NSString *)columnName withType:(YapDatabaseSecondaryIndexType)type
85
- {
86
- if (columnName == nil)
87
- {
88
- NSAssert(NO, @"Invalid columnName: nil");
89
-
90
- YDBLogError(@"%@: Invalid columnName: nil", THIS_METHOD);
91
- return;
92
- }
93
-
94
- if ([self isReservedName:columnName])
95
- {
96
- NSAssert(NO, @"Invalid columnName: columnName is reserved");
97
-
98
- YDBLogError(@"Invalid columnName: columnName is reserved");
99
- return;
100
- }
101
-
102
- if ([self isExistingName:columnName])
103
- {
104
- NSAssert(NO, @"Invalid columnName: columnName already exists");
105
-
106
- YDBLogError(@"Invalid columnName: columnName already exists");
107
- return;
108
- }
109
-
110
- if (type != YapDatabaseSecondaryIndexTypeInteger &&
111
- type != YapDatabaseSecondaryIndexTypeReal &&
112
- type != YapDatabaseSecondaryIndexTypeText)
113
- {
114
- NSAssert(NO, @"Invalid type");
115
-
116
- YDBLogError(@"%@: Invalid type", THIS_METHOD);
117
- return;
118
- }
119
-
120
- YapDatabaseSecondaryIndexColumn *column =
121
- [[YapDatabaseSecondaryIndexColumn alloc] initWithName:columnName type:type];
122
-
123
- [setup addObject:column];
124
- }
125
-
126
- - (NSUInteger)count
127
- {
128
- return [setup count];
129
- }
130
-
131
- - (YapDatabaseSecondaryIndexColumn *)columnAtIndex:(NSUInteger)index
132
- {
133
- if (index < [setup count])
134
- return [setup objectAtIndex:index];
135
- else
136
- return nil;
137
- }
138
-
139
- - (NSArray *)columnNames
140
- {
141
- NSMutableArray *columnNames = [NSMutableArray arrayWithCapacity:[setup count]];
142
-
143
- for (YapDatabaseSecondaryIndexColumn *column in setup)
144
- {
145
- [columnNames addObject:column.name];
146
- }
147
-
148
- return [columnNames copy];
149
- }
150
-
151
- - (id)copyWithZone:(NSZone *)zone
152
- {
153
- YapDatabaseSecondaryIndexSetup *copy = [[YapDatabaseSecondaryIndexSetup alloc] initForCopy];
154
- copy->setup = [setup mutableCopy];
155
-
156
- return copy;
157
- }
158
-
159
- - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
160
- objects:(__unsafe_unretained id [])buffer
161
- count:(NSUInteger)length
162
- {
163
- return [setup countByEnumeratingWithState:state objects:buffer count:length];
164
- }
165
-
166
- /**
167
- * The columns parameter comes from:
168
- * [YapDatabase columnNamesAndAffinityForTable:using:]
169
- **/
170
- - (BOOL)matchesExistingColumnNamesAndAffinity:(NSDictionary *)columns
171
- {
172
- // The columns parameter will include the 'rowid' column, which we need to ignore.
173
-
174
- if (([setup count] + 1) != [columns count])
175
- {
176
- return NO;
177
- }
178
-
179
- for (YapDatabaseSecondaryIndexColumn *setupColumn in setup)
180
- {
181
- NSString *existingAffinity = [columns objectForKey:setupColumn.name];
182
- if (existingAffinity == nil)
183
- {
184
- return NO;
185
- }
186
- else
187
- {
188
- if (setupColumn.type == YapDatabaseSecondaryIndexTypeInteger)
189
- {
190
- if ([existingAffinity caseInsensitiveCompare:@"INTEGER"] != NSOrderedSame)
191
- return NO;
192
- }
193
- else if (setupColumn.type == YapDatabaseSecondaryIndexTypeReal)
194
- {
195
- if ([existingAffinity caseInsensitiveCompare:@"REAL"] != NSOrderedSame)
196
- return NO;
197
- }
198
- else if (setupColumn.type == YapDatabaseSecondaryIndexTypeText)
199
- {
200
- if ([existingAffinity caseInsensitiveCompare:@"TEXT"] != NSOrderedSame)
201
- return NO;
202
- }
203
- }
204
- }
205
-
206
- return YES;
207
- }
208
-
209
- @end
210
-
211
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
212
- #pragma mark -
213
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
214
-
215
- @implementation YapDatabaseSecondaryIndexColumn
216
-
217
- @synthesize name = name;
218
- @synthesize type = type;
219
-
220
- - (id)initWithName:(NSString *)inName type:(YapDatabaseSecondaryIndexType)inType
221
- {
222
- if ((self = [super init]))
223
- {
224
- name = [inName copy];
225
- type = inType;
226
- }
227
- return self;
228
- }
229
-
230
- - (NSString *)description
231
- {
232
- NSString *typeStr;
233
- if (type == YapDatabaseSecondaryIndexTypeInteger)
234
- typeStr = @"Integer";
235
- else if (type == YapDatabaseSecondaryIndexTypeReal)
236
- typeStr = @"Real";
237
- else if (type == YapDatabaseSecondaryIndexTypeText)
238
- typeStr = @"Text";
239
- else
240
- typeStr = @"Unknown";
241
-
242
- return [NSString stringWithFormat:@"<YapDatabaseSecondaryIndexColumn: name(%@), type(%@)>", name, typeStr];
243
- }
244
-
245
- @end
@@ -1,58 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- #import "YapDatabaseExtensionTransaction.h"
4
- #import "YapDatabaseQuery.h"
5
-
6
-
7
- @interface YapDatabaseSecondaryIndexTransaction : YapDatabaseExtensionTransaction
8
-
9
- /**
10
- * These methods allow you to enumerates matches from the secondary index(es) using a given query.
11
- *
12
- * The query that you input is an SQL style query (appropriate for SQLite semantics),
13
- * excluding the "SELECT ... FROM 'tableName'" component.
14
- *
15
- * For example:
16
- *
17
- * query = [YapDatabaseQuery queryWithFormat:@"WHERE age >= 62"];
18
- * [[transaction ext:@"idx"] enumerateKeysMatchingQuery:query usingBlock:^(NSString *key, BOOL *stop) {
19
- *
20
- * // ...
21
- * }];
22
- *
23
- * You can also pass parameters to the query using the standard SQLite placeholder:
24
- *
25
- * query = [YapDatabaseQuery queryWithFormat:@"WHERE age >= ? AND state == ?", @(age), state];
26
- * [[transaction ext:@"idx"] enumerateKeysMatchingQuery:query usingBlock:^(NSString *key, BOOL *stop) {
27
- *
28
- * // ...
29
- * }];
30
- *
31
- * For more information, and more examples, please see YapDatabaseQuery.
32
- *
33
- * @return NO if there was a problem with the given query. YES otherwise.
34
- *
35
- * @see YapDatabaseQuery
36
- **/
37
-
38
- - (BOOL)enumerateKeysMatchingQuery:(YapDatabaseQuery *)query
39
- usingBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block;
40
-
41
- - (BOOL)enumerateKeysAndMetadataMatchingQuery:(YapDatabaseQuery *)query
42
- usingBlock:
43
- (void (^)(NSString *collection, NSString *key, id metadata, BOOL *stop))block;
44
-
45
- - (BOOL)enumerateKeysAndObjectsMatchingQuery:(YapDatabaseQuery *)query
46
- usingBlock:
47
- (void (^)(NSString *collection, NSString *key, id object, BOOL *stop))block;
48
-
49
- - (BOOL)enumerateRowsMatchingQuery:(YapDatabaseQuery *)query
50
- usingBlock:
51
- (void (^)(NSString *collection, NSString *key, id object, id metadata, BOOL *stop))block;
52
- /**
53
- * Skips the enumeration process, and just gives you the count of matching rows.
54
- **/
55
-
56
- - (BOOL)getNumberOfRows:(NSUInteger *)count matchingQuery:(YapDatabaseQuery *)query;
57
-
58
- @end
@@ -1,1269 +0,0 @@
1
- #import "YapDatabaseSecondaryIndexTransaction.h"
2
- #import "YapDatabaseSecondaryIndexPrivate.h"
3
- #import "YapDatabaseStatement.h"
4
-
5
- #import "YapDatabasePrivate.h"
6
- #import "YapDatabaseExtensionPrivate.h"
7
-
8
- #import "YapDatabaseLogging.h"
9
-
10
- #if ! __has_feature(objc_arc)
11
- #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
12
- #endif
13
-
14
- /**
15
- * Define log level for this file: OFF, ERROR, WARN, INFO, VERBOSE
16
- * See YapDatabaseLogging.h for more information.
17
- **/
18
- #if DEBUG
19
- static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
20
- #else
21
- static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
22
- #endif
23
-
24
- /**
25
- * Declare that this class implements YapDatabaseExtensionTransaction_Hooks protocol.
26
- * This is done privately, as the protocol is internal.
27
- **/
28
- @interface YapDatabaseSecondaryIndexTransaction () <YapDatabaseExtensionTransaction_Hooks>
29
- @end
30
-
31
-
32
- @implementation YapDatabaseSecondaryIndexTransaction
33
-
34
- - (id)initWithSecondaryIndexConnection:(YapDatabaseSecondaryIndexConnection *)inSecondaryIndexConnection
35
- databaseTransaction:(YapDatabaseReadTransaction *)inDatabaseTransaction
36
- {
37
- if ((self = [super init]))
38
- {
39
- secondaryIndexConnection = inSecondaryIndexConnection;
40
- databaseTransaction = inDatabaseTransaction;
41
- }
42
- return self;
43
- }
44
-
45
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
46
- #pragma mark Extension Lifecycle
47
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48
-
49
- /**
50
- * Required override method from YapDatabaseExtensionTransaction.
51
- *
52
- * This method is called to create any necessary tables (if needed),
53
- * as well as populate the view (if needed) by enumerating over the existing rows in the database.
54
- **/
55
- - (BOOL)createIfNeeded
56
- {
57
- int oldClassVersion = 0;
58
- BOOL hasOldClassVersion = [self getIntValue:&oldClassVersion forExtensionKey:@"classVersion"];
59
- int classVersion = YAP_DATABASE_SECONDARY_INDEX_CLASS_VERSION;
60
-
61
- if (oldClassVersion != classVersion)
62
- {
63
- // First time registration (or at least for this version)
64
-
65
- if (hasOldClassVersion) {
66
- if (![self dropTable]) return NO;
67
- }
68
-
69
- if (![self createTable]) return NO;
70
- if (![self populate]) return NO;
71
-
72
- [self setIntValue:classVersion forExtensionKey:@"classVersion"];
73
-
74
- int userSuppliedConfigVersion = secondaryIndexConnection->secondaryIndex->version;
75
- [self setIntValue:userSuppliedConfigVersion forExtensionKey:@"version"];
76
- }
77
- else
78
- {
79
- // Check user-supplied config version.
80
- // We may need to re-populate the database if the groupingBlock or sortingBlock changed.
81
-
82
- int oldVersion = [self intValueForExtensionKey:@"version"];
83
- int newVersion = secondaryIndexConnection->secondaryIndex->version;
84
-
85
- if (oldVersion != newVersion)
86
- {
87
- if (![self dropTable]) return NO;
88
- if (![self createTable]) return NO;
89
- if (![self populate]) return NO;
90
-
91
- [self setIntValue:newVersion forExtensionKey:@"version"];
92
- }
93
-
94
- // The following code is designed to assist developers in understanding extension changes.
95
- // The rules are straight-forward and easy to remember:
96
- //
97
- // - If you make ANY changes to the configuration of the extension then you MUST change the version.
98
- //
99
- // For this extension, that means you MUST change the version if ANY of the following are true:
100
- //
101
- // - you changed the setup
102
- // - you changed the block in any meaningful way (which would result in different values for any existing row)
103
- //
104
- // Note: The code below detects only changes to the setup.
105
- // It could theoretically handle such changes, and automatically force a repopulation.
106
- // This is a bad idea for two reasons:
107
- //
108
- // - First, it complicates the rules. The rules, as stated above, are simple. They follow the KISS principle.
109
- // Changing these rules would pose a complication that increases cognitive overhead.
110
- // It may be easy to remember now, but 6 months from now the nuance has become hazy.
111
- // Additionally, the rest of the database system follows the same set of rules.
112
- // So adding a complication for just a particular extension is even more confusing.
113
- //
114
- // - Second, it adds overhead to the registration process.
115
- // This sanity check doesn't come for free.
116
- // And the overhead is only helpful during the development lifecycle.
117
- // It's certainly not something you want in a shipped version.
118
- //
119
- #if DEBUG
120
- else
121
- {
122
- __unsafe_unretained YapDatabase *database = databaseTransaction->connection->database;
123
- sqlite3 *db = databaseTransaction->connection->db;
124
-
125
- NSDictionary *columns = [database columnNamesAndAffinityForTable:[self tableName] using:db];
126
-
127
- YapDatabaseSecondaryIndexSetup *setup = secondaryIndexConnection->secondaryIndex->setup;
128
-
129
- if (![setup matchesExistingColumnNamesAndAffinity:columns])
130
- {
131
- YDBLogError(@"Error creating secondary index extension (%@):"
132
- @" The given setup doesn't match the previously registered setup."
133
- @" If you change the setup, or you change the block in any meaningful way,"
134
- @" then you MUST change the version as well.",
135
- THIS_METHOD);
136
- return NO;
137
- }
138
- }
139
- #endif
140
- }
141
-
142
- return YES;
143
- }
144
-
145
- /**
146
- * Required override method from YapDatabaseExtensionTransaction.
147
- *
148
- * This method is called to prepare the transaction for use.
149
- *
150
- * Remember, an extension transaction is a very short lived object.
151
- * Thus it stores the majority of its state within the extension connection (the parent).
152
- *
153
- * Return YES if completed successfully, or if already prepared.
154
- * Return NO if some kind of error occured.
155
- **/
156
- - (BOOL)prepareIfNeeded
157
- {
158
- return YES;
159
- }
160
-
161
- /**
162
- * Internal method.
163
- *
164
- * This method is called, if needed, to drop the old table.
165
- **/
166
- - (BOOL)dropTable
167
- {
168
- sqlite3 *db = databaseTransaction->connection->db;
169
-
170
- NSString *tableName = [self tableName];
171
- NSString *dropTable = [NSString stringWithFormat:@"DROP TABLE IF EXISTS \"%@\";", tableName];
172
-
173
- int status = sqlite3_exec(db, [dropTable UTF8String], NULL, NULL, NULL);
174
- if (status != SQLITE_OK)
175
- {
176
- YDBLogError(@"%@ - Failed dropping secondary index table (%@): %d %s",
177
- THIS_METHOD, dropTable, status, sqlite3_errmsg(db));
178
- return NO;
179
- }
180
-
181
- return YES;
182
- }
183
-
184
- /**
185
- * Internal method.
186
- *
187
- * This method is called, if needed, to create the tables for the view.
188
- **/
189
- - (BOOL)createTable
190
- {
191
- sqlite3 *db = databaseTransaction->connection->db;
192
-
193
- NSString *tableName = [self tableName];
194
- YapDatabaseSecondaryIndexSetup *setup = secondaryIndexConnection->secondaryIndex->setup;
195
-
196
- YDBLogVerbose(@"Creating secondary index table for registeredName(%@): %@", [self registeredName], tableName);
197
-
198
- // CREATE TABLE IF NOT EXISTS "tableName" ("rowid" INTEGER PRIMARY KEY, index1, index2...);
199
-
200
- NSMutableString *createTable = [NSMutableString stringWithCapacity:100];
201
- [createTable appendFormat:@"CREATE TABLE IF NOT EXISTS \"%@\" (\"rowid\" INTEGER PRIMARY KEY", tableName];
202
-
203
- for (YapDatabaseSecondaryIndexColumn *column in setup)
204
- {
205
- if (column.type == YapDatabaseSecondaryIndexTypeInteger)
206
- {
207
- [createTable appendFormat:@", \"%@\" INTEGER", column.name];
208
- }
209
- else if (column.type == YapDatabaseSecondaryIndexTypeReal)
210
- {
211
- [createTable appendFormat:@", \"%@\" REAL", column.name];
212
- }
213
- else if (column.type == YapDatabaseSecondaryIndexTypeText)
214
- {
215
- [createTable appendFormat:@", \"%@\" TEXT", column.name];
216
- }
217
- }
218
-
219
- [createTable appendString:@");"];
220
-
221
- int status = sqlite3_exec(db, [createTable UTF8String], NULL, NULL, NULL);
222
- if (status != SQLITE_OK)
223
- {
224
- YDBLogError(@"%@ - Failed creating secondary index table (%@): %d %s",
225
- THIS_METHOD, tableName, status, sqlite3_errmsg(db));
226
- return NO;
227
- }
228
-
229
- for (YapDatabaseSecondaryIndexColumn *column in setup)
230
- {
231
- NSString *createIndex =
232
- [NSString stringWithFormat:@"CREATE INDEX IF NOT EXISTS \"%@\" ON \"%@\" (\"%@\");",
233
- column.name, tableName, column.name];
234
-
235
- status = sqlite3_exec(db, [createIndex UTF8String], NULL, NULL, NULL);
236
- if (status != SQLITE_OK)
237
- {
238
- YDBLogError(@"Failed creating index on '%@': %d %s", column.name, status, sqlite3_errmsg(db));
239
- return NO;
240
- }
241
- }
242
-
243
- return YES;
244
- }
245
-
246
- /**
247
- * Internal method.
248
- *
249
- * This method is called, if needed, to populate the FTS indexes.
250
- * It does so by enumerating the rows in the database, and invoking the usual blocks and insertion methods.
251
- **/
252
- - (BOOL)populate
253
- {
254
- // Remove everything from the database
255
-
256
- [self removeAllRowids];
257
-
258
- // Enumerate the existing rows in the database and populate the indexes
259
-
260
- __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
261
-
262
- if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithKey)
263
- {
264
- __unsafe_unretained YapDatabaseSecondaryIndexWithKeyBlock block =
265
- (YapDatabaseSecondaryIndexWithKeyBlock)secondaryIndex->block;
266
-
267
- [databaseTransaction _enumerateKeysInAllCollectionsUsingBlock:
268
- ^(int64_t rowid, NSString *collection, NSString *key, BOOL *stop) {
269
-
270
- block(secondaryIndexConnection->blockDict, collection, key);
271
-
272
- if ([secondaryIndexConnection->blockDict count] > 0)
273
- {
274
- [self addRowid:rowid isNew:YES];
275
- [secondaryIndexConnection->blockDict removeAllObjects];
276
- }
277
- }];
278
- }
279
- else if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithObject)
280
- {
281
- __unsafe_unretained YapDatabaseSecondaryIndexWithObjectBlock block =
282
- (YapDatabaseSecondaryIndexWithObjectBlock)secondaryIndex->block;
283
-
284
- [databaseTransaction _enumerateKeysAndObjectsInAllCollectionsUsingBlock:
285
- ^(int64_t rowid, NSString *collection, NSString *key, id object, BOOL *stop) {
286
-
287
- block(secondaryIndexConnection->blockDict, collection, key, object);
288
-
289
- if ([secondaryIndexConnection->blockDict count] > 0)
290
- {
291
- [self addRowid:rowid isNew:YES];
292
- [secondaryIndexConnection->blockDict removeAllObjects];
293
- }
294
- }];
295
- }
296
- else if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithMetadata)
297
- {
298
- __unsafe_unretained YapDatabaseSecondaryIndexWithMetadataBlock block =
299
- (YapDatabaseSecondaryIndexWithMetadataBlock)secondaryIndex->block;
300
-
301
- [databaseTransaction _enumerateKeysAndMetadataInAllCollectionsUsingBlock:
302
- ^(int64_t rowid, NSString *collection, NSString *key, id metadata, BOOL *stop) {
303
-
304
- block(secondaryIndexConnection->blockDict, collection, key, metadata);
305
-
306
- if ([secondaryIndexConnection->blockDict count] > 0)
307
- {
308
- [self addRowid:rowid isNew:YES];
309
- [secondaryIndexConnection->blockDict removeAllObjects];
310
- }
311
- }];
312
- }
313
- else // if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithRow)
314
- {
315
- __unsafe_unretained YapDatabaseSecondaryIndexWithRowBlock block =
316
- (YapDatabaseSecondaryIndexWithRowBlock)secondaryIndex->block;
317
-
318
- [databaseTransaction _enumerateRowsInAllCollectionsUsingBlock:
319
- ^(int64_t rowid, NSString *collection, NSString *key, id object, id metadata, BOOL *stop) {
320
-
321
- block(secondaryIndexConnection->blockDict, collection, key, object, metadata);
322
-
323
- if ([secondaryIndexConnection->blockDict count] > 0)
324
- {
325
- [self addRowid:rowid isNew:YES];
326
- [secondaryIndexConnection->blockDict removeAllObjects];
327
- }
328
- }];
329
- }
330
-
331
- return YES;
332
- }
333
-
334
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
335
- #pragma mark Accessors
336
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
337
-
338
- /**
339
- * Required override method from YapDatabaseExtensionTransaction.
340
- **/
341
- - (YapDatabaseReadTransaction *)databaseTransaction
342
- {
343
- return databaseTransaction;
344
- }
345
-
346
- /**
347
- * Required override method from YapDatabaseExtensionTransaction.
348
- **/
349
- - (YapDatabaseExtensionConnection *)extensionConnection
350
- {
351
- return secondaryIndexConnection;
352
- }
353
-
354
- - (NSString *)registeredName
355
- {
356
- return [secondaryIndexConnection->secondaryIndex registeredName];
357
- }
358
-
359
- - (NSString *)tableName
360
- {
361
- return [secondaryIndexConnection->secondaryIndex tableName];
362
- }
363
-
364
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
365
- #pragma mark Logic
366
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
367
-
368
- /**
369
- * Adds a row to the table, using the given rowid along with the values in the 'blockDict' ivar.
370
- **/
371
- - (void)addRowid:(int64_t)rowid isNew:(BOOL)isNew
372
- {
373
- YDBLogAutoTrace();
374
-
375
- sqlite3_stmt *statement = NULL;
376
- if (isNew)
377
- statement = [secondaryIndexConnection insertStatement];
378
- else
379
- statement = [secondaryIndexConnection updateStatement];
380
-
381
- if (statement == NULL)
382
- return;
383
-
384
- // isNew : INSERT INTO "tableName" ("rowid", "column1", "column2", ...) VALUES (?, ?, ? ...);
385
- // !isNew : UPDATE "tableName" SET "column1" = ?, "column2" = ?, ... WHERE "rowid" = ?;
386
-
387
- int i = 1;
388
-
389
- if (isNew) {
390
- sqlite3_bind_int64(statement, i, rowid);
391
- i++;
392
- }
393
-
394
- for (YapDatabaseSecondaryIndexColumn *column in secondaryIndexConnection->secondaryIndex->setup)
395
- {
396
- id columnValue = [secondaryIndexConnection->blockDict objectForKey:column.name];
397
- if (columnValue)
398
- {
399
- if (column.type == YapDatabaseSecondaryIndexTypeInteger)
400
- {
401
- if ([columnValue isKindOfClass:[NSNumber class]])
402
- {
403
- __unsafe_unretained NSNumber *cast = (NSNumber *)columnValue;
404
-
405
- int64_t num = [cast longLongValue];
406
- sqlite3_bind_int64(statement, i, (sqlite3_int64)num);
407
- }
408
- else
409
- {
410
- YDBLogWarn(@"Unable to bind value for column(name=%@, type=integer) with unsupported class: %@."
411
- @" Column requires NSNumber.",
412
- column.name, NSStringFromClass([columnValue class]));
413
- }
414
- }
415
- else if (column.type == YapDatabaseSecondaryIndexTypeReal)
416
- {
417
- if ([columnValue isKindOfClass:[NSNumber class]])
418
- {
419
- __unsafe_unretained NSNumber *cast = (NSNumber *)columnValue;
420
-
421
- double num = [cast doubleValue];
422
- sqlite3_bind_double(statement, i, num);
423
- }
424
- else if ([columnValue isKindOfClass:[NSDate class]])
425
- {
426
- __unsafe_unretained NSDate *cast = (NSDate *)columnValue;
427
-
428
- double num = [cast timeIntervalSinceReferenceDate];
429
- sqlite3_bind_double(statement, i, num);
430
- }
431
- else
432
- {
433
- YDBLogWarn(@"Unable to bind value for column(name=%@, type=real) with unsupported class: %@."
434
- @" Column requires NSNumber or NSDate.",
435
- column.name, NSStringFromClass([columnValue class]));
436
- }
437
- }
438
- else // if (column.type == YapDatabaseSecondaryIndexTypeText)
439
- {
440
- if ([columnValue isKindOfClass:[NSString class]])
441
- {
442
- __unsafe_unretained NSString *cast = (NSString *)columnValue;
443
-
444
- sqlite3_bind_text(statement, i, [cast UTF8String], -1, SQLITE_TRANSIENT);
445
- }
446
- else
447
- {
448
- YDBLogWarn(@"Unable to bind value for column(name=%@, type=text) with unsupported class: %@."
449
- @" Column requires NSString.",
450
- column.name, NSStringFromClass([columnValue class]));
451
- }
452
- }
453
- }
454
-
455
- i++;
456
- }
457
-
458
- if (!isNew) {
459
- sqlite3_bind_int64(statement, i, rowid);
460
- i++;
461
- }
462
-
463
- int status = sqlite3_step(statement);
464
- if (status != SQLITE_DONE)
465
- {
466
- YDBLogError(@"Error executing '%s': %d %s",
467
- isNew ? "insertStatement" : "updateStatement",
468
- status, sqlite3_errmsg(databaseTransaction->connection->db));
469
- }
470
-
471
- sqlite3_clear_bindings(statement);
472
- sqlite3_reset(statement);
473
-
474
- isMutated = YES;
475
- }
476
-
477
- - (void)removeRowid:(int64_t)rowid
478
- {
479
- YDBLogAutoTrace();
480
-
481
- sqlite3_stmt *statement = [secondaryIndexConnection removeStatement];
482
- if (statement == NULL) return;
483
-
484
- // DELETE FROM "tableName" WHERE "rowid" = ?;
485
-
486
- sqlite3_bind_int64(statement, 1, rowid);
487
-
488
- int status = sqlite3_step(statement);
489
- if (status != SQLITE_DONE)
490
- {
491
- YDBLogError(@"Error executing 'removeStatement': %d %s",
492
- status, sqlite3_errmsg(databaseTransaction->connection->db));
493
- }
494
-
495
- sqlite3_clear_bindings(statement);
496
- sqlite3_reset(statement);
497
-
498
- isMutated = YES;
499
- }
500
-
501
- - (void)removeRowids:(NSArray *)rowids
502
- {
503
- YDBLogAutoTrace();
504
-
505
- NSUInteger count = [rowids count];
506
-
507
- if (count == 0) return;
508
- if (count == 1)
509
- {
510
- int64_t rowid = [[rowids objectAtIndex:0] longLongValue];
511
-
512
- [self removeRowid:rowid];
513
- return;
514
- }
515
-
516
- // DELETE FROM "tableName" WHERE "rowid" in (?, ?, ...);
517
- //
518
- // Note: We don't have to worry sqlite's max number of host parameters.
519
- // YapDatabase gives us the rowids in batches where each batch is already capped at this number.
520
-
521
- NSUInteger capacity = 50 + (count * 3);
522
- NSMutableString *query = [NSMutableString stringWithCapacity:capacity];
523
-
524
- [query appendFormat:@"DELETE FROM \"%@\" WHERE \"rowid\" IN (", [self tableName]];
525
-
526
- NSUInteger i;
527
- for (i = 0; i < count; i++)
528
- {
529
- if (i == 0)
530
- [query appendFormat:@"?"];
531
- else
532
- [query appendFormat:@", ?"];
533
- }
534
-
535
- [query appendString:@");"];
536
-
537
- sqlite3_stmt *statement;
538
-
539
- int status = sqlite3_prepare_v2(databaseTransaction->connection->db, [query UTF8String], -1, &statement, NULL);
540
- if (status != SQLITE_OK)
541
- {
542
- YDBLogError(@"Error creating 'removeRowids' statement: %d %s",
543
- status, sqlite3_errmsg(databaseTransaction->connection->db));
544
- return;
545
- }
546
-
547
- for (i = 0; i < count; i++)
548
- {
549
- int64_t rowid = [[rowids objectAtIndex:i] longLongValue];
550
-
551
- sqlite3_bind_int64(statement, (int)(i + 1), rowid);
552
- }
553
-
554
- status = sqlite3_step(statement);
555
- if (status != SQLITE_DONE)
556
- {
557
- YDBLogError(@"Error executing 'removeRowids' statement: %d %s",
558
- status, sqlite3_errmsg(databaseTransaction->connection->db));
559
- }
560
-
561
- sqlite3_finalize(statement);
562
-
563
- isMutated = YES;
564
- }
565
-
566
- - (void)removeAllRowids
567
- {
568
- YDBLogAutoTrace();
569
-
570
- sqlite3_stmt *statement = [secondaryIndexConnection removeAllStatement];
571
- if (statement == NULL)
572
- return;
573
-
574
- int status;
575
-
576
- // DELETE FROM "tableName";
577
-
578
- YDBLogVerbose(@"DELETE FROM '%@';", [self tableName]);
579
-
580
- status = sqlite3_step(statement);
581
- if (status != SQLITE_DONE)
582
- {
583
- YDBLogError(@"%@ (%@): Error in removeAllStatement: %d %s",
584
- THIS_METHOD, [self registeredName],
585
- status, sqlite3_errmsg(databaseTransaction->connection->db));
586
- }
587
-
588
- sqlite3_reset(statement);
589
-
590
- isMutated = YES;
591
- }
592
-
593
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
594
- #pragma mark Cleanup & Commit
595
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
596
-
597
- /**
598
- * Required override method from YapDatabaseExtension
599
- **/
600
- - (void)commitTransaction
601
- {
602
- // An extensionTransaction is only valid within the scope of its encompassing databaseTransaction.
603
- // I imagine this may occasionally be misunderstood, and developers may attempt to store the extension in an ivar,
604
- // and then use it outside the context of the database transaction block.
605
- // Thus, this code is here as a safety net to ensure that such accidental misuse doesn't do any damage.
606
-
607
- secondaryIndexConnection = nil; // Do not remove !
608
- databaseTransaction = nil; // Do not remove !
609
- }
610
-
611
- /**
612
- * Required override method from YapDatabaseExtension
613
- **/
614
- - (void)rollbackTransaction
615
- {
616
- // An extensionTransaction is only valid within the scope of its encompassing databaseTransaction.
617
- // I imagine this may occasionally be misunderstood, and developers may attempt to store the extension in an ivar,
618
- // and then use it outside the context of the database transaction block.
619
- // Thus, this code is here as a safety net to ensure that such accidental misuse doesn't do any damage.
620
-
621
- secondaryIndexConnection = nil; // Do not remove !
622
- databaseTransaction = nil; // Do not remove !
623
- }
624
-
625
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
626
- #pragma mark YapDatabaseExtensionTransaction_Hooks
627
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
628
-
629
- /**
630
- * YapDatabase extension hook.
631
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
632
- **/
633
- - (void)handleInsertObject:(id)object
634
- forCollectionKey:(YapCollectionKey *)collectionKey
635
- withMetadata:(id)metadata
636
- rowid:(int64_t)rowid
637
- {
638
- YDBLogAutoTrace();
639
-
640
- __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
641
-
642
- __unsafe_unretained NSString *collection = collectionKey.collection;
643
- __unsafe_unretained NSString *key = collectionKey.key;
644
-
645
- // Invoke the block to find out if the object should be included in the index.
646
-
647
- if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithKey)
648
- {
649
- __unsafe_unretained YapDatabaseSecondaryIndexWithKeyBlock block =
650
- (YapDatabaseSecondaryIndexWithKeyBlock)secondaryIndex->block;
651
-
652
- block(secondaryIndexConnection->blockDict, collection, key);
653
- }
654
- else if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithObject)
655
- {
656
- __unsafe_unretained YapDatabaseSecondaryIndexWithObjectBlock block =
657
- (YapDatabaseSecondaryIndexWithObjectBlock)secondaryIndex->block;
658
-
659
- block(secondaryIndexConnection->blockDict, collection, key, object);
660
- }
661
- else if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithMetadata)
662
- {
663
- __unsafe_unretained YapDatabaseSecondaryIndexWithMetadataBlock block =
664
- (YapDatabaseSecondaryIndexWithMetadataBlock)secondaryIndex->block;
665
-
666
- block(secondaryIndexConnection->blockDict, collection, key, metadata);
667
- }
668
- else
669
- {
670
- __unsafe_unretained YapDatabaseSecondaryIndexWithRowBlock block =
671
- (YapDatabaseSecondaryIndexWithRowBlock)secondaryIndex->block;
672
-
673
- block(secondaryIndexConnection->blockDict, collection, key, object, metadata);
674
- }
675
-
676
- if ([secondaryIndexConnection->blockDict count] == 0)
677
- {
678
- // This was an insert operation, so we don't have to worry about removing anything.
679
- }
680
- else
681
- {
682
- // Add values to index.
683
- // This was an insert operation, so we know we can insert rather than update.
684
-
685
- [self addRowid:rowid isNew:YES];
686
- [secondaryIndexConnection->blockDict removeAllObjects];
687
- }
688
- }
689
-
690
- /**
691
- * YapDatabase extension hook.
692
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
693
- **/
694
- - (void)handleUpdateObject:(id)object
695
- forCollectionKey:(YapCollectionKey *)collectionKey
696
- withMetadata:(id)metadata
697
- rowid:(int64_t)rowid
698
- {
699
- YDBLogAutoTrace();
700
-
701
- __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
702
-
703
- __unsafe_unretained NSString *collection = collectionKey.collection;
704
- __unsafe_unretained NSString *key = collectionKey.key;
705
-
706
- // Invoke the block to find out if the object should be included in the index.
707
-
708
- if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithKey)
709
- {
710
- __unsafe_unretained YapDatabaseSecondaryIndexWithKeyBlock block =
711
- (YapDatabaseSecondaryIndexWithKeyBlock)secondaryIndex->block;
712
-
713
- block(secondaryIndexConnection->blockDict, collection, key);
714
- }
715
- else if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithObject)
716
- {
717
- __unsafe_unretained YapDatabaseSecondaryIndexWithObjectBlock block =
718
- (YapDatabaseSecondaryIndexWithObjectBlock)secondaryIndex->block;
719
-
720
- block(secondaryIndexConnection->blockDict, collection, key, object);
721
- }
722
- else if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithMetadata)
723
- {
724
- __unsafe_unretained YapDatabaseSecondaryIndexWithMetadataBlock block =
725
- (YapDatabaseSecondaryIndexWithMetadataBlock)secondaryIndex->block;
726
-
727
- block(secondaryIndexConnection->blockDict, collection, key, metadata);
728
- }
729
- else
730
- {
731
- __unsafe_unretained YapDatabaseSecondaryIndexWithRowBlock block =
732
- (YapDatabaseSecondaryIndexWithRowBlock)secondaryIndex->block;
733
-
734
- block(secondaryIndexConnection->blockDict, collection, key, object, metadata);
735
- }
736
-
737
- if ([secondaryIndexConnection->blockDict count] == 0)
738
- {
739
- // Remove associated values from index (if needed).
740
- // This was an update operation, so the rowid may have previously had values in the index.
741
-
742
- [self removeRowid:rowid];
743
- }
744
- else
745
- {
746
- // Add values to index (or update them).
747
- // This was an update operation, so we need to insert or update.
748
-
749
- [self addRowid:rowid isNew:NO];
750
- [secondaryIndexConnection->blockDict removeAllObjects];
751
- }
752
- }
753
-
754
- /**
755
- * YapDatabase extension hook.
756
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
757
- **/
758
- - (void)handleReplaceObject:(id)object forCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
759
- {
760
- YDBLogAutoTrace();
761
-
762
- __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
763
-
764
- __unsafe_unretained NSString *collection = collectionKey.collection;
765
- __unsafe_unretained NSString *key = collectionKey.key;
766
-
767
- // Invoke the block to find out if the object should be included in the index.
768
-
769
- id metadata = nil;
770
-
771
- if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithKey ||
772
- secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithMetadata)
773
- {
774
- // Index values are based on the key or object.
775
- // Neither have changed, and thus the values haven't changed.
776
-
777
- return;
778
- }
779
- else
780
- {
781
- // Index values are based on object or row (object+metadata).
782
- // Invoke block to see what the new values are.
783
-
784
- if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithObject)
785
- {
786
- __unsafe_unretained YapDatabaseSecondaryIndexWithObjectBlock block =
787
- (YapDatabaseSecondaryIndexWithObjectBlock)secondaryIndex->block;
788
-
789
- block(secondaryIndexConnection->blockDict, collection, key, object);
790
- }
791
- else
792
- {
793
- __unsafe_unretained YapDatabaseSecondaryIndexWithRowBlock block =
794
- (YapDatabaseSecondaryIndexWithRowBlock)secondaryIndex->block;
795
-
796
- metadata = [databaseTransaction objectForCollectionKey:collectionKey withRowid:rowid];
797
- block(secondaryIndexConnection->blockDict, collection, key, object, metadata);
798
- }
799
-
800
- if ([secondaryIndexConnection->blockDict count] == 0)
801
- {
802
- // Remove associated values from index (if needed).
803
- // This was an update operation, so the rowid may have previously had values in the index.
804
-
805
- [self removeRowid:rowid];
806
- }
807
- else
808
- {
809
- // Add values to index (or update them).
810
- // This was an update operation, so we need to insert or update.
811
-
812
- [self addRowid:rowid isNew:NO];
813
- [secondaryIndexConnection->blockDict removeAllObjects];
814
- }
815
- }
816
- }
817
-
818
- /**
819
- * YapDatabase extension hook.
820
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
821
- **/
822
- - (void)handleReplaceMetadata:(id)metadata forCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
823
- {
824
- YDBLogAutoTrace();
825
-
826
- __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
827
-
828
- __unsafe_unretained NSString *collection = collectionKey.collection;
829
- __unsafe_unretained NSString *key = collectionKey.key;
830
-
831
- // Invoke the block to find out if the object should be included in the index.
832
-
833
- id object = nil;
834
-
835
- if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithKey ||
836
- secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithObject)
837
- {
838
- // Index values are based on the key or object.
839
- // Neither have changed, and thus the values haven't changed.
840
-
841
- return;
842
- }
843
- else
844
- {
845
- // Index values are based on metadata or objectAndMetadata.
846
- // Invoke block to see what the new values are.
847
-
848
- if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithMetadata)
849
- {
850
- __unsafe_unretained YapDatabaseSecondaryIndexWithMetadataBlock block =
851
- (YapDatabaseSecondaryIndexWithMetadataBlock)secondaryIndex->block;
852
-
853
- block(secondaryIndexConnection->blockDict, collection, key, metadata);
854
- }
855
- else
856
- {
857
- __unsafe_unretained YapDatabaseSecondaryIndexWithRowBlock block =
858
- (YapDatabaseSecondaryIndexWithRowBlock)secondaryIndex->block;
859
-
860
- object = [databaseTransaction objectForCollectionKey:collectionKey withRowid:rowid];
861
- block(secondaryIndexConnection->blockDict, collection, key, object, metadata);
862
- }
863
-
864
- if ([secondaryIndexConnection->blockDict count] == 0)
865
- {
866
- // Remove associated values from index (if needed).
867
- // This was an update operation, so the rowid may have previously had values in the index.
868
-
869
- [self removeRowid:rowid];
870
- }
871
- else
872
- {
873
- // Add values to index (or update them).
874
- // This was an update operation, so we need to insert or update.
875
-
876
- [self addRowid:rowid isNew:NO];
877
- [secondaryIndexConnection->blockDict removeAllObjects];
878
- }
879
- }
880
- }
881
-
882
- /**
883
- * YapDatabase extension hook.
884
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
885
- **/
886
- - (void)handleTouchObjectForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
887
- {
888
- // Nothing to do for this extension
889
- }
890
-
891
- /**
892
- * YapDatabase extension hook.
893
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
894
- **/
895
- - (void)handleTouchMetadataForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
896
- {
897
- // Nothing to do for this extension
898
- }
899
-
900
- /**
901
- * YapDatabase extension hook.
902
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
903
- **/
904
- - (void)handleRemoveObjectForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
905
- {
906
- YDBLogAutoTrace();
907
-
908
- [self removeRowid:rowid];
909
- }
910
-
911
- /**
912
- * YapDatabase extension hook.
913
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
914
- **/
915
- - (void)handleRemoveObjectsForKeys:(NSArray *)keys inCollection:(NSString *)collection withRowids:(NSArray *)rowids
916
- {
917
- YDBLogAutoTrace();
918
-
919
- [self removeRowids:rowids];
920
- }
921
-
922
- /**
923
- * YapDatabase extension hook.
924
- * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
925
- **/
926
- - (void)handleRemoveAllObjectsInAllCollections
927
- {
928
- YDBLogAutoTrace();
929
-
930
- [self removeAllRowids];
931
- }
932
-
933
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
934
- #pragma mark Enumerate
935
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
936
-
937
- - (BOOL)_enumerateRowidsMatchingQuery:(YapDatabaseQuery *)query
938
- usingBlock:(void (^)(int64_t rowid, BOOL *stop))block
939
- {
940
- // Create full query using given filtering clause(s)
941
-
942
- NSString *fullQueryString =
943
- [NSString stringWithFormat:@"SELECT \"rowid\" FROM \"%@\" %@;", [self tableName], query.queryString];
944
-
945
- // Turn query into compiled sqlite statement.
946
- // Use cache if possible.
947
-
948
- sqlite3_stmt *statement = NULL;
949
-
950
- YapDatabaseStatement *wrapper = [secondaryIndexConnection->queryCache objectForKey:fullQueryString];
951
- if (wrapper)
952
- {
953
- statement = wrapper.stmt;
954
- }
955
- else
956
- {
957
- sqlite3 *db = databaseTransaction->connection->db;
958
-
959
- int status = sqlite3_prepare_v2(db, [fullQueryString UTF8String], -1, &statement, NULL);
960
- if (status != SQLITE_OK)
961
- {
962
- YDBLogError(@"%@: Error creating query:\n query: '%@'\n error: %d %s",
963
- THIS_METHOD, fullQueryString, status, sqlite3_errmsg(db));
964
-
965
- return NO;
966
- }
967
-
968
- if (secondaryIndexConnection->queryCache)
969
- {
970
- wrapper = [[YapDatabaseStatement alloc] initWithStatement:statement];
971
- [secondaryIndexConnection->queryCache setObject:wrapper forKey:fullQueryString];
972
- }
973
- }
974
-
975
- // Bind query parameters appropriately.
976
-
977
- int i = 1;
978
- for (id value in query.queryParameters)
979
- {
980
- if ([value isKindOfClass:[NSNumber class]])
981
- {
982
- __unsafe_unretained NSNumber *cast = (NSNumber *)value;
983
-
984
- CFNumberType numType = CFNumberGetType((__bridge CFNumberRef)cast);
985
-
986
- if (numType == kCFNumberFloatType ||
987
- numType == kCFNumberFloat32Type ||
988
- numType == kCFNumberFloat64Type ||
989
- numType == kCFNumberDoubleType ||
990
- numType == kCFNumberCGFloatType )
991
- {
992
- double num = [cast doubleValue];
993
- sqlite3_bind_double(statement, i, num);
994
- }
995
- else
996
- {
997
- int64_t num = [cast longLongValue];
998
- sqlite3_bind_int64(statement, i, (sqlite3_int64)num);
999
- }
1000
- }
1001
- else if ([value isKindOfClass:[NSDate class]])
1002
- {
1003
- __unsafe_unretained NSDate *cast = (NSDate *)value;
1004
-
1005
- double num = [cast timeIntervalSinceReferenceDate];
1006
- sqlite3_bind_double(statement, i, num);
1007
- }
1008
- else if ([value isKindOfClass:[NSString class]])
1009
- {
1010
- __unsafe_unretained NSString *cast = (NSString *)value;
1011
-
1012
- sqlite3_bind_text(statement, i, [cast UTF8String], -1, SQLITE_TRANSIENT);
1013
- }
1014
- else
1015
- {
1016
- YDBLogWarn(@"Unable to bind value for with unsupported class: %@", NSStringFromClass([value class]));
1017
- }
1018
-
1019
- i++;
1020
- }
1021
-
1022
- // Enumerate query results
1023
-
1024
- BOOL stop = NO;
1025
- isMutated = NO; // mutation during enumeration protection
1026
-
1027
- int status = sqlite3_step(statement);
1028
- if (status == SQLITE_ROW)
1029
- {
1030
- if (databaseTransaction->connection->needsMarkSqlLevelSharedReadLock)
1031
- [databaseTransaction->connection markSqlLevelSharedReadLockAcquired];
1032
-
1033
- do
1034
- {
1035
- int64_t rowid = sqlite3_column_int64(statement, 0);
1036
-
1037
- block(rowid, &stop);
1038
-
1039
- if (stop || isMutated) break;
1040
-
1041
- } while ((status = sqlite3_step(statement)) == SQLITE_ROW);
1042
- }
1043
-
1044
- if ((status != SQLITE_DONE) && !stop && !isMutated)
1045
- {
1046
- YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
1047
- status, sqlite3_errmsg(databaseTransaction->connection->db));
1048
- }
1049
-
1050
- sqlite3_clear_bindings(statement);
1051
- sqlite3_reset(statement);
1052
-
1053
- if (isMutated && !stop)
1054
- {
1055
- @throw [self mutationDuringEnumerationException];
1056
- }
1057
-
1058
- return (status == SQLITE_DONE);
1059
- }
1060
-
1061
- - (BOOL)enumerateKeysMatchingQuery:(YapDatabaseQuery *)query
1062
- usingBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block
1063
- {
1064
- if (query == nil) return NO;
1065
- if (block == nil) return NO;
1066
-
1067
- BOOL result = [self _enumerateRowidsMatchingQuery:query usingBlock:^(int64_t rowid, BOOL *stop) {
1068
-
1069
- YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
1070
-
1071
- block(ck.collection, ck.key, stop);
1072
- }];
1073
-
1074
- return result;
1075
- }
1076
-
1077
- - (BOOL)enumerateKeysAndMetadataMatchingQuery:(YapDatabaseQuery *)query
1078
- usingBlock:
1079
- (void (^)(NSString *collection, NSString *key, id metadata, BOOL *stop))block
1080
- {
1081
- if (query == nil) return NO;
1082
- if (block == nil) return NO;
1083
-
1084
- BOOL result = [self _enumerateRowidsMatchingQuery:query usingBlock:^(int64_t rowid, BOOL *stop) {
1085
-
1086
- YapCollectionKey *ck = nil;
1087
- id metadata = nil;
1088
- [databaseTransaction getCollectionKey:&ck metadata:&metadata forRowid:rowid];
1089
-
1090
- block(ck.collection, ck.key, metadata, stop);
1091
- }];
1092
-
1093
- return result;
1094
- }
1095
-
1096
- - (BOOL)enumerateKeysAndObjectsMatchingQuery:(YapDatabaseQuery *)query
1097
- usingBlock:
1098
- (void (^)(NSString *collection, NSString *key, id object, BOOL *stop))block
1099
- {
1100
- if (query == nil) return NO;
1101
- if (block == nil) return NO;
1102
-
1103
- BOOL result = [self _enumerateRowidsMatchingQuery:query usingBlock:^(int64_t rowid, BOOL *stop) {
1104
-
1105
- YapCollectionKey *ck = nil;
1106
- id object = nil;
1107
- [databaseTransaction getCollectionKey:&ck object:&object forRowid:rowid];
1108
-
1109
- block(ck.collection, ck.key, object, stop);
1110
- }];
1111
-
1112
- return result;
1113
- }
1114
-
1115
- - (BOOL)enumerateRowsMatchingQuery:(YapDatabaseQuery *)query
1116
- usingBlock:
1117
- (void (^)(NSString *collection, NSString *key, id object, id metadata, BOOL *stop))block
1118
- {
1119
- if (query == nil) return NO;
1120
- if (block == nil) return NO;
1121
-
1122
- BOOL result = [self _enumerateRowidsMatchingQuery:query usingBlock:^(int64_t rowid, BOOL *stop) {
1123
-
1124
- YapCollectionKey *ck = nil;
1125
- id object = nil;
1126
- id metadata = nil;
1127
- [databaseTransaction getCollectionKey:&ck object:&object metadata:&metadata forRowid:rowid];
1128
-
1129
- block(ck.collection, ck.key, object, metadata, stop);
1130
- }];
1131
-
1132
- return result;
1133
- }
1134
-
1135
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1136
- #pragma mark Count
1137
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1138
-
1139
- - (BOOL)getNumberOfRows:(NSUInteger *)countPtr matchingQuery:(YapDatabaseQuery *)query
1140
- {
1141
- // Create full query using given filtering clause(s)
1142
-
1143
- NSString *fullQueryString =
1144
- [NSString stringWithFormat:@"SELECT COUNT(*) AS NumberOfRows FROM \"%@\" %@;",
1145
- [self tableName], query.queryString];
1146
-
1147
- // Turn query into compiled sqlite statement.
1148
- // Use cache if possible.
1149
-
1150
- sqlite3_stmt *statement = NULL;
1151
-
1152
- YapDatabaseStatement *wrapper = [secondaryIndexConnection->queryCache objectForKey:fullQueryString];
1153
- if (wrapper)
1154
- {
1155
- statement = wrapper.stmt;
1156
- }
1157
- else
1158
- {
1159
- sqlite3 *db = databaseTransaction->connection->db;
1160
-
1161
- int status = sqlite3_prepare_v2(db, [fullQueryString UTF8String], -1, &statement, NULL);
1162
- if (status != SQLITE_OK)
1163
- {
1164
- YDBLogError(@"%@: Error creating query:\n query: '%@'\n error: %d %s",
1165
- THIS_METHOD, fullQueryString, status, sqlite3_errmsg(db));
1166
-
1167
- return NO;
1168
- }
1169
-
1170
- if (secondaryIndexConnection->queryCache)
1171
- {
1172
- wrapper = [[YapDatabaseStatement alloc] initWithStatement:statement];
1173
- [secondaryIndexConnection->queryCache setObject:wrapper forKey:fullQueryString];
1174
- }
1175
- }
1176
-
1177
- // Bind query parameters appropriately.
1178
-
1179
- int i = 1;
1180
- for (id value in query.queryParameters)
1181
- {
1182
- if ([value isKindOfClass:[NSNumber class]])
1183
- {
1184
- __unsafe_unretained NSNumber *cast = (NSNumber *)value;
1185
-
1186
- CFNumberType numType = CFNumberGetType((__bridge CFNumberRef)cast);
1187
-
1188
- if (numType == kCFNumberFloatType ||
1189
- numType == kCFNumberFloat32Type ||
1190
- numType == kCFNumberFloat64Type ||
1191
- numType == kCFNumberDoubleType ||
1192
- numType == kCFNumberCGFloatType )
1193
- {
1194
- double num = [cast doubleValue];
1195
- sqlite3_bind_double(statement, i, num);
1196
- }
1197
- else
1198
- {
1199
- int64_t num = [cast longLongValue];
1200
- sqlite3_bind_int64(statement, i, (sqlite3_int64)num);
1201
- }
1202
- }
1203
- else if ([value isKindOfClass:[NSDate class]])
1204
- {
1205
- __unsafe_unretained NSDate *cast = (NSDate *)value;
1206
-
1207
- double num = [cast timeIntervalSinceReferenceDate];
1208
- sqlite3_bind_double(statement, i, num);
1209
- }
1210
- else if ([value isKindOfClass:[NSString class]])
1211
- {
1212
- __unsafe_unretained NSString *cast = (NSString *)value;
1213
-
1214
- sqlite3_bind_text(statement, i, [cast UTF8String], -1, SQLITE_TRANSIENT);
1215
- }
1216
- else
1217
- {
1218
- YDBLogWarn(@"Unable to bind value for with unsupported class: %@", NSStringFromClass([value class]));
1219
- }
1220
-
1221
- i++;
1222
- }
1223
-
1224
- // Execute query
1225
-
1226
- BOOL result = YES;
1227
- NSUInteger count = 0;
1228
-
1229
- int status = sqlite3_step(statement);
1230
- if (status == SQLITE_ROW)
1231
- {
1232
- if (databaseTransaction->connection->needsMarkSqlLevelSharedReadLock)
1233
- [databaseTransaction->connection markSqlLevelSharedReadLockAcquired];
1234
-
1235
- count = (NSUInteger)sqlite3_column_int64(statement, 0);
1236
- }
1237
- else if (status == SQLITE_ERROR)
1238
- {
1239
- YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
1240
- status, sqlite3_errmsg(databaseTransaction->connection->db));
1241
- result = NO;
1242
- }
1243
-
1244
- sqlite3_clear_bindings(statement);
1245
- sqlite3_reset(statement);
1246
-
1247
- if (countPtr) *countPtr = count;
1248
- return result;
1249
- }
1250
-
1251
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1252
- #pragma mark Exceptions
1253
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1254
-
1255
- - (NSException *)mutationDuringEnumerationException
1256
- {
1257
- NSString *reason = [NSString stringWithFormat:
1258
- @"SecondaryIndex <RegisteredName=%@> was mutated while being enumerated.", [self registeredName]];
1259
-
1260
- NSDictionary *userInfo = @{ NSLocalizedRecoverySuggestionErrorKey:
1261
- @"In general, you cannot modify the database while enumerating it."
1262
- @" This is similar in concept to an NSMutableArray."
1263
- @" If you only need to make a single modification, you may do so but you MUST set the 'stop' parameter"
1264
- @" of the enumeration block to YES (*stop = YES;) immediately after making the modification."};
1265
-
1266
- return [NSException exceptionWithName:@"YapDatabaseException" reason:reason userInfo:userInfo];
1267
- }
1268
-
1269
- @end