query.json 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. {
  2. "dateTests" : {
  3. "schema" : [{
  4. "name": "DateObject",
  5. "properties": [{ "name": "date", "type": "date" }]
  6. }],
  7. "objects": [
  8. { "type": "DateObject", "value": [10000] },
  9. { "type": "DateObject", "value": [10001] },
  10. { "type": "DateObject", "value": [10002] }
  11. ],
  12. "tests": [
  13. ["QueryCount", 2, "DateObject", "date < $0", [2, "date"]],
  14. ["QueryCount", 3, "DateObject", "date <= $0", [2, "date"]],
  15. ["QueryCount", 2, "DateObject", "date > $0", [0, "date"]],
  16. ["QueryCount", 3, "DateObject", "date >= $0", [0, "date"]],
  17. ["QueryCount", 1, "DateObject", "date == $0", [0, "date"]],
  18. ["QueryCount", 2, "DateObject", "date != $0", [0, "date"]],
  19. ["QueryThrows", "DateObject", "date == 'not a date'"],
  20. ["QueryThrows", "DateObject", "date == 1"],
  21. ["QueryThrows", "DateObject", "date == $0", 1]
  22. ]
  23. },
  24. "boolTests" : {
  25. "schema" : [{
  26. "name": "BoolObject",
  27. "properties": [{ "name": "boolCol", "type": "bool" }]
  28. }],
  29. "objects": [
  30. { "type": "BoolObject", "value": [false] },
  31. { "type": "BoolObject", "value": [true] },
  32. { "type": "BoolObject", "value": [true] }
  33. ],
  34. "tests": [
  35. ["QueryCount", 2, "BoolObject", "boolCol == true"],
  36. ["QueryCount", 1, "BoolObject", "boolCol==false"],
  37. ["QueryCount", 1, "BoolObject", "boolCol != true"],
  38. ["QueryCount", 2, "BoolObject", "true == boolCol"],
  39. ["QueryCount", 2, "BoolObject", "boolCol == TRUE"],
  40. ["QueryCount", 1, "BoolObject", "boolCol == FALSE"],
  41. ["QueryCount", 2, "BoolObject", "boolCol == $0", true],
  42. ["QueryCount", 1, "BoolObject", "boolCol == $0", false],
  43. ["QueryCount", 0, "BoolObject", "boolCol == true && boolCol == false"],
  44. ["QueryCount", 3, "BoolObject", "boolCol == true || boolCol == false"],
  45. ["QueryThrows", "BoolObject", "boolCol == 0"],
  46. ["QueryThrows", "BoolObject", "boolCol == 1"],
  47. ["QueryThrows", "BoolObject", "boolCol == 'not a bool'"],
  48. ["QueryThrows", "BoolObject", "boolCol == $0", "not a bool"],
  49. ["QueryThrows", "BoolObject", "boolCol > true"],
  50. ["QueryThrows", "BoolObject", "boolCol >= true"],
  51. ["QueryThrows", "BoolObject", "boolCol < true"],
  52. ["QueryThrows", "BoolObject", "boolCol <= true"],
  53. ["QueryThrows", "BoolObject", "boolCol BEGINSWITH true"],
  54. ["QueryThrows", "BoolObject", "boolCol CONTAINS true"],
  55. ["QueryThrows", "BoolObject", "boolCol ENDSWITH true"]
  56. ]
  57. },
  58. "intTests" : {
  59. "schema" : [{
  60. "name": "IntObject",
  61. "properties": [{ "name": "intCol", "type": "int" }]
  62. }],
  63. "objects": [
  64. { "type": "IntObject", "value": [-1] },
  65. { "type": "IntObject", "value": [0] },
  66. { "type": "IntObject", "value": [100] }
  67. ],
  68. "tests": [
  69. ["QueryCount", 1, "IntObject", "intCol == -1"],
  70. ["QueryCount", 1, "IntObject", "intCol==0"],
  71. ["QueryCount", 0, "IntObject", "1 == intCol"],
  72. ["QueryCount", 2, "IntObject", "intCol != 0"],
  73. ["QueryCount", 2, "IntObject", "intCol > -1"],
  74. ["QueryCount", 3, "IntObject", "intCol >= -1"],
  75. ["QueryCount", 2, "IntObject", "intCol < 100"],
  76. ["QueryCount", 3, "IntObject", "intCol <= 100"],
  77. ["QueryCount", 1, "IntObject", "intCol > 0x1F"],
  78. ["QueryCount", 1, "IntObject", "intCol == $0", 100],
  79. ["QueryThrows", "IntObject", "intCol == 'not an int'"],
  80. ["QueryThrows", "IntObject", "intCol == true"],
  81. ["QueryThrows", "IntObject", "intCol == $0", "not an int"],
  82. ["QueryThrows", "IntObject", "intCol BEGINSWITH 1"],
  83. ["QueryThrows", "IntObject", "intCol CONTAINS 1"],
  84. ["QueryThrows", "IntObject", "intCol ENDSWITH 1"]
  85. ]
  86. },
  87. "floatTests" : {
  88. "schema" : [{
  89. "name": "FloatObject",
  90. "properties": [{ "name": "floatCol", "type": "float" }]
  91. }],
  92. "objects": [
  93. { "type": "FloatObject", "value": [-1.001] },
  94. { "type": "FloatObject", "value": [0.0] },
  95. { "type": "FloatObject", "value": [100.2] }
  96. ],
  97. "tests": [
  98. ["QueryCount", 1, "FloatObject", "floatCol == -1.001"],
  99. ["QueryCount", 1, "FloatObject", "floatCol = 0"],
  100. ["QueryCount", 0, "FloatObject", "1 == floatCol"],
  101. ["QueryCount", 2, "FloatObject", "floatCol != 0"],
  102. ["QueryCount", 2, "FloatObject", "floatCol > -1.001"],
  103. ["QueryCount", 3, "FloatObject", "floatCol >= -1.001"],
  104. ["QueryCount", 2, "FloatObject", "floatCol < 100.2"],
  105. ["QueryCount", 3, "FloatObject", "floatCol <= 100.2"],
  106. ["QueryCount", 1, "FloatObject", "floatCol > 0x1F"],
  107. ["QueryCount", 1, "FloatObject", "floatCol == $0", 100.2],
  108. ["QueryThrows", "FloatObject", "floatCol == 'not a float'"],
  109. ["QueryThrows", "FloatObject", "floatCol == true"],
  110. ["QueryThrows", "FloatObject", "floatCol == $0", "not a float"],
  111. ["QueryThrows", "FloatObject", "floatCol BEGINSWITH 1"],
  112. ["QueryThrows", "FloatObject", "floatCol CONTAINS 1"],
  113. ["QueryThrows", "FloatObject", "floatCol ENDSWITH 1"],
  114. ["Disabled", "QueryThrows", "FloatObject", "floatCol = 3.5e+38"],
  115. ["Disabled", "QueryThrows", "FloatObject", "floatCol = -3.5e+38"]
  116. ]
  117. },
  118. "doubleTests" : {
  119. "schema" : [{
  120. "name": "DoubleObject",
  121. "properties": [{ "name": "doubleCol", "type": "double" }]
  122. }],
  123. "objects": [
  124. { "type": "DoubleObject", "value": [-1.001] },
  125. { "type": "DoubleObject", "value": [0.0] },
  126. { "type": "DoubleObject", "value": [100.2] }
  127. ],
  128. "tests": [
  129. ["QueryCount", 1, "DoubleObject", "doubleCol == -1.001"],
  130. ["QueryCount", 1, "DoubleObject", "doubleCol == 0"],
  131. ["QueryCount", 0, "DoubleObject", "1 == doubleCol"],
  132. ["QueryCount", 2, "DoubleObject", "doubleCol != 0"],
  133. ["QueryCount", 2, "DoubleObject", "doubleCol > -1.001"],
  134. ["QueryCount", 3, "DoubleObject", "doubleCol >= -1.001"],
  135. ["QueryCount", 2, "DoubleObject", "doubleCol < 100.2"],
  136. ["QueryCount", 3, "DoubleObject", "doubleCol <= 100.2"],
  137. ["QueryCount", 1, "DoubleObject", "doubleCol > 0x1F"],
  138. ["QueryCount", 1, "DoubleObject", "doubleCol == $0", 100.2],
  139. ["QueryThrows", "DoubleObject", "doubleCol == 'not a double'"],
  140. ["QueryThrows", "DoubleObject", "doubleCol == true"],
  141. ["QueryThrows", "DoubleObject", "doubleCol == $0", "not a double"],
  142. ["QueryThrows", "DoubleObject", "doubleCol BEGINSWITH 1"],
  143. ["QueryThrows", "DoubleObject", "doubleCol CONTAINS 1"],
  144. ["QueryThrows", "DoubleObject", "doubleCol ENDSWITH 1"]
  145. ]
  146. },
  147. "stringTests" : {
  148. "schema" : [{
  149. "name": "StringObject",
  150. "properties": [{ "name": "stringCol", "type": "string" }]
  151. }],
  152. "objects": [
  153. { "type": "StringObject", "value": ["A"] },
  154. { "type": "StringObject", "value": ["a"] },
  155. { "type": "StringObject", "value": ["a"] },
  156. { "type": "StringObject", "value": ["C"] },
  157. { "type": "StringObject", "value": ["c"] },
  158. { "type": "StringObject", "value": ["abc"] },
  159. { "type": "StringObject", "value": ["ABC"] },
  160. { "type": "StringObject", "value": [""] },
  161. { "type": "StringObject", "value": ["\\\"\\n\\0\\r\\\\'"] }
  162. ],
  163. "tests": [
  164. ["QueryCount", 2, "StringObject", "stringCol == 'a'"],
  165. ["QueryCount", 1, "StringObject", "'c' == stringCol"],
  166. ["QueryCount", 2, "StringObject", "stringCol == \"a\""],
  167. ["QueryCount", 1, "StringObject", "stringCol=='abc'"],
  168. ["QueryCount", 1, "StringObject", "stringCol == ''"],
  169. ["QueryCount", 8, "StringObject", "stringCol != ''"],
  170. ["QueryCount", 1, "StringObject", "stringCol == \"\\\"\\n\\0\\r\\\\'\""],
  171. ["QueryCount", 3, "StringObject", "stringCol BEGINSWITH 'a'"],
  172. ["QueryCount", 1, "StringObject", "stringCol beginswith 'ab'"],
  173. ["QueryCount", 0, "StringObject", "stringCol BEGINSWITH 'abcd'"],
  174. ["QueryCount", 2, "StringObject", "stringCol BEGINSWITH 'A'"],
  175. ["QueryCount", 2, "StringObject", "stringCol ENDSWITH 'c'"],
  176. ["QueryCount", 1, "StringObject", "stringCol endswith 'bc'"],
  177. ["QueryCount", 9, "StringObject", "stringCol ENDSWITH ''"],
  178. ["QueryCount", 1, "StringObject", "stringCol CONTAINS 'b'"],
  179. ["QueryCount", 2, "StringObject", "stringCol contains 'c'"],
  180. ["QueryCount", 9, "StringObject", "stringCol CONTAINS ''"],
  181. ["QueryCount", 2, "StringObject", "stringCol == $0", "a"],
  182. ["QueryCount", 2, "StringObject", "stringCol ENDSWITH $0", "c"],
  183. ["QueryThrows", "StringObject", "stringCol == true"],
  184. ["QueryThrows", "StringObject", "stringCol == 123"],
  185. ["QueryThrows", "StringObject", "stringCol CONTAINS $0", 1],
  186. ["QueryCount", 3, "StringObject", "stringCol ==[c] 'a'"],
  187. ["QueryCount", 5, "StringObject", "stringCol BEGINSWITH[c] 'A'"],
  188. ["QueryCount", 4, "StringObject", "stringCol ENDSWITH[c] 'c'"],
  189. ["QueryCount", 2, "StringObject", "stringCol CONTAINS[c] 'B'"]
  190. ]
  191. },
  192. "binaryTests" : {
  193. "schema" : [{
  194. "name": "BinaryObject",
  195. "properties": [{ "name": "binaryCol", "type": "data" }]
  196. }],
  197. "objects": [
  198. { "type": "BinaryObject", "value": [[1, 100, 233, 255, 0]] },
  199. { "type": "BinaryObject", "value": [[1, 100]] },
  200. { "type": "BinaryObject", "value": [[100]] },
  201. { "type": "BinaryObject", "value": [[]] },
  202. { "type": "BinaryObject", "value": [[255, 0]] }
  203. ],
  204. "tests": [
  205. ["QueryCount", 1, "BinaryObject", "binaryCol == $0", [1, "binaryCol"]],
  206. ["QueryCount", 1, "BinaryObject", "$0 == binaryCol", [2, "binaryCol"]],
  207. ["QueryCount", 4, "BinaryObject", "binaryCol != $0", [0, "binaryCol"]],
  208. ["QueryCount", 1, "BinaryObject", "binaryCol BEGINSWITH $0", [0, "binaryCol"]],
  209. ["QueryCount", 2, "BinaryObject", "binaryCol BEGINSWITH $0", [1, "binaryCol"]],
  210. ["QueryCount", 2, "BinaryObject", "binaryCol ENDSWITH $0", [4, "binaryCol"]],
  211. ["QueryCount", 3, "BinaryObject", "binaryCol CONTAINS $0", [2, "binaryCol"]]
  212. ]
  213. },
  214. "objectTests" : {
  215. "schema" : [
  216. { "name": "IntObject", "properties": [
  217. { "name": "intCol", "type": "int" }
  218. ]},
  219. { "name": "LinkObject", "properties": [
  220. { "name": "linkCol", "type": "object", "objectType": "IntObject" }
  221. ]}
  222. ],
  223. "objects": [
  224. { "type": "LinkObject", "value": [[1]] },
  225. { "type": "LinkObject", "value": [[2]] },
  226. { "type": "LinkObject", "value": [null] }
  227. ],
  228. "tests": [
  229. ["QueryCount", 1, "LinkObject", "linkCol == $0", [0, "linkCol"]],
  230. ["QueryCount", 1, "LinkObject", "$0 == linkCol", [1, "linkCol"]],
  231. ["QueryCount", 2, "LinkObject", "linkCol != $0", [0, "linkCol"]],
  232. ["QueryCount", 1, "LinkObject", "linkCol = null"],
  233. ["QueryCount", 2, "LinkObject", "linkCol != NULL"],
  234. ["QueryCount", 1, "LinkObject", "linkCol = $0", null],
  235. ["QueryThrows", "LinkObject", "linkCol > $0", [0, "linkCol"]],
  236. ["QueryThrows", "LinkObject", "intCol = $0", [0, "linkCol"]]
  237. ]
  238. },
  239. "compoundTests" : {
  240. "schema" : [
  241. { "name": "IntObject",
  242. "properties": [{ "name": "intCol", "type": "int" }],
  243. "primaryKey" : "intCol" }
  244. ],
  245. "objects": [
  246. { "type": "IntObject", "value": [0] },
  247. { "type": "IntObject", "value": [1] },
  248. { "type": "IntObject", "value": [2] },
  249. { "type": "IntObject", "value": [3] }
  250. ],
  251. "tests": [
  252. ["ObjectSet", [], "IntObject", "intCol == 0 && intCol == 1"],
  253. ["ObjectSet", [0, 1], "IntObject", "intCol == 0 || intCol == 1"],
  254. ["ObjectSet", [0], "IntObject", "intCol == 0 && intCol != 1"],
  255. ["ObjectSet", [2, 3], "IntObject", "intCol >= 2 && intCol < 4"],
  256. ["ObjectSet", [0], "IntObject", "intCol == 0 && NOT intCol != 0"],
  257. ["ObjectSet", [0, 3], "IntObject", "intCol == 0 || NOT (intCol == 1 || intCol == 2)"],
  258. ["ObjectSet", [1], "IntObject", "(intCol == 0 || intCol == 1) && intCol >= 1"],
  259. ["ObjectSet", [1], "IntObject", "intCol >= 1 && (intCol == 0 || intCol == 1)"],
  260. ["ObjectSet", [0, 1], "IntObject", "intCol == 0 || (intCol == 1 && intCol >= 1)"],
  261. ["ObjectSet", [0, 1], "IntObject", "(intCol == 1 && intCol >= 1) || intCol == 0"],
  262. ["ObjectSet", [0, 1], "IntObject", "intCol == 0 || intCol == 1 && intCol >= 1"],
  263. ["ObjectSet", [0, 1, 2],"IntObject", "intCol == 0 || intCol == 1 || intCol <= 2"],
  264. ["ObjectSet", [0, 1], "IntObject", "intCol == 1 && intCol >= 1 || intCol == 0"],
  265. ["ObjectSet", [0, 1], "IntObject", "intCol == 1 || intCol == 0 && intCol <= 0 && intCol >= 0"],
  266. ["ObjectSet", [0, 1], "IntObject", "intCol == 0 || NOT (intCol == 3 && intCol >= 0) && intCol == 1"]
  267. ]
  268. },
  269. "keyPathTests" : {
  270. "schema" : [
  271. {
  272. "name": "BasicTypesObject",
  273. "properties": [
  274. { "name": "intCol", "type": "int" },
  275. { "name": "floatCol", "type": "float" },
  276. { "name": "doubleCol", "type": "double" },
  277. { "name": "stringCol", "type": "string" },
  278. { "name": "dateCol", "type": "date" },
  279. { "name": "dataCol", "type": "data" }
  280. ]
  281. },
  282. {
  283. "name": "LinkTypesObject",
  284. "primaryKey": "primaryKey",
  285. "properties": [
  286. { "name": "primaryKey", "type": "int" },
  287. { "name": "basicLink", "type": "object", "objectType": "BasicTypesObject" },
  288. { "name": "linkLink", "type": "object", "objectType": "LinkTypesObject" }
  289. ]
  290. }],
  291. "objects": [
  292. { "type": "LinkTypesObject", "value": [0, [1, 0.1, 0.001, "1", 1, [1, 10, 100]], null] },
  293. { "type": "LinkTypesObject", "value": [1, null, [2, [1, 0.1, 0.001, "1", 1, [1, 10, 100]], null]] },
  294. { "type": "LinkTypesObject", "value": [3, null, [4, [2, 0.2, 0.002, "2", 2, [2, 20, 200]], null]] }
  295. ],
  296. "tests": [
  297. ["ObjectSet", [0, 2], "LinkTypesObject", "basicLink.intCol == 1"],
  298. ["ObjectSet", [1], "LinkTypesObject", "linkLink.basicLink.intCol == 1"],
  299. ["ObjectSet", [1, 3], "LinkTypesObject", "linkLink.basicLink.intCol > 0"],
  300. ["ObjectSet", [0, 2], "LinkTypesObject", "basicLink.floatCol == 0.1"],
  301. ["ObjectSet", [1], "LinkTypesObject", "linkLink.basicLink.floatCol == 0.1"],
  302. ["ObjectSet", [1, 3], "LinkTypesObject", "linkLink.basicLink.floatCol > 0"]
  303. ]
  304. },
  305. "optionalTests" : {
  306. "schema" : [
  307. {
  308. "name": "OptionalTypesObject",
  309. "primaryKey": "primaryKey",
  310. "properties": [
  311. { "name": "primaryKey", "type": "int" },
  312. { "name": "intCol", "type": "int", "optional": true },
  313. { "name": "floatCol", "type": "float", "optional": true },
  314. { "name": "doubleCol", "type": "double", "optional": true },
  315. { "name": "stringCol", "type": "string", "optional": true },
  316. { "name": "dateCol", "type": "date", "optional": true },
  317. { "name": "dataCol", "type": "data", "optional": true }
  318. ]
  319. },
  320. {
  321. "name": "LinkTypesObject",
  322. "primaryKey": "primaryKey",
  323. "properties": [
  324. { "name": "primaryKey", "type": "int" },
  325. { "name": "basicLink", "type": "object", "objectType": "OptionalTypesObject" }
  326. ]
  327. }],
  328. "objects": [
  329. { "type": "LinkTypesObject", "value": [0, [0, 1, 0.1, 0.001, "1", 1, [1, 10, 100]]] },
  330. { "type": "LinkTypesObject", "value": [1, [1, null, null, null, null, null, null]] }
  331. ],
  332. "tests": [
  333. ["ObjectSet", [1], "OptionalTypesObject", "intCol == null"],
  334. ["ObjectSet", [1], "OptionalTypesObject", "null == intCol"],
  335. ["ObjectSet", [0], "OptionalTypesObject", "intCol != null"],
  336. ["ObjectSet", [1], "OptionalTypesObject", "floatCol == null"],
  337. ["ObjectSet", [0], "OptionalTypesObject", "floatCol != null"],
  338. ["ObjectSet", [1], "OptionalTypesObject", "doubleCol == null"],
  339. ["ObjectSet", [0], "OptionalTypesObject", "doubleCol != null"],
  340. ["ObjectSet", [1], "OptionalTypesObject", "stringCol == null"],
  341. ["ObjectSet", [0], "OptionalTypesObject", "stringCol != null"],
  342. ["ObjectSet", [1], "OptionalTypesObject", "dateCol == null"],
  343. ["ObjectSet", [0], "OptionalTypesObject", "dateCol != null"],
  344. ["ObjectSet", [1], "OptionalTypesObject", "dataCol == null"],
  345. ["ObjectSet", [0], "OptionalTypesObject", "dataCol != null"],
  346. ["ObjectSet", [1], "LinkTypesObject", "basicLink.intCol == null"],
  347. ["ObjectSet", [0], "LinkTypesObject", "basicLink.intCol != null"],
  348. ["ObjectSet", [1], "LinkTypesObject", "basicLink.floatCol == null"],
  349. ["ObjectSet", [0], "LinkTypesObject", "basicLink.floatCol != null"],
  350. ["ObjectSet", [1], "LinkTypesObject", "basicLink.doubleCol == null"],
  351. ["ObjectSet", [0], "LinkTypesObject", "basicLink.doubleCol != null"],
  352. ["ObjectSet", [1], "LinkTypesObject", "basicLink.stringCol == null"],
  353. ["ObjectSet", [0], "LinkTypesObject", "basicLink.stringCol != null"],
  354. ["ObjectSet", [1], "LinkTypesObject", "basicLink.dateCol == null"],
  355. ["ObjectSet", [0], "LinkTypesObject", "basicLink.dateCol != null"],
  356. ["QueryThrows", "LinkTypesObject", "basicLink.dataCol == null"]
  357. ]
  358. }
  359. }