Coder Social home page Coder Social logo

Comments (6)

bcambel avatar bcambel commented on June 3, 2024 1

+1 , 2 years and still valuable :)

from honeysql.

devn avatar devn commented on June 3, 2024

+1 to this. This would be nice to include in the big example in the README.

from honeysql.

jrdoane avatar jrdoane commented on June 3, 2024

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.

seancorfield avatar seancorfield commented on June 3, 2024

@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.

seancorfield avatar seancorfield commented on June 3, 2024

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.

seancorfield avatar seancorfield commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.