piccolo 1.5.2__tar.gz → 1.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. {piccolo-1.5.2 → piccolo-1.6.0}/PKG-INFO +1 -1
  2. piccolo-1.6.0/piccolo/__init__.py +1 -0
  3. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/base.py +31 -40
  4. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/column_types.py +11 -8
  5. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/m2m.py +16 -6
  6. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/readable.py +9 -7
  7. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/__init__.py +1 -4
  8. piccolo-1.6.0/piccolo/query/functions/__init__.py +16 -0
  9. piccolo-1.6.0/piccolo/query/functions/aggregate.py +179 -0
  10. piccolo-1.6.0/piccolo/query/functions/base.py +21 -0
  11. piccolo-1.6.0/piccolo/query/functions/string.py +73 -0
  12. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/__init__.py +18 -1
  13. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/count.py +3 -3
  14. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/delete.py +1 -1
  15. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/exists.py +1 -1
  16. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/objects.py +1 -1
  17. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/select.py +17 -232
  18. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/update.py +1 -1
  19. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/mixins.py +9 -2
  20. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/querystring.py +101 -13
  21. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/table.py +8 -24
  22. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/PKG-INFO +1 -1
  23. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/SOURCES.txt +5 -0
  24. piccolo-1.6.0/tests/query/test_functions.py +102 -0
  25. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_select.py +2 -9
  26. piccolo-1.5.2/piccolo/__init__.py +0 -1
  27. {piccolo-1.5.2 → piccolo-1.6.0}/LICENSE +0 -0
  28. {piccolo-1.5.2 → piccolo-1.6.0}/README.md +0 -0
  29. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/__init__.py +0 -0
  30. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/__init__.py +0 -0
  31. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/__init__.py +0 -0
  32. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/new.py +0 -0
  33. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/show_all.py +0 -0
  34. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/templates/piccolo_app.py.jinja +0 -0
  35. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/templates/tables.py.jinja +0 -0
  36. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/piccolo_app.py +0 -0
  37. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/__init__.py +0 -0
  38. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/__init__.py +0 -0
  39. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/new.py +0 -0
  40. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/README.md.jinja +0 -0
  41. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_blacksheep_app.py.jinja +0 -0
  42. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_esmerald_app.py.jinja +0 -0
  43. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_fastapi_app.py.jinja +0 -0
  44. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_lilya_app.py.jinja +0 -0
  45. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_litestar_app.py.jinja +0 -0
  46. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_starlette_app.py.jinja +0 -0
  47. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/app.py.jinja +0 -0
  48. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/conftest.py.jinja +0 -0
  49. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/__init__.py.jinja +0 -0
  50. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_blacksheep_endpoints.py.jinja +0 -0
  51. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_esmerald_endpoints.py.jinja +0 -0
  52. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_lilya_endpoints.py.jinja +0 -0
  53. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_litestar_endpoints.py.jinja +0 -0
  54. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_starlette_endpoints.py.jinja +0 -0
  55. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/endpoints.py.jinja +0 -0
  56. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_app.py.jinja +0 -0
  57. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_migrations/README.md +0 -0
  58. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/tables.py.jinja +0 -0
  59. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/templates/base.html.jinja_raw +0 -0
  60. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/templates/home.html.jinja_raw +0 -0
  61. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/main.py.jinja +0 -0
  62. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf.py.jinja +0 -0
  63. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf_test.py.jinja +0 -0
  64. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/requirements.txt.jinja +0 -0
  65. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/static/favicon.ico +0 -0
  66. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/static/main.css +0 -0
  67. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/piccolo_app.py +0 -0
  68. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/__init__.py +0 -0
  69. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/commands/__init__.py +0 -0
  70. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/commands/dump.py +0 -0
  71. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/commands/load.py +0 -0
  72. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/commands/shared.py +0 -0
  73. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/piccolo_app.py +0 -0
  74. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/meta/__init__.py +0 -0
  75. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/meta/commands/__init__.py +0 -0
  76. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/meta/commands/version.py +0 -0
  77. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/meta/piccolo_app.py +0 -0
  78. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/__init__.py +0 -0
  79. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/__init__.py +0 -0
  80. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/diffable_table.py +0 -0
  81. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/migration_manager.py +0 -0
  82. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/operations.py +0 -0
  83. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/schema_differ.py +0 -0
  84. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/schema_snapshot.py +0 -0
  85. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/serialisation.py +0 -0
  86. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/serialisation_legacy.py +0 -0
  87. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/__init__.py +0 -0
  88. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/backwards.py +0 -0
  89. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/base.py +0 -0
  90. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/check.py +0 -0
  91. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/clean.py +0 -0
  92. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/forwards.py +0 -0
  93. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/new.py +0 -0
  94. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/templates/migration.py.jinja +0 -0
  95. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/piccolo_app.py +0 -0
  96. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/tables.py +0 -0
  97. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/playground/__init__.py +0 -0
  98. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/playground/commands/__init__.py +0 -0
  99. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/playground/commands/run.py +0 -0
  100. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/playground/piccolo_app.py +0 -0
  101. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/__init__.py +0 -0
  102. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/commands/__init__.py +0 -0
  103. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/commands/new.py +0 -0
  104. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/commands/templates/piccolo_conf.py.jinja +0 -0
  105. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/piccolo_app.py +0 -0
  106. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/__init__.py +0 -0
  107. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/__init__.py +0 -0
  108. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/exceptions.py +0 -0
  109. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/generate.py +0 -0
  110. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/graph.py +0 -0
  111. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/templates/graphviz.dot.jinja +0 -0
  112. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/piccolo_app.py +0 -0
  113. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/shell/__init__.py +0 -0
  114. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/shell/commands/__init__.py +0 -0
  115. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/shell/commands/run.py +0 -0
  116. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/shell/piccolo_app.py +0 -0
  117. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/sql_shell/__init__.py +0 -0
  118. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/sql_shell/commands/__init__.py +0 -0
  119. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/sql_shell/commands/run.py +0 -0
  120. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/sql_shell/piccolo_app.py +0 -0
  121. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/tester/__init__.py +0 -0
  122. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/tester/commands/__init__.py +0 -0
  123. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/tester/commands/run.py +0 -0
  124. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/tester/piccolo_app.py +0 -0
  125. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/__init__.py +0 -0
  126. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/__init__.py +0 -0
  127. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/change_password.py +0 -0
  128. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/change_permissions.py +0 -0
  129. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/create.py +0 -0
  130. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/list.py +0 -0
  131. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_app.py +0 -0
  132. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_migrations/2019-11-14T21-52-21.py +0 -0
  133. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_migrations/2020-06-11T21-38-55.py +0 -0
  134. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_migrations/2021-04-30T16-14-15.py +0 -0
  135. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_migrations/__init__.py +0 -0
  136. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/tables.py +0 -0
  137. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/__init__.py +0 -0
  138. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/choices.py +0 -0
  139. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/combination.py +0 -0
  140. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/__init__.py +0 -0
  141. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/base.py +0 -0
  142. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/date.py +0 -0
  143. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/interval.py +0 -0
  144. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/time.py +0 -0
  145. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/timestamp.py +0 -0
  146. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/timestamptz.py +0 -0
  147. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/uuid.py +0 -0
  148. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/indexes.py +0 -0
  149. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/__init__.py +0 -0
  150. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/base.py +0 -0
  151. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/comparison.py +0 -0
  152. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/math.py +0 -0
  153. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/string.py +0 -0
  154. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/reference.py +0 -0
  155. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/conf/__init__.py +0 -0
  156. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/conf/apps.py +0 -0
  157. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/custom_types.py +0 -0
  158. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/__init__.py +0 -0
  159. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/base.py +0 -0
  160. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/cockroach.py +0 -0
  161. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/exceptions.py +0 -0
  162. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/finder.py +0 -0
  163. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/postgres.py +0 -0
  164. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/sqlite.py +0 -0
  165. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/main.py +0 -0
  166. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/py.typed +0 -0
  167. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/base.py +0 -0
  168. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/alter.py +0 -0
  169. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/create.py +0 -0
  170. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/create_index.py +0 -0
  171. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/drop_index.py +0 -0
  172. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/indexes.py +0 -0
  173. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/insert.py +0 -0
  174. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/raw.py +0 -0
  175. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/refresh.py +0 -0
  176. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/table_exists.py +0 -0
  177. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/proxy.py +0 -0
  178. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/schema.py +0 -0
  179. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/table_reflection.py +0 -0
  180. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/testing/__init__.py +0 -0
  181. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/testing/model_builder.py +0 -0
  182. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/testing/random_builder.py +0 -0
  183. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/__init__.py +0 -0
  184. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/dictionary.py +0 -0
  185. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/encoding.py +0 -0
  186. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/graphlib/__init__.py +0 -0
  187. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/graphlib/_graphlib.py +0 -0
  188. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/lazy_loader.py +0 -0
  189. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/list.py +0 -0
  190. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/naming.py +0 -0
  191. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/objects.py +0 -0
  192. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/printing.py +0 -0
  193. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/pydantic.py +0 -0
  194. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/repr.py +0 -0
  195. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/sql_values.py +0 -0
  196. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/sync.py +0 -0
  197. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/warnings.py +0 -0
  198. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/dependency_links.txt +0 -0
  199. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/entry_points.txt +0 -0
  200. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/requires.txt +0 -0
  201. {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/top_level.txt +0 -0
  202. {piccolo-1.5.2 → piccolo-1.6.0}/profiling/__init__.py +0 -0
  203. {piccolo-1.5.2 → piccolo-1.6.0}/profiling/run_profile.py +0 -0
  204. {piccolo-1.5.2 → piccolo-1.6.0}/pyproject.toml +0 -0
  205. {piccolo-1.5.2 → piccolo-1.6.0}/setup.cfg +0 -0
  206. {piccolo-1.5.2 → piccolo-1.6.0}/setup.py +0 -0
  207. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/__init__.py +0 -0
  208. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/app/__init__.py +0 -0
  209. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/app/commands/__init__.py +0 -0
  210. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/app/commands/test_new.py +0 -0
  211. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/app/commands/test_show_all.py +0 -0
  212. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/asgi/__init__.py +0 -0
  213. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/asgi/commands/__init__.py +0 -0
  214. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/asgi/commands/test_new.py +0 -0
  215. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/fixtures/__init__.py +0 -0
  216. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/fixtures/commands/__init__.py +0 -0
  217. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/fixtures/commands/test_dump_load.py +0 -0
  218. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/fixtures/commands/test_shared.py +0 -0
  219. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/meta/__init__.py +0 -0
  220. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/meta/commands/__init__.py +0 -0
  221. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/meta/commands/test_version.py +0 -0
  222. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/__init__.py +0 -0
  223. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/__init__.py +0 -0
  224. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/integration/__init__.py +0 -0
  225. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/integration/test_migrations.py +0 -0
  226. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_diffable_table.py +0 -0
  227. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_migration_manager.py +0 -0
  228. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_schema_differ.py +0 -0
  229. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_schema_snapshot.py +0 -0
  230. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_serialisation.py +0 -0
  231. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/__init__.py +0 -0
  232. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_base.py +0 -0
  233. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_check.py +0 -0
  234. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_clean.py +0 -0
  235. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_forwards_backwards.py +0 -0
  236. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_migrations/2020-03-31T20-38-22.py +0 -0
  237. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_migrations/__init__.py +0 -0
  238. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_new.py +0 -0
  239. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/test_migration.py +0 -0
  240. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/project/__init__.py +0 -0
  241. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/project/commands/__init__.py +0 -0
  242. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/project/commands/test_new.py +0 -0
  243. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/schema/__init__.py +0 -0
  244. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/shell/__init__.py +0 -0
  245. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/shell/commands/__init__.py +0 -0
  246. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/shell/commands/test_run.py +0 -0
  247. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/sql_shell/__init__.py +0 -0
  248. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/sql_shell/commands/__init__.py +0 -0
  249. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/sql_shell/commands/test_run.py +0 -0
  250. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/tester/__init__.py +0 -0
  251. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/__init__.py +0 -0
  252. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/__init__.py +0 -0
  253. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/test_change_password.py +0 -0
  254. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/test_change_permissions.py +0 -0
  255. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/test_create.py +0 -0
  256. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/test_list.py +0 -0
  257. {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/test_tables.py +0 -0
  258. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/__init__.py +0 -0
  259. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/m2m/__init__.py +0 -0
  260. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/m2m/base.py +0 -0
  261. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/m2m/test_m2m.py +0 -0
  262. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/m2m/test_m2m_schema.py +0 -0
  263. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_array.py +0 -0
  264. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_base.py +0 -0
  265. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_bigint.py +0 -0
  266. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_boolean.py +0 -0
  267. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_bytea.py +0 -0
  268. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_choices.py +0 -0
  269. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_combination.py +0 -0
  270. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_date.py +0 -0
  271. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_db_column_name.py +0 -0
  272. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_defaults.py +0 -0
  273. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_double_precision.py +0 -0
  274. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_interval.py +0 -0
  275. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_json.py +0 -0
  276. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_jsonb.py +0 -0
  277. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_numeric.py +0 -0
  278. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_primary_key.py +0 -0
  279. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_readable.py +0 -0
  280. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_real.py +0 -0
  281. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_reference.py +0 -0
  282. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_reserved_column_names.py +0 -0
  283. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_smallint.py +0 -0
  284. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_time.py +0 -0
  285. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_timestamp.py +0 -0
  286. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_timestamptz.py +0 -0
  287. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_uuid.py +0 -0
  288. {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_varchar.py +0 -0
  289. {piccolo-1.5.2 → piccolo-1.6.0}/tests/conf/__init__.py +0 -0
  290. {piccolo-1.5.2 → piccolo-1.6.0}/tests/conf/example.py +0 -0
  291. {piccolo-1.5.2 → piccolo-1.6.0}/tests/conf/test_apps.py +0 -0
  292. {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/__init__.py +0 -0
  293. {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_extra_nodes.py +0 -0
  294. {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_logging.py +0 -0
  295. {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_nested_transaction.py +0 -0
  296. {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_pool.py +0 -0
  297. {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_transaction.py +0 -0
  298. {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_version_parsing.py +0 -0
  299. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/__init__.py +0 -0
  300. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/__init__.py +0 -0
  301. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/piccolo_app.py +0 -0
  302. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/piccolo_migrations/2021-09-20T21-23-25-698988.py +0 -0
  303. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/piccolo_migrations/__init__.py +0 -0
  304. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/tables.py +0 -0
  305. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/music/__init__.py +0 -0
  306. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/music/piccolo_app.py +0 -0
  307. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/music/tables.py +0 -0
  308. {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/music/tables_detailed.py +0 -0
  309. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/__init__.py +0 -0
  310. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/mixins/__init__.py +0 -0
  311. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/mixins/test_columns_delegate.py +0 -0
  312. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/mixins/test_order_by_delegate.py +0 -0
  313. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_await.py +0 -0
  314. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_camelcase.py +0 -0
  315. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_freeze.py +0 -0
  316. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_gather.py +0 -0
  317. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_querystring.py +0 -0
  318. {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_slots.py +0 -0
  319. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/__init__.py +0 -0
  320. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/__init__.py +0 -0
  321. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_create.py +0 -0
  322. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_get_related.py +0 -0
  323. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_get_related_readable.py +0 -0
  324. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_instantiate.py +0 -0
  325. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_remove.py +0 -0
  326. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_save.py +0 -0
  327. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_to_dict.py +0 -0
  328. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_all_columns.py +0 -0
  329. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_alter.py +0 -0
  330. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_batch.py +0 -0
  331. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_callback.py +0 -0
  332. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_constructor.py +0 -0
  333. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_count.py +0 -0
  334. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_create.py +0 -0
  335. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_create_db_tables.py +0 -0
  336. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_create_table_class.py +0 -0
  337. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_delete.py +0 -0
  338. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_drop_db_tables.py +0 -0
  339. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_exists.py +0 -0
  340. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_from_dict.py +0 -0
  341. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_indexes.py +0 -0
  342. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_inheritance.py +0 -0
  343. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_insert.py +0 -0
  344. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_join.py +0 -0
  345. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_join_on.py +0 -0
  346. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_metaclass.py +0 -0
  347. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_objects.py +0 -0
  348. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_output.py +0 -0
  349. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_raw.py +0 -0
  350. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_ref.py +0 -0
  351. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_refresh.py +0 -0
  352. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_repr.py +0 -0
  353. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_str.py +0 -0
  354. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_table_exists.py +0 -0
  355. {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_update.py +0 -0
  356. {piccolo-1.5.2 → piccolo-1.6.0}/tests/test_main.py +0 -0
  357. {piccolo-1.5.2 → piccolo-1.6.0}/tests/test_schema.py +0 -0
  358. {piccolo-1.5.2 → piccolo-1.6.0}/tests/testing/__init__.py +0 -0
  359. {piccolo-1.5.2 → piccolo-1.6.0}/tests/testing/test_model_builder.py +0 -0
  360. {piccolo-1.5.2 → piccolo-1.6.0}/tests/testing/test_random_builder.py +0 -0
  361. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/__init__.py +0 -0
  362. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_dictionary.py +0 -0
  363. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_encoding.py +0 -0
  364. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_lazy_loader.py +0 -0
  365. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_list.py +0 -0
  366. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_naming.py +0 -0
  367. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_printing.py +0 -0
  368. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_pydantic.py +0 -0
  369. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_sql_values.py +0 -0
  370. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_sync.py +0 -0
  371. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_table_reflection.py +0 -0
  372. {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_warnings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: piccolo
3
- Version: 1.5.2
3
+ Version: 1.6.0
4
4
  Summary: A fast, user friendly ORM and query builder which supports asyncio.
5
5
  Home-page: https://github.com/piccolo-orm/piccolo
6
6
  Author: Daniel Townsend
@@ -0,0 +1 @@
1
+ __VERSION__ = "1.6.0"
@@ -6,7 +6,6 @@ import decimal
6
6
  import inspect
7
7
  import typing as t
8
8
  import uuid
9
- from abc import ABCMeta, abstractmethod
10
9
  from dataclasses import dataclass, field, fields
11
10
  from enum import Enum
12
11
 
@@ -32,6 +31,7 @@ from piccolo.columns.operators.comparison import (
32
31
  NotLike,
33
32
  )
34
33
  from piccolo.columns.reference import LazyTableReference
34
+ from piccolo.querystring import QueryString, Selectable
35
35
  from piccolo.utils.warnings import colored_warning
36
36
 
37
37
  if t.TYPE_CHECKING: # pragma: no cover
@@ -205,7 +205,6 @@ class ColumnMeta:
205
205
 
206
206
  # Used by Foreign Keys:
207
207
  call_chain: t.List["ForeignKey"] = field(default_factory=list)
208
- table_alias: t.Optional[str] = None
209
208
 
210
209
  ###########################################################################
211
210
 
@@ -260,7 +259,7 @@ class ColumnMeta:
260
259
  column_name = self.db_column_name
261
260
 
262
261
  if self.call_chain:
263
- table_alias = self.call_chain[-1]._meta.table_alias
262
+ table_alias = self.call_chain[-1].table_alias
264
263
  if include_quotes:
265
264
  return f'"{table_alias}"."{column_name}"'
266
265
  else:
@@ -272,7 +271,9 @@ class ColumnMeta:
272
271
  return f"{self.table._meta.tablename}.{column_name}"
273
272
 
274
273
  def get_full_name(
275
- self, with_alias: bool = True, include_quotes: bool = True
274
+ self,
275
+ with_alias: bool = True,
276
+ include_quotes: bool = True,
276
277
  ) -> str:
277
278
  """
278
279
  Returns the full column name, taking into account joins.
@@ -302,11 +303,10 @@ class ColumnMeta:
302
303
  >>> column._meta.get_full_name(include_quotes=False)
303
304
  'my_table_name.my_column_name'
304
305
 
305
-
306
306
  """
307
307
  full_name = self._get_path(include_quotes=include_quotes)
308
308
 
309
- if with_alias and self.call_chain:
309
+ if with_alias:
310
310
  alias = self.get_default_alias()
311
311
  if include_quotes:
312
312
  full_name += f' AS "{alias}"'
@@ -346,32 +346,6 @@ class ColumnMeta:
346
346
  return self.copy()
347
347
 
348
348
 
349
- class Selectable(metaclass=ABCMeta):
350
- """
351
- Anything which inherits from this can be used in a select query.
352
- """
353
-
354
- _alias: t.Optional[str]
355
-
356
- @abstractmethod
357
- def get_select_string(
358
- self, engine_type: str, with_alias: bool = True
359
- ) -> str:
360
- """
361
- In a query, what to output after the select statement - could be a
362
- column name, a sub query, a function etc. For a column it will be the
363
- column name.
364
- """
365
- raise NotImplementedError()
366
-
367
- def as_alias(self, alias: str) -> Selectable:
368
- """
369
- Allows column names to be changed in the result of a select.
370
- """
371
- self._alias = alias
372
- return self
373
-
374
-
375
349
  class Column(Selectable):
376
350
  """
377
351
  All other columns inherit from ``Column``. Don't use it directly.
@@ -822,25 +796,32 @@ class Column(Selectable):
822
796
 
823
797
  def get_select_string(
824
798
  self, engine_type: str, with_alias: bool = True
825
- ) -> str:
799
+ ) -> QueryString:
826
800
  """
827
801
  How to refer to this column in a SQL query, taking account of any joins
828
802
  and aliases.
829
803
  """
804
+
830
805
  if with_alias:
831
806
  if self._alias:
832
807
  original_name = self._meta.get_full_name(
833
808
  with_alias=False,
834
809
  )
835
- return f'{original_name} AS "{self._alias}"'
810
+ return QueryString(f'{original_name} AS "{self._alias}"')
836
811
  else:
837
- return self._meta.get_full_name(
838
- with_alias=True,
812
+ return QueryString(
813
+ self._meta.get_full_name(
814
+ with_alias=True,
815
+ )
839
816
  )
840
817
 
841
- return self._meta.get_full_name(with_alias=False)
818
+ return QueryString(
819
+ self._meta.get_full_name(
820
+ with_alias=False,
821
+ )
822
+ )
842
823
 
843
- def get_where_string(self, engine_type: str) -> str:
824
+ def get_where_string(self, engine_type: str) -> QueryString:
844
825
  return self.get_select_string(
845
826
  engine_type=engine_type, with_alias=False
846
827
  )
@@ -902,6 +883,13 @@ class Column(Selectable):
902
883
  def column_type(self):
903
884
  return self.__class__.__name__.upper()
904
885
 
886
+ @property
887
+ def table_alias(self) -> str:
888
+ return "$".join(
889
+ f"{_key._meta.table._meta.tablename}${_key._meta.name}"
890
+ for _key in [*self._meta.call_chain, self]
891
+ )
892
+
905
893
  @property
906
894
  def ddl(self) -> str:
907
895
  """
@@ -945,8 +933,8 @@ class Column(Selectable):
945
933
 
946
934
  return query
947
935
 
948
- def copy(self) -> Column:
949
- column: Column = copy.copy(self)
936
+ def copy(self: Self) -> Self:
937
+ column = copy.copy(self)
950
938
  column._meta = self._meta.copy()
951
939
  return column
952
940
 
@@ -971,3 +959,6 @@ class Column(Selectable):
971
959
  f"{table_class_name}.{self._meta.name} - "
972
960
  f"{self.__class__.__name__}"
973
961
  )
962
+
963
+
964
+ Self = t.TypeVar("Self", bound=Column)
@@ -60,7 +60,7 @@ from piccolo.columns.defaults.uuid import UUID4, UUIDArg
60
60
  from piccolo.columns.operators.comparison import ArrayAll, ArrayAny
61
61
  from piccolo.columns.operators.string import Concat
62
62
  from piccolo.columns.reference import LazyTableReference
63
- from piccolo.querystring import QueryString, Unquoted
63
+ from piccolo.querystring import QueryString
64
64
  from piccolo.utils.encoding import dump_json
65
65
  from piccolo.utils.warnings import colored_warning
66
66
 
@@ -752,8 +752,8 @@ class SmallInt(Integer):
752
752
  ###############################################################################
753
753
 
754
754
 
755
- DEFAULT = Unquoted("DEFAULT")
756
- NULL = Unquoted("null")
755
+ DEFAULT = QueryString("DEFAULT")
756
+ NULL = QueryString("null")
757
757
 
758
758
 
759
759
  class Serial(Column):
@@ -778,7 +778,7 @@ class Serial(Column):
778
778
  if engine_type == "postgres":
779
779
  return DEFAULT
780
780
  elif engine_type == "cockroach":
781
- return Unquoted("unique_rowid()")
781
+ return QueryString("unique_rowid()")
782
782
  elif engine_type == "sqlite":
783
783
  return NULL
784
784
  raise Exception("Unrecognized engine type")
@@ -2194,6 +2194,7 @@ class ForeignKey(Column, t.Generic[ReferencedTable]):
2194
2194
  column_meta: ColumnMeta = object.__getattribute__(self, "_meta")
2195
2195
 
2196
2196
  new_column._meta.call_chain = column_meta.call_chain.copy()
2197
+
2197
2198
  new_column._meta.call_chain.append(self)
2198
2199
  return new_column
2199
2200
  else:
@@ -2311,7 +2312,7 @@ class JSONB(JSON):
2311
2312
 
2312
2313
  def get_select_string(
2313
2314
  self, engine_type: str, with_alias: bool = True
2314
- ) -> str:
2315
+ ) -> QueryString:
2315
2316
  select_string = self._meta.get_full_name(with_alias=False)
2316
2317
 
2317
2318
  if self.json_operator is not None:
@@ -2321,7 +2322,7 @@ class JSONB(JSON):
2321
2322
  alias = self._alias or self._meta.get_default_alias()
2322
2323
  select_string += f' AS "{alias}"'
2323
2324
 
2324
- return select_string
2325
+ return QueryString(select_string)
2325
2326
 
2326
2327
  def eq(self, value) -> Where:
2327
2328
  """
@@ -2616,7 +2617,9 @@ class Array(Column):
2616
2617
  else:
2617
2618
  raise ValueError("Only integers can be used for indexing.")
2618
2619
 
2619
- def get_select_string(self, engine_type: str, with_alias=True) -> str:
2620
+ def get_select_string(
2621
+ self, engine_type: str, with_alias=True
2622
+ ) -> QueryString:
2620
2623
  select_string = self._meta.get_full_name(with_alias=False)
2621
2624
 
2622
2625
  if isinstance(self.index, int):
@@ -2626,7 +2629,7 @@ class Array(Column):
2626
2629
  alias = self._alias or self._meta.get_default_alias()
2627
2630
  select_string += f' AS "{alias}"'
2628
2631
 
2629
- return select_string
2632
+ return QueryString(select_string)
2630
2633
 
2631
2634
  def any(self, value: t.Any) -> Where:
2632
2635
  """
@@ -4,7 +4,6 @@ import inspect
4
4
  import typing as t
5
5
  from dataclasses import dataclass
6
6
 
7
- from piccolo.columns.base import Selectable
8
7
  from piccolo.columns.column_types import (
9
8
  JSON,
10
9
  JSONB,
@@ -12,6 +11,7 @@ from piccolo.columns.column_types import (
12
11
  ForeignKey,
13
12
  LazyTableReference,
14
13
  )
14
+ from piccolo.querystring import QueryString, Selectable
15
15
  from piccolo.utils.list import flatten
16
16
  from piccolo.utils.sync import run_sync
17
17
 
@@ -56,7 +56,9 @@ class M2MSelect(Selectable):
56
56
  for column in columns
57
57
  )
58
58
 
59
- def get_select_string(self, engine_type: str, with_alias=True) -> str:
59
+ def get_select_string(
60
+ self, engine_type: str, with_alias=True
61
+ ) -> QueryString:
60
62
  m2m_table_name_with_schema = (
61
63
  self.m2m._meta.resolved_joining_table._meta.get_formatted_tablename() # noqa: E501
62
64
  ) # noqa: E501
@@ -90,28 +92,33 @@ class M2MSelect(Selectable):
90
92
  if engine_type in ("postgres", "cockroach"):
91
93
  if self.as_list:
92
94
  column_name = self.columns[0]._meta.db_column_name
93
- return f"""
95
+ return QueryString(
96
+ f"""
94
97
  ARRAY(
95
98
  SELECT
96
99
  "inner_{table_2_name}"."{column_name}"
97
100
  FROM {inner_select}
98
101
  ) AS "{m2m_relationship_name}"
99
102
  """
103
+ )
100
104
  elif not self.serialisation_safe:
101
105
  column_name = table_2_pk_name
102
- return f"""
106
+ return QueryString(
107
+ f"""
103
108
  ARRAY(
104
109
  SELECT
105
110
  "inner_{table_2_name}"."{column_name}"
106
111
  FROM {inner_select}
107
112
  ) AS "{m2m_relationship_name}"
108
113
  """
114
+ )
109
115
  else:
110
116
  column_names = ", ".join(
111
117
  f'"inner_{table_2_name}"."{column._meta.db_column_name}"'
112
118
  for column in self.columns
113
119
  )
114
- return f"""
120
+ return QueryString(
121
+ f"""
115
122
  (
116
123
  SELECT JSON_AGG({m2m_relationship_name}_results)
117
124
  FROM (
@@ -119,13 +126,15 @@ class M2MSelect(Selectable):
119
126
  ) AS "{m2m_relationship_name}_results"
120
127
  ) AS "{m2m_relationship_name}"
121
128
  """
129
+ )
122
130
  elif engine_type == "sqlite":
123
131
  if len(self.columns) > 1 or not self.serialisation_safe:
124
132
  column_name = table_2_pk_name
125
133
  else:
126
134
  column_name = self.columns[0]._meta.db_column_name
127
135
 
128
- return f"""
136
+ return QueryString(
137
+ f"""
129
138
  (
130
139
  SELECT group_concat(
131
140
  "inner_{table_2_name}"."{column_name}"
@@ -134,6 +143,7 @@ class M2MSelect(Selectable):
134
143
  )
135
144
  AS "{m2m_relationship_name} [M2M]"
136
145
  """
146
+ )
137
147
  else:
138
148
  raise ValueError(f"{engine_type} is an unrecognised engine type")
139
149
 
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import typing as t
4
4
  from dataclasses import dataclass
5
5
 
6
- from piccolo.columns.base import Selectable
6
+ from piccolo.querystring import QueryString, Selectable
7
7
 
8
8
  if t.TYPE_CHECKING: # pragma: no cover
9
9
  from piccolo.columns.base import Column
@@ -27,25 +27,27 @@ class Readable(Selectable):
27
27
  i._meta.get_full_name(with_alias=False) for i in self.columns
28
28
  )
29
29
 
30
- def _get_string(self, operator: str) -> str:
31
- return (
30
+ def _get_string(self, operator: str) -> QueryString:
31
+ return QueryString(
32
32
  f"{operator}('{self.template}', {self._columns_string}) AS "
33
33
  f"{self.output_name}"
34
34
  )
35
35
 
36
36
  @property
37
- def sqlite_string(self) -> str:
37
+ def sqlite_string(self) -> QueryString:
38
38
  return self._get_string(operator="PRINTF")
39
39
 
40
40
  @property
41
- def postgres_string(self) -> str:
41
+ def postgres_string(self) -> QueryString:
42
42
  return self._get_string(operator="FORMAT")
43
43
 
44
44
  @property
45
- def cockroach_string(self) -> str:
45
+ def cockroach_string(self) -> QueryString:
46
46
  return self._get_string(operator="FORMAT")
47
47
 
48
- def get_select_string(self, engine_type: str, with_alias=True) -> str:
48
+ def get_select_string(
49
+ self, engine_type: str, with_alias=True
50
+ ) -> QueryString:
49
51
  try:
50
52
  return getattr(self, f"{engine_type}_string")
51
53
  except AttributeError as e:
@@ -1,9 +1,9 @@
1
1
  from piccolo.columns.combination import WhereRaw
2
2
 
3
3
  from .base import Query
4
+ from .functions.aggregate import Avg, Max, Min, Sum
4
5
  from .methods import (
5
6
  Alter,
6
- Avg,
7
7
  Count,
8
8
  Create,
9
9
  CreateIndex,
@@ -11,12 +11,9 @@ from .methods import (
11
11
  DropIndex,
12
12
  Exists,
13
13
  Insert,
14
- Max,
15
- Min,
16
14
  Objects,
17
15
  Raw,
18
16
  Select,
19
- Sum,
20
17
  TableExists,
21
18
  Update,
22
19
  )
@@ -0,0 +1,16 @@
1
+ from .aggregate import Avg, Count, Max, Min, Sum
2
+ from .string import Length, Lower, Ltrim, Reverse, Rtrim, Upper
3
+
4
+ __all__ = (
5
+ "Avg",
6
+ "Count",
7
+ "Length",
8
+ "Lower",
9
+ "Ltrim",
10
+ "Max",
11
+ "Min",
12
+ "Reverse",
13
+ "Rtrim",
14
+ "Sum",
15
+ "Upper",
16
+ )
@@ -0,0 +1,179 @@
1
+ import typing as t
2
+
3
+ from piccolo.columns.base import Column
4
+ from piccolo.querystring import QueryString
5
+
6
+ from .base import Function
7
+
8
+
9
+ class Avg(Function):
10
+ """
11
+ ``AVG()`` SQL function. Column type must be numeric to run the query.
12
+
13
+ .. code-block:: python
14
+
15
+ await Band.select(Avg(Band.popularity)).run()
16
+
17
+ # We can use an alias. These two are equivalent:
18
+
19
+ await Band.select(
20
+ Avg(Band.popularity, alias="popularity_avg")
21
+ ).run()
22
+
23
+ await Band.select(
24
+ Avg(Band.popularity).as_alias("popularity_avg")
25
+ ).run()
26
+
27
+ """
28
+
29
+ function_name = "AVG"
30
+
31
+
32
+ class Count(QueryString):
33
+ """
34
+ Used in ``Select`` queries, usually in conjunction with the ``group_by``
35
+ clause::
36
+
37
+ >>> await Band.select(
38
+ ... Band.manager.name.as_alias('manager_name'),
39
+ ... Count(alias='band_count')
40
+ ... ).group_by(Band.manager)
41
+ [{'manager_name': 'Guido', 'count': 1}, ...]
42
+
43
+ It can also be used without the ``group_by`` clause (though you may prefer
44
+ to the :meth:`Table.count <piccolo.table.Table.count>` method instead, as
45
+ it's more convenient)::
46
+
47
+ >>> await Band.select(Count())
48
+ [{'count': 3}]
49
+
50
+ """
51
+
52
+ def __init__(
53
+ self,
54
+ column: t.Optional[Column] = None,
55
+ distinct: t.Optional[t.Sequence[Column]] = None,
56
+ alias: str = "count",
57
+ ):
58
+ """
59
+ :param column:
60
+ If specified, the count is for non-null values in that column.
61
+ :param distinct:
62
+ If specified, the count is for distinct values in those columns.
63
+ :param alias:
64
+ The name of the value in the response::
65
+
66
+ # These two are equivalent:
67
+
68
+ await Band.select(
69
+ Band.name, Count(alias="total")
70
+ ).group_by(Band.name)
71
+
72
+ await Band.select(
73
+ Band.name,
74
+ Count().as_alias("total")
75
+ ).group_by(Band.name)
76
+
77
+ """
78
+ if distinct and column:
79
+ raise ValueError("Only specify `column` or `distinct`")
80
+
81
+ if distinct:
82
+ engine_type = distinct[0]._meta.engine_type
83
+ if engine_type == "sqlite":
84
+ # SQLite doesn't allow us to specify multiple columns, so
85
+ # instead we concatenate the values.
86
+ column_names = " || ".join("{}" for _ in distinct)
87
+ else:
88
+ column_names = ", ".join("{}" for _ in distinct)
89
+
90
+ return super().__init__(
91
+ f"COUNT(DISTINCT({column_names}))", *distinct, alias=alias
92
+ )
93
+ else:
94
+ if column:
95
+ return super().__init__("COUNT({})", column, alias=alias)
96
+ else:
97
+ return super().__init__("COUNT(*)", alias=alias)
98
+
99
+
100
+ class Min(Function):
101
+ """
102
+ ``MIN()`` SQL function.
103
+
104
+ .. code-block:: python
105
+
106
+ await Band.select(Min(Band.popularity)).run()
107
+
108
+ # We can use an alias. These two are equivalent:
109
+
110
+ await Band.select(
111
+ Min(Band.popularity, alias="popularity_min")
112
+ ).run()
113
+
114
+ await Band.select(
115
+ Min(Band.popularity).as_alias("popularity_min")
116
+ ).run()
117
+
118
+ """
119
+
120
+ function_name = "MIN"
121
+
122
+
123
+ class Max(Function):
124
+ """
125
+ ``MAX()`` SQL function.
126
+
127
+ .. code-block:: python
128
+
129
+ await Band.select(
130
+ Max(Band.popularity)
131
+ ).run()
132
+
133
+ # We can use an alias. These two are equivalent:
134
+
135
+ await Band.select(
136
+ Max(Band.popularity, alias="popularity_max")
137
+ ).run()
138
+
139
+ await Band.select(
140
+ Max(Band.popularity).as_alias("popularity_max")
141
+ ).run()
142
+
143
+ """
144
+
145
+ function_name = "MAX"
146
+
147
+
148
+ class Sum(Function):
149
+ """
150
+ ``SUM()`` SQL function. Column type must be numeric to run the query.
151
+
152
+ .. code-block:: python
153
+
154
+ await Band.select(
155
+ Sum(Band.popularity)
156
+ ).run()
157
+
158
+ # We can use an alias. These two are equivalent:
159
+
160
+ await Band.select(
161
+ Sum(Band.popularity, alias="popularity_sum")
162
+ ).run()
163
+
164
+ await Band.select(
165
+ Sum(Band.popularity).as_alias("popularity_sum")
166
+ ).run()
167
+
168
+ """
169
+
170
+ function_name = "SUM"
171
+
172
+
173
+ __all__ = (
174
+ "Avg",
175
+ "Count",
176
+ "Min",
177
+ "Max",
178
+ "Sum",
179
+ )
@@ -0,0 +1,21 @@
1
+ import typing as t
2
+
3
+ from piccolo.columns.base import Column
4
+ from piccolo.querystring import QueryString
5
+
6
+
7
+ class Function(QueryString):
8
+ function_name: str
9
+
10
+ def __init__(
11
+ self,
12
+ identifier: t.Union[Column, QueryString, str],
13
+ alias: t.Optional[str] = None,
14
+ ):
15
+ alias = alias or self.__class__.__name__.lower()
16
+
17
+ super().__init__(
18
+ f"{self.function_name}({{}})",
19
+ identifier,
20
+ alias=alias,
21
+ )
@@ -0,0 +1,73 @@
1
+ """
2
+ These functions mirror their counterparts in the Postgresql docs:
3
+
4
+ https://www.postgresql.org/docs/current/functions-string.html
5
+
6
+ """
7
+
8
+ from .base import Function
9
+
10
+
11
+ class Length(Function):
12
+ """
13
+ Returns the number of characters in the string.
14
+ """
15
+
16
+ function_name = "LENGTH"
17
+
18
+
19
+ class Lower(Function):
20
+ """
21
+ Converts the string to all lower case, according to the rules of the
22
+ database's locale.
23
+ """
24
+
25
+ function_name = "LOWER"
26
+
27
+
28
+ class Ltrim(Function):
29
+ """
30
+ Removes the longest string containing only characters in characters (a
31
+ space by default) from the start of string.
32
+ """
33
+
34
+ function_name = "LTRIM"
35
+
36
+
37
+ class Reverse(Function):
38
+ """
39
+ Return reversed string.
40
+
41
+ Not supported in SQLite.
42
+
43
+ """
44
+
45
+ function_name = "REVERSE"
46
+
47
+
48
+ class Rtrim(Function):
49
+ """
50
+ Removes the longest string containing only characters in characters (a
51
+ space by default) from the end of string.
52
+ """
53
+
54
+ function_name = "RTRIM"
55
+
56
+
57
+ class Upper(Function):
58
+ """
59
+ Converts the string to all upper case, according to the rules of the
60
+ database's locale.
61
+ """
62
+
63
+ function_name = "UPPER"
64
+
65
+
66
+ __all__ = (
67
+ "Length",
68
+ "Lower",
69
+ "Ltrim",
70
+ "Reverse",
71
+ "Rtrim",
72
+ "Upper",
73
+ )