Comments (6)
+1 , 2 years and still valuable :)
from honeysql.
+1 to this. This would be nice to include in the big example in the README.
from honeysql.
For what it's worth, I'm going to play devil's advocate here. They (sub-queries and aliasing,) don't really behave any differently separate than when you put them together. It just writes strangely which is why when I do this, I'm working with the map directly instead of using helper functions because it's not unrealistic that you'll want to re-use or alter certain stanzas.
I see the example above and would be tempted to write it without the helpers:
(sql/format {:select [:%count.*] :from [[{:select [:*] :from [:client]} :foo]]})
Personally, the only thing that looks weird is the sub-query itself, so you could just pull it apart and it looks normal again.
(def sub-query {:select [:*] :from [:client]})
(def full-query {:select [:%count.*] :from [[sub-query :foo]]})
(sql/format full-query)
For what it is worth, there are sub-query examples and aliasing examples. Is it really not obvious that the two can be put together and still work?
from honeysql.
@jrdoane I'm looking over the README and don't see examples of either. Where are you seeing examples of these? (figuring out where best to add more examples)
from honeysql.
I've just added an example of aliasing to the README. There are two examples of nested selects but neither lend themselves to adding aliasing. PRs welcome to improve the README in this area!
from honeysql.
Closing this in the absence of a PR or further feedback. FWIW, I agree with @jrdoane that these things don't behave any differently together than they do separately: (-> ... (from [sql-expression the-alias]) ...)
so I'm not sure what could be clearer in the README (but I'll certainly accept PRs for improvements -- just bear in mind that the README can't include every combination of features in the library because that would be huge!).
from honeysql.
Related Issues (20)
- Formatting unhashable objects HOT 1
- Add NRQL dialect support HOT 2
- CREATE OR REPLACE syntax
- BigQuery ARRAY subquery HOT 3
- Ignore additional metadata?
- Default quoting needs to be smarter HOT 8
- `:union` and similar ops should format their arguments wrapped in parentheses HOT 5
- Temporal: alias in wrong place
- Temporal: ALL in wrong place for XTDB HOT 3
- Temporal: support date/time literals? HOT 1
- Dialect: XTDB HOT 9
- MS SQL table hints in FROM clause (e.g. NOLOCK) HOT 1
- Expand readme function examples to include aliases
- union clause doc mentions nest with no example
- with clause does not support register-fn! formatters HOT 1
- Inconsistent quote "as-is" handling
- Support for UPDATE SET ... FROM (VALUES ...) pattern HOT 6
- Postgres `@?` operator produces `@??` HOT 3
- The `:join` special syntax does not allow specifying an alias for the leftmost expression HOT 3
- How to specify `USING` with `create-index`? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from honeysql.