Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why pass db into select, insert, create-table, etc when it's actually needed only in sql fn? #24

Open
mlapshin opened this issue Dec 16, 2014 · 1 comment

Comments

@mlapshin
Copy link

Hi Roman.

After reading sqlingvo source I'm confused with db argument of functions such as select, insert and others. db contains information about how to escape various SQL literals, so it's needed only when generating string representation of SQL AST - in sqlingvo.core.sql function.

It'll be much more convenient to completely separate AST construction and generation of SQL strings:

(let [select-stmt (select [:*]
                    (from :foo)
                    (where '(= :bar 42)))]
  (println "PostgreSQL variant:" (sql postgres-db select-stmt))
  (println "SQLite variant:" (sql sqlite-db select-stmt))
  (println "MySQL variant:" (sql mysql-db select-stmt)))

Or I'm missing something? I can make a pull request if this change makes sense.

@r0man
Copy link
Owner

r0man commented Dec 19, 2014

Hey mlapshin,

the reason I pass the db to those fns is because in some future I
want to be able to do something like the following example:

@(select db [1 2 3])
;=> ({:?column?-3 3, :?column?-2 2, :?column? 1})

I have an other project that builds on top of sqlingvo over here
that has some examples in the readme.

https://github.com/r0man/datumbazo

That repo is highly experimental, so I would not recommend
building on top of that. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants