Commit graph

299 commits

Author SHA1 Message Date
Sean Corfield
e8e6c7f932 address #281 - support select foo.* except 2022-01-07 11:35:08 -08:00
Sean Corfield
a653f9b157 address #281 add select * except / replace for BigQuery 2022-01-06 23:02:20 -08:00
Sean Corfield
499b9de0ae proposed syntax for #281 2022-01-06 20:41:51 -08:00
Sean Corfield
8979e938f3 fixes #374 2021-12-23 13:32:47 -08:00
Sean Corfield
6aee04e25c fixes #365 2021-10-03 22:18:12 -07:00
Sean Corfield
dae09ff601 fixes #363 by improving inlining capability 2021-09-25 17:06:48 -07:00
Sean Corfield
9ece8972b5 fixes #344 by special-casing MySQL SET 2021-08-12 18:26:39 -07:00
Sean Corfield
50bbfef07f Fixes #338 properly by making offset/fetch smarter 2021-07-17 17:57:17 -07:00
Sean Corfield
7e84b58463 fixes #338 by adding ONLY to :fetch 2021-07-17 13:32:43 -07:00
Sean Corfield
a393cd89e2 fixes #337 by using clojure.test for cljs 2021-07-15 19:26:59 -07:00
Sean Corfield
fe4be6cca6 Make test cljs-compatible 2021-05-10 22:46:36 -07:00
Sean Corfield
9e0b31bbd9 Fixes #325 Fixes #326 adds tests/docs 2021-05-10 22:44:57 -07:00
Neil McCalum
9c38554154 format with opts, hyphen to under in function names, improve and relocate tests 2021-05-11 01:07:34 +12:00
Neil McCalum
6ebc017969 quoting for :%fun.col(s) syntax to match with [[:fun :col]] 2021-05-09 17:18:39 +12:00
Sean Corfield
d73560b7e3 Add :quoted-snake option 2021-05-08 21:01:28 -07:00
Sean Corfield
46b3c1773b Fixes #324 by correcting insert-into 2021-05-01 12:56:42 -07:00
Sean Corfield
20cba15da2 Fixes #321 by adding :checking option
Initial linting is only for IN () and IN (NULL)
2021-04-22 22:13:32 -07:00
Sean Corfield
f606dc6044 Fixes #323 by allowing multiple column names 2021-04-22 19:16:30 -07:00
Sean Corfield
dd52ebe7e8 Fixes #322 by rewriting where/having merge 2021-04-13 12:51:21 -07:00
Sean Corfield
272b088918 Revert "Addresses #315 by expanding IN to handle nil"
This reverts commit 8a1e2cca71.
2021-04-12 15:04:17 -07:00
Sean Corfield
e6a5bdb001 Fixes #308 by adding support for clauses
This also corrects the docstring for the join-by helper.
2021-04-11 04:18:14 -07:00
Sean Corfield
d734767877 Remove the old 1.x code
It hasn't been part of the deployed library for quite a while because I
had moved it into the test folder, while I was reaching parity.
2021-04-11 03:21:35 -07:00
Sean Corfield
50fd829752 Addresses #310 by adding filter, order-by, within-group syntax 2021-04-11 14:32:48 -07:00
Sean Corfield
862a2496c6 Consistent use of 1.x / 2.x 2021-04-11 11:09:47 -07:00
Sean Corfield
8a1e2cca71 Addresses #315 by expanding IN to handle nil 2021-04-10 10:57:13 -07:00
Sean Corfield
88282ee258 Fixes #316 by adding check on entity characters
Also record that documentation addresses #300, #309, #313, and #314.
2021-04-09 23:41:59 -07:00
Sean Corfield
2fe083f8e6 Support named arguments in format again
With the advent of Clojure 1.11 and the ability to call functions that
accept named arguments using a hash map, I have restored the named
argument version of `format` (in addition to the hash map version),
and if you are using Clojure 1.11 you can mix'n'match styles.
2021-04-09 17:04:48 -07:00
Sean Corfield
af382708e5 Fixes #319 by making register-clause! idempotent
Technically, it removes any instance of the clause from the ordering
before it attempts to add it back in, allowing you to correct the
order if you got it wrong.
2021-04-09 15:58:56 -07:00
Sean Corfield
06f25ed2e3 Fixes #317 by dropping qualifier in :set clause 2021-04-01 12:50:09 -07:00
Sean Corfield
16d04a1dfd Fixes #297 by adding into/bulk-collect-into 2021-03-13 13:42:08 -08:00
Sean Corfield
cff1e5b43c Fixes #284 by adding lateral expression syntax 2021-03-13 13:13:35 -08:00
Sean Corfield
6b070df52c Finish off TOP implementation #292 2021-03-13 12:10:42 -08:00
Sean Corfield
479008c294 Address #292 by starting to support SELECT TOP 2021-03-12 18:54:19 -08:00
Sean Corfield
dc6a3662f0 Fixes #303 by adding ON DUPLICATE KEY UPDATE 2021-03-12 16:13:52 -08:00
Sean Corfield
d35d9141bc Fixes #280 by adding [:escape pattern chars] 2021-03-12 15:39:54 -08:00
Sean Corfield
ddebda9481 Fixes #301 Fixes #306 by expanding drop/create syntax 2021-03-12 11:43:21 -08:00
Sean Corfield
e70985e93b Fixes #277 by adding join-by 2021-03-07 19:21:13 -08:00
Sean Corfield
b600348808 Addresses #283 on the v1 branch 2021-03-06 22:10:43 -08:00
Sean Corfield
06d90c174e Rework and-merge WIP (tests fail) 2021-03-06 18:40:23 -08:00
Sean Corfield
5e2036a922 Temporarily comment out WIP tests 2021-02-27 09:35:03 -08:00
Sean Corfield
78ca2a0530 Fixes #305 by supporting more complex JOIN source 2021-02-27 09:33:20 -08:00
Sean Corfield
770beec886 Add test for (v1) SQL Injection in insert #299 2021-02-22 10:56:32 -08:00
Sean Corfield
28a4074e12 Add flexibility for on conflict / on constraint 2021-02-15 20:43:53 -08:00
Sean Corfield
155ae25ad0 Clean up create extension test 2021-02-15 17:56:18 -08:00
Sean Corfield
0b687c5eb0 Add nilenso version of tests for comparison
This shows all the changes side-by-side.
2021-02-15 16:27:08 -08:00
Sean Corfield
f4137d3fc1 Enhance insert-into; document more helpers 2021-02-14 20:39:32 -08:00
Sean Corfield
e23502eba8 Add create/drop extension #293 2021-02-13 22:06:43 -08:00
Sean Corfield
e585ded37e Restore upsert helper for #293 2021-02-13 19:08:40 -08:00
Sean Corfield
7b928fecb2 Addresses #293 by porting nilenso tests
I intended to keep all the original tests inline but it got harder than
I expected, so I'm going to make another pass over this and insert the
original tests back in later.
2021-02-13 16:02:13 -08:00
Sean Corfield
f6975ef6bd Fix select as, select distinct on 2021-02-13 15:58:56 -08:00
Sean Corfield
4b7ded4009 WIP nilenso test (fails) 2021-02-13 10:50:36 -08:00
Sean Corfield
167d7cee0c Addresses #293 by adding alter table stuff
And documenting more of the DDL.
2021-02-12 17:08:37 -08:00
Sean Corfield
49d8365bfb Addresses #293 partial with-columns implementation 2021-02-10 22:32:29 -08:00
Sean Corfield
83d4ccba38 Addresses #293 start work on DDL support 2021-02-10 20:07:05 -08:00
Sean Corfield
e157aec976 Addresses #293 by adding over, partition-by, and window 2021-02-10 16:25:31 -08:00
Sean Corfield
5318c184e6 Addresses #293 by expanding insert-into behavior
This adds alias support into `:insert-into`.
It also adds some tests for the PostgreSQL-specific
stuff currently in nilenso's library.
2021-02-10 15:07:16 -08:00
Sean Corfield
0a83601c3c Fixes #298 by restoring multi-CTE capability
Reverts code changes that stripped the sequence support.
Updates the docs to clarify how sequence support works.
2021-02-10 12:04:53 -08:00
Sean Corfield
e02b5b5c82 Revert "Document with / CTE"
This reverts commit c00fbffe30.
2021-02-10 11:50:00 -08:00
Sean Corfield
8f725abe02 Revert "Update CTE test to verify both 1.x and 2.x"
This reverts commit 16dd1fff41.
2021-02-10 11:49:32 -08:00
Sean Corfield
16dd1fff41 Update CTE test to verify both 1.x and 2.x 2021-02-07 04:47:23 -08:00
Sean Corfield
c00fbffe30 Document with / CTE
Change the implementation to support just a pair instead of the legacy,
weird sequence of one pair.
2021-02-06 09:00:46 -08:00
Sean Corfield
1b749c1599 Overhaul differences document 2021-02-01 16:24:19 -08:00
Sean Corfield
53bcfd8bea Move toward 2.0.0 Alpha 1 2021-02-01 14:49:17 -08:00
Sean Corfield
379d3d05c4 Drop ? from all keyword options 2021-02-01 13:10:57 -08:00
Sean Corfield
7aab640e30 Fixes #291 by ensuring consistent values
For uneven vectors of values, pad with NULLs.

For uneven maps of values, use full set of keys across all of them.
2021-02-01 10:44:07 -08:00
Sean Corfield
0e2aae4a00 Fix :lift and test to use wrapper 2021-01-31 05:31:10 -08:00
Sean Corfield
8373c72f45 Fixes #286 by supporting WAIT, SKIP LOCKED
NOWAIT was already supported.
2021-01-30 11:43:48 -08:00
Sean Corfield
d2968bbfcc Fixes #289 by implementing USING 2021-01-30 11:19:12 -08:00
Sean Corfield
07eb66759a Restore cljs compatibility 2021-01-30 17:27:00 -08:00
Sean Corfield
87eec786e1 It's 2021 2021-01-29 16:11:52 -08:00
Sean Corfield
17c5e4b980 Add test for question in #285 2020-12-04 10:28:09 -08:00
Sean Corfield
39a83ae57e Add test to V2 for issue #282 2020-10-28 16:26:35 -07:00
Sean Corfield
273732089b Improve :inline/:raw
Note: these are still in flux!
2020-10-14 11:50:32 -07:00
Sean Corfield
b711044548 Minor syntax differences
`:group-by` must take sequence.
`:<` is binary only.
`:select-distinct` instead of modifier.
2020-10-12 22:56:47 -07:00
Sean Corfield
9da9dfe399 Fix test for issue 263 2020-10-12 22:55:16 -07:00
Sean Corfield
f14b73e592 Start merging old core tests (for helpers) 2020-10-12 18:50:07 -07:00
Sean Corfield
97a3782112 Support :inline option
This is similar to `:parameterizer :none` (but better).
2020-10-09 21:52:18 -07:00
Sean Corfield
0c7ce43381 Address #279 by treating UNION expressions as nested 2020-10-09 21:30:45 -07:00
Sean Corfield
8b2f0ef292 Add locking select support via for/lock 2020-09-28 20:45:43 -07:00
Sean Corfield
1fdd50d6b0 Add more tests on insert 2020-09-28 13:18:34 -07:00
Sean Corfield
6db2426046 Fix do update set; add on conflict tests 2020-09-28 11:49:29 -07:00
Sean Corfield
25097af134 First cut of on conflict support 2020-09-26 15:16:12 -07:00
Sean Corfield
002523bb8c Generate AS for select/from; except for Oracle 2020-09-26 00:17:31 -07:00
Sean Corfield
ae6229c282 Move data_readers to test
Since we will not need/support this in V2
2020-09-25 16:44:01 -07:00
Sean Corfield
0052aade7c Implement variadic and/or/+/* 2020-09-25 16:40:15 -07:00
Sean Corfield
5449c23ede Clarify tests
Annotate parameterizer tests as known failures.

Create inline versions of :parameterizer :none tests.
2020-09-25 16:39:50 -07:00
Sean Corfield
a6c1f98b71 Fix CTE syntax
Should always be wrapped in parens
2020-09-25 16:38:38 -07:00
Sean Corfield
1ebbbc1772 Fix inline string behavior 2020-09-25 16:38:11 -07:00
Sean Corfield
9f20ade0fe Fix is/not null generation 2020-09-25 15:31:11 -07:00
Sean Corfield
11ef895c4a Clean up dialect support; start docs
Also move old namespaces to test-only tree for reference while I 
continue developing V2.
2020-09-24 19:07:32 -07:00
Sean Corfield
3ce47b92f2 Implement :inline syntax; allow select call without alias 2020-09-23 22:52:57 -07:00
Sean Corfield
97531fa4cf Implement array as SQL syntax instead of special HoneySQL syntax 2020-09-23 22:25:13 -07:00
Sean Corfield
f7d5e3a4cf Down to just 8 failures now!
Mising: array, inline, parameterizer.
2020-09-23 18:15:20 -07:00
Sean Corfield
1a699f18ab Support more clauses; flesh out dialect and clause ordering 2020-09-23 12:55:02 -07:00
Sean Corfield
a1d90a6382 Work toward more 1.x compatibility
Temporarily disable `AS` in alias while testing compatibility; only 
quoted by default if `:dialect` specified (may revisit this).
2020-09-23 00:14:25 -07:00
Sean Corfield
834ac3a096 Rename sql-format back to format now Chlorine is updated! 2020-09-21 10:56:05 -07:00
Sean Corfield
1dc0447244 Convert more RCFs to tests 2020-09-20 22:25:28 -07:00
Sean Corfield
b6d6d2c4f4 Refactor to sql-format for now 2020-09-20 21:33:04 -07:00
Sean Corfield
2c98d35f63 Start some tests; implement more clauses 2020-09-20 19:17:37 -07:00
Sean Corfield
b3baa094c2 Fixes #257 by adding CROSS JOIN 2020-05-29 16:01:49 -07:00
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