Commit graph

299 commits

Author SHA1 Message Date
Sean Corfield
d86150784b Fixes #239 by never qualifying inserted column names 2020-05-18 12:06:20 -07:00
Sean Corfield
97868812c1 Prepare to switch from lein to CLI/deps.edn
This starts the cleanup of the project so I can use cljs-test-runner via 
the CLI. The next big cleanup will be removing macrovich.
2020-03-06 15:11:44 -08:00
Ted Coakley
e7dce6b347 Adds support for except set operation #254 2020-03-06 17:34:06 +00:00
Sean Corfield
9fb3d42660 Release 0.9.9 fixes #253 2020-03-02 16:01:14 -08:00
Sean Corfield
a732815b37 Fixes #249 by adding :namespace-as-table? option for 0.9.8 2019-09-07 23:42:38 -07:00
Sean Corfield
f17a6f5582 Fixes #247 by reverting #132 / #131
Adds `*allow-namespaced-names?*` Var and `:allow-namespaced-names?` 
option so the previous behavior can still be used.
2019-09-07 15:18:10 -07:00
Sean Corfield
c573f3bd9c Fixes #235 by adding two different SET priority variants
This allows the behavior change in #200 to be worked around.
2019-09-07 14:55:06 -07:00
Sean Corfield
7831ebed38 Fixes #128 by adding :truncate / truncate 2019-09-07 13:24:46 -07:00
Sean Corfield
94601ee5ae Fixes #248 by changing how aliases are rendered
In theory, the only change here will be to stop the paren-wrapping in 
generation of alias SQL -- but I think that treating alias/columns pairs 
like this (as a nested alias) is very suspicious anyway so that probably 
ought to be fixed "properly" at some point.
2019-09-05 16:38:20 -07:00
Sean Corfield
8bf68d1d10 Another run at fixing #246 2019-08-21 21:59:39 -07:00
Sean Corfield
a31426da6b Fixes #246
Also fixes reflection warning introduced in #237.
2019-08-21 16:03:21 -07:00
Cam Saul
bd076b193a
Fix query generation when user.language is Turkish 2019-02-08 20:02:31 -08:00
Gordon Stratton
5faae8790f The "AS" alias is no longer split before quoting
Fixes #216
2018-10-01 15:19:03 +00:00
Andrea Richiardi
24c20c3a2f Add mimimal test for #228 2018-09-25 09:56:39 -07:00
Vincent
6e3631822d Added Inlinable protocol for more sensible stringification of inline values, and to allow library users to further extend the inline behavior (#224) 2018-08-30 18:55:53 +02:00
Sean Corfield
2b238c5a47 Fix #221 by treating #inline nil as a special case 2018-08-03 17:13:46 -07:00
Sean Corfield
ea76608c7c Merge branch 'delete' of https://github.com/MichaelBlume/honeysql into MichaelBlume-delete
Corrects `delete` to support multiple tables.
Adds tests.
Adds README examples.

# Conflicts:
#	src/honeysql/format.cljc
#	src/honeysql/helpers.clj
2018-06-26 18:24:01 -07:00
Chris Targett
f778419cb9 Refactored parameterizer to use mutimethods
It was briefly mentioned in #honeysql on clojurians.slack.com that this
mechanism of extension uses a register method and an atom to support
extension when multimethods are used elsewhere.
2018-05-15 21:22:32 +01:00
Michael Blume
524887a9cd test SET after JOIN 2018-04-16 00:03:35 -07:00
Michael Blume
43e94bf497
Merge pull request #201 from vincent-dm/master
adds support for JOIN ... USING (...) syntax (#188)
2018-04-12 23:39:59 -07:00
Juvenn Woo
2abe128008
Support register customized parameterizer 2018-03-09 11:54:14 +08:00
Nuttanart Pornprasitsakul
3206b099df Remove nil predicate from :and 2018-02-18 13:27:07 +07:00
Michael Blume
8ad38d28af
Merge pull request #196 from emidln/emidln/insert-into-drop-parens
Avoid wrapping QUERY with parens while formatting INSERT INTO ... QUERY
2018-02-10 23:48:01 -08:00
Vincent
8a6ecd94aa adds support for JOIN ... USING (...) syntax (#188) 2018-01-16 03:13:14 +01:00
Tianxiang Xiong
ccff2d2c23 Limit value context to sequences in value positions
Fix #198
2018-01-09 23:42:53 -08:00
Brandon Adams
c7df208e3e Avoid wrapping QUERY with parens while formatting INSERT INTO ... QUERY
This also adds a test using honeysql.format/format for an existing
format-clause test case for :insert-into which encodes the previously
failing behavior.
2017-12-12 16:09:31 -06:00
Michael Blume
faba02f2b4
Merge pull request #186 from arichiardi/parameterizer-none
Add :parameterizer :none option
2017-11-15 21:23:11 -08:00
Andrea Richiardi
6cf89436d4 Add :parameterizer :none option
Sometimes you want to completely skip using parameters.

Postgres, in particular, complains with cryptic "syntax error at or near "$1"
whenever query parameters cannot be used for the query. An example would be
CREATE TABLE queries where the only parameters are the VARCHAR size.

This patch adds a :none option to :parameterizer which completely skips
parameter filling (and numbering), returning the SQL string only.
2017-11-06 17:13:02 -08:00
Andrea Richiardi
65037939b2 [Fix #167] Add ClojureScript self-host support
This patch uses the wonderful cgrand/macrovich for supporting both JVM and
self-host ClojureScript. The library avoids destructive code changes, no
namespaces were moved.

The patch also adds a runner for self-host tests by adding the lein-tach
plugin. Tests can be launched with:

  lein tach lumo (or planck)

See the lein-tach README for details.
2017-11-01 10:13:47 -07:00
Michael Blume
7256f7afba Revert "Merge pull request #169"
Revert the reversion, keep the behavior from 0.9.0, vectors will be
primarily used for function calls.
2017-08-25 09:12:53 -07:00
Michael Blume
3eaf5edbc0 Merge pull request #169 from MichaelBlume/fix-tuples
Revert #149 and restore tuple behavior
2017-07-18 13:47:56 -07:00
Michael Blume
9ab7d3a2f8 restore function call test using sql/call 2017-07-18 13:45:12 -07:00
Michael Blume
d99efb8606 allow inlining values
Most of the time we want to parameterize numbers, but sometimes we don't

Fixes #171
2017-07-18 12:50:27 -07:00
Michael Blume
a0b73cdcc6 Test that tuples work correctly
Thanks to @jetmind who gave this test in #168
2017-07-17 20:49:35 -07:00
Michael Blume
62c4760c6a Revert "Merge pull request #149"
Should #168
2017-07-17 20:49:35 -07:00
Brandon Adams
f94e343f31 Reprioritize WITH wrt UNION and UNION ALL
WITH needs to come before clauses that are part of a UNION
or UNION ALL.[1][2][3][4]

[1] "A CTE must be followed by a single SELECT, INSERT, UPDATE, or DELETE
statement that references some or all the CTE columns."
https://docs.microsoft.com/en-us/sql/t-sql/queries/with-common-table-expression-transact-sql

[2] "the WITH clause itself is attached to a primary statement that can
also be a SELECT, INSERT, UPDATE, or DELETE"
https://www.postgresql.org/docs/9.6/static/queries-with.html

[3] https://mariadb.com/kb/en/mariadb/with/

[4] "All common table expressions (ordinary and recursive) are created
by prepending a WITH clause in front of a SELECT, INSERT, DELETE, or
UPDATE statement."
https://sqlite.org/lang_with.html

Added a test case demonstrating the expected behavior for each of
UNION and UNION ALL.
2017-06-27 20:01:52 -07:00
Eli Naeher
00316fc6bd Add helpers for :with and :with-recursive clauses 2017-05-19 22:59:21 -07:00
Michael Blume
e0072efbdc Merge pull request #132, allow namespaced keywords 2017-04-05 21:11:45 -07:00
Tom Connors
bdfee0883e Fix using maps with different key orders in :values 2017-03-24 00:18:04 -07:00
Joost Diepenmaat
5e7e224df4 Show problem with operators in value positions 2017-02-17 10:20:40 +01:00
Richard Newman
a0d0880ac6 Add an additional test for phrasing complex UNION queries. 2016-10-12 09:26:51 -07:00
Richard Newman
9dd87d14a0 Don't parenthesize the subclauses of a UNION, UNION ALL, or INTERSECT clause. Fixes #141. 2016-10-12 08:50:54 -07:00
Richard Newman
0539e33d9a Get tests running with 'lein doo'. 2016-07-18 14:12:01 -07:00
Mike Blume
7c8cdf241d MichaelBlume's first pass at ClojureScript support. 2016-07-18 14:12:01 -07:00
Mike Blume
5603e9df9f Add ClojureScript build, move files to cljc.
ClojureScript build fails.
2016-07-18 14:10:52 -07:00
Jon Doane
5b197f9756 Solve an issue where namespaced keywords and symbols where only taking the name portion of the identifier.
- This now checks if there is a namespace and prepends it to the name if it exists.
2016-07-09 10:37:33 -04:00
Alexander Hudek
7397b3a48f Update tests for parameterized numbers. 2016-05-18 17:21:51 -04:00
Michael Blume
43df955a86 Merge pull request #111 from stuarth/master
allow joins without a pred
2016-03-30 23:10:18 -07:00
Michael Blume
d9567e64e0 Merge pull request #110 from csummers/master
escape quote characters in quoted identifiers
2016-03-12 17:33:09 -08:00
Dave Della Costa
0662a00722 Merge pull request #103 from jakemcc/add-intersect
add intersect support
2016-03-02 12:37:17 -05:00
Stuart Hinson
80e9d2ec44 allow joins without a pred 2016-03-01 09:39:21 -05:00
Curtis Summers
47cefd0371 escape quote characters in quoted identifiers 2016-02-24 06:45:49 -06:00
Michael Blume
06c97376ef prevent records from being treated as maps
Thanks to @djwhitt and @blinsay for reporting and for providing
test cases.

Fixes #106
2016-02-09 14:09:22 -08:00
Michael Blume
f8a2eedf45 demonstrate incorrect raw/call behavior 2016-02-09 14:07:51 -08:00
Jake McCrary
8fa44d22b3 add INTERSECT support 2015-11-29 17:49:45 -06:00
Michael Blume
607ee17cca Merge pull request #95 from emidln/emidln/with_column_names
Support column names in :with clauses
2015-10-18 11:07:03 -07:00
Brandon Adams
10a1565467 Support column names in :with clauses
This binds `honeysql.format/*subquery?*` to `false` which turns
on processing of a cte-name like `[:foo {:columns [:a :b :c]}]`
resulting in a string like `WITH foo (a, b, c)`.
2015-10-12 15:13:16 -05:00
Jon Doane
f38668edc6 Added one more assertion to test dashed names that are split by periods. 2015-10-11 11:38:50 -04:00
Jon Doane
7e78b10ae4 Added simple test to check for preserved dashes when the var is bound to true. 2015-10-11 11:29:55 -04:00
Dave Della Costa
2123c01fb5 adds tests for :union and :union-all 2015-08-26 00:11:29 +09:00
loganlinn
b51611d4d6 Add fn-handler for CASE statement 2015-08-06 11:29:54 -07:00
Donald Ball
713f72cfb6 Fix the parameterizable protocol to include nil
I forgot that Object doesn't include nil on protocols.

I added test coverage demonstrating the regression, only to note that
parameterized and literal queries produce different sql for the nil
case. I believe only the former is actually valid ANSI SQL, though mysql
at least does not care.
2015-05-20 11:23:36 -04:00
Mike Blume
115ac81fee Merge pull request #74 2015-05-08 16:41:11 -07:00
Andy Chambers
203296149f Add support for exists 2015-04-24 08:08:13 -07:00
Donald Ball
4bdaae39af Convert seq param values to literal sql param lists
This allows seqs to be used as param values, e.g. for IN clauses. It
also converts sets to seqs for the same purpose.

It does not expand the parameter name when this occurs, which will lead
to a mismatch between the *param-names* and *params* collections. It is
not clear how *param-names* are intended to be used, so I have no better
fix to suggest other than repeating a seq's param name the corresponding
number of times into that collection.
2015-04-21 14:28:28 -04:00
Donald Ball
2820662f59 Apply seq to sets when converting to sql
This allows them to be used as values, e.g. for in clauses, as
demonstrated in the test.
2015-04-20 23:40:59 -04:00
Mike Blume
72784452b9 Merge remote-tracking branch 'dball/support-locking-selects' into HEAD 2015-04-17 14:25:23 -07:00
Michael Blume
198115fb84 Merge pull request #69 from mishok13/nulls-first-last-in-order-by
NULL order specification support
2015-04-17 14:20:23 -07:00
Donald Ball
bc0b7e904f Support locking selects
This will need documentation before being merged.
2015-04-17 15:15:23 -04:00
Andrii V. Mishkovskyi
7160b4b1ad Adding tests for expected behavior 2015-04-17 12:29:20 +02:00
Logan Buckley
84387afaa5 Add SqlArray type and reader literal support. 2015-04-15 10:29:34 -05:00
Mike Blume
0c89c0362e add value test 2015-03-31 10:32:48 -07:00
Mike Blume
42c29506a0 Merge remote-tracking branch 'icambron/parameter-fns' into HEAD 2015-03-09 23:31:17 -07:00
Mike Blume
34f84e41b4 Merge remote-tracking branch 'dave/master' into HEAD 2015-03-09 09:56:11 -07:00
Dave Della Costa
6d0ff344b9 Adds basic tests for PR #34, common table expressions 2015-03-09 13:21:41 +09:00
Dave Della Costa
0f24df5ee0 supports extended INSERT INTO...SELECT syntax allowing specifying columns to insert into explicitly 2015-03-05 00:20:42 +09:00
Mike Blume
17145ea549 Merge remote-tracking branch 'justindell/master' into HEAD 2015-03-03 20:34:16 -08:00
Michael Blume
8e7615ee4d Merge pull request #47 from MichaelBlume/testing
Testing
2015-03-03 20:23:47 -08:00
Michael Blume
b621273fd2 Merge pull request #49 from MichaelBlume/expected-first
in unit test, put expected value first
2015-03-03 20:23:31 -08:00
Michael Blume
12f73bfa5a Merge pull request #40 from senior/add-cast-support
Added support for casts of the form CAST(foo AS type)
2015-03-03 20:18:21 -08:00
Mike Blume
a931e375f7 in unit test, put expected value first
is assumes that the first argument to = is a fixture, and the second is
the result of a computation, when it prints Expected: and Actual:
2015-03-03 19:55:08 -08:00
Mike Blume
c8f647ea26 simple format tests 2015-03-03 16:16:41 -08:00
Mike Blume
cbb71c3db9 test apply too 2015-03-03 16:16:41 -08:00
Mike Blume
2cafa5940e avoid collision with update in tests as well 2015-03-02 15:08:16 -08:00
Ryan Senior
dd9647ee3e Added support for casts of the form CAST(foo AS type) 2015-02-20 10:05:09 -06:00
Isaac Cambron
25ba952a3e support postgres-native parameters 2015-01-06 19:58:56 -05:00
Justin Dell
f8a5886124 Add full join 2014-11-05 15:04:21 -06:00
Chris Perkins
a4e9f0ff46 Oracle support.
Omit AS in JOIN, FROM, etc. because Oracle does not support it.
2013-09-06 16:29:41 -06:00
Justin Kramer
74669d62b5 quote aliases better 2013-08-06 15:23:37 -04:00
Justin Kramer
4590b93df5 keyword syntax for bindable param 2013-08-06 14:27:56 -04:00
Justin Kramer
e768e3c1d1 fix test 2013-08-06 14:14:40 -04:00
Justin Kramer
96ddbc18f4 keyword syntax for sql calls 2013-08-06 14:06:00 -04:00
Justin Kramer
76d6ccbcdb :left-join & :right-join clauses; simplifies :join syntax 2012-10-19 12:41:26 -04:00
Justin Kramer
e0c190b50e data reader & test for param 2012-08-24 22:47:54 -04:00
Justin Kramer
2a37063995 fix test 2012-08-24 18:20:45 -04:00
Justin Kramer
cfadae53d1 always pipe base map through build, to ensure consistency 2012-08-24 17:08:22 -04:00
Justin Kramer
18d5fa19e8 make clause-building extensible, move helper fns to honeysql.helpers 2012-08-24 16:50:56 -04:00
Justin Kramer
cef05d4ef5 fix params 2012-07-13 17:20:48 -04:00
Justin Kramer
ed0edfe13f add test 2012-07-13 14:32:43 -04:00