View Code? Open in Web Editor
NEW
A Clojure(script) SQL library for building APIs: Datomic® (GraphQL-ish) pull syntax, data driven configuration, dynamic filtering with relations in mind
Home Page: https://walkable.gitlab.io/
License: Eclipse Public License 2.0
Clojure 99.35%
Shell 0.65%
walkable's Issues
Generated column names in WHERE should in the alias form (aka Clojuric form)
instead of
WHERE ` column` .` name` = 1
The SQL builder is written in plain Clojure data structure hence it should work in both Clojure and Clojurescript
instead of just call reverse against the associated join-seq
Current implementation only keep the last one. In case there is more than one condition, all of them should be kept
Currently operators must be one of =
, >
, <
etc. Users should be able to add their own operators, too
automatically attach reversed key to entities?
rename sql-pull to pull-entities
better unit testing
new helper functions: process-conditions and process-query
it assumes a primary keyword, which maybe not the case in the future
does not allow combination of conditions (AND, OR...)
it has different order from that of conditions, so developers may mistake the two
merging params from multiple queries
merging params from sub queries in SELECT statements
See
{:pre [(s/valid? (s/keys :req-un [::columns ::idents ]
Due to the use of flatten-multi-keys
later, also the following keys are basically mandatory for a schema:
joins
cardinality
extra-conditions
While the first two most likely always exist anyways in any non-trivial example, extra-conditions
might actually not be needed and the assert thrown later in flatten-multi-keys
is way more confusing than just making them req-un
for now?
how sql queries are built and when entities are assoc
ed into env
to support union queries
for ident type, it's the table
for joins, it's the target table
numbers and column names can be safely inlined into sql strings
So that batching can happen to sub queries as well
And don't forget the pseudo columns' params.
May get quite complicated if pseudo columns are used as params of another pseudo columns (recur case)
because join source column value will be nil
and results in invalid sql queries
this is only relevant to a join child:
SELECT foo .col AS ` foo/col` , foo .id AS ` foo/id` FROM foo WHERE foo .id = ?
1
vs
SELECT foo .col AS ` foo/col` , 1 AS ` foo/id` FROM foo WHERE foo .id = ?
1
along with :required-columns
.
May consider :required-parent-columns
, too
Pull extra data to an entity's keyword with custom sql queries
so checking if a keyword is of type ident
is fast
Some database eg sqlite won't work with table or column whose name is a reserved keyword. Generated SQL strings should contains:
instead of table.column
should have a key to provide that info
so conditions can describe relationship between a row's attributes
I'm trying to test walkable
on a fulcro
setup with postgres
database and it's generating a query syntax that is not supported by postgres. I dig thru the code and it looks likethe generation select queries with back tick. Or possible that I'm missing something here. Can you help? Thanks
in that case, should use the provided source table instead of infer from the condition keyword
and make use of compiled schema, instead of being sample code
when it's not clear which column should be the subject and others are objects of an operator
eg: for this SQL
(?, ?) OVERLAPS (?, ?)
` table_1` .` start_column` , ` table_1` .` end_column` , ` table_2` .` start_column` , ` table_2` .` end_column`
you can use the syntax
{:_ [:overlaps :table-1/start-column :table-1/end-column :table-2/start-column :table-2/end-column ]}
When none is specified. But may expose too much?
Both full keyword aliases like :table/name
→ :other-table/other-name
as well as table aliases like :table/*
→ :other-table/*
.
Should be implemented as a pathom plugin.
will refactor selection-with-aliases
, ->query-string
and query-string-input
add script to replace string to generate migration for postgresql and sqlite from mysql's
currently only current entity's columns are allowed in filters
There should be :join-filters
and :extra-join-filters
to provide constraints about join's properties.
{[(:person/all {:filters {:person/number [:> 0 ]}
:join-filters {:person/pets {:pet/yob [:> 1999 ]}}})]
[:person/name :person/yob ]}
SELECT ` person` .` name` AS ` person/name` , ` person` .` yob` AS ` person/yob`
FROM ` person`
WHERE
(` person` .` number` IN (SELECT ` person_pet` .` person_number`
FROM ` person_pet` JOIN ` pet` ON ` person_pet` .` pet_index` = ` pet` .` index`
WHERE ` pet` .` yob` > 1999 ))
AND
(` person` .` number` > 0 )
should make use of #22
Currently not operators are embedded into keywords: :not=
, :not-in
etc
Should support something like [:not [:or [:= 2] [:= 3]]]
.
Make use of join aliases so no name collisions
Clojure(scirpt) can't alias
a namespace without requiring it
To make walkable-sql compatible with fulcro-sql.
Should be implemented as a pathom plugin.