#515: exclude some entities from smart quoting

this is a partial solution, intended to catch (and quote) things like
`0abc` while not changing the behavior for `80` or `2023_11_20`
This commit is contained in:
Sean Corfield 2023-11-20 11:43:33 -08:00
parent 002285a5af
commit f46dbc5ca7
2 changed files with 7 additions and 3 deletions

View file

@ -2,7 +2,7 @@
* 2.5.next in progress * 2.5.next in progress
* Review metadata -> SQL logic? * 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 * 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`. * 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`.

View file

@ -244,8 +244,12 @@
) )
(def ^:private alphanumeric (def ^:private alphanumeric
"Basic regex for entities that do not need quoting." "Basic regex for entities that do not need quoting.
#"^[A-Za-z0-9_]+$") 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 (defn format-entity
"Given a simple SQL entity (a keyword or symbol -- or string), "Given a simple SQL entity (a keyword or symbol -- or string),