Skip to content

Commit

Permalink
#515: exclude some entities from smart quoting
Browse files Browse the repository at this point in the history
this is a partial solution, intended to catch (and quote) things like
`0abc` while not changing the behavior for `80` or `2023_11_20`
  • Loading branch information
seancorfield committed Nov 20, 2023
1 parent 002285a commit f46dbc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* 2.5.next in progress
* Review metadata -> SQL logic?
* Review quoting logic?
* Address [#515](https://github.com/seancorfield/honeysql/issues/515) in part by quoting entities that start with a digit but are otherwise alphanumeric. Note that entities that are all digits (optionally including underscores) will still not be quoted as in previous releases.

* 2.5.1091 -- 2023-10-28
* Address [#512](https://github.com/seancorfield/honeysql/issues/512) by adding support for subqueries in the `:array` special syntax (for BigQuery and PostgreSQL). This also adds support for metadata on the `:select` value to produce `AS STRUCT` or `DISTINCT`.
Expand Down
8 changes: 6 additions & 2 deletions src/honey/sql.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,12 @@
)

(def ^:private alphanumeric
"Basic regex for entities that do not need quoting."
#"^[A-Za-z0-9_]+$")
"Basic regex for entities that do not need quoting.
Either:
* the whole entity is numeric (with optional underscores), or
* the first character is alphabetic (or underscore) and the rest is
alphanumeric (or underscore)."
#"^([0-9_]+|[A-Za-z_][A-Za-z0-9_]*)$")

(defn format-entity
"Given a simple SQL entity (a keyword or symbol -- or string),
Expand Down

0 comments on commit f46dbc5

Please sign in to comment.