Repository navigation
fix(pretty_print): indent broken ALTER DOMAIN and drop double space before JSON RETURNING - #882
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two small formatter bugs found while working on #871.
ALTER DOMAIN operations are indented when the statement breaks
emit_alter_domain_stmtbroke the line before the operation without an indent, so a longALTER DOMAINputadd constraint(anddrop constraint,validate constraint,set/drop default,set/drop not null) at column 0. The operation now sits in an indent, the same way ALTER TABLE indents its commands:Short statements still fit on one line (
alter domain public.short_domain drop not null;).No double space before RETURNING in JSON functions
json_value,json_query,json_arrayaggandjson_objectaggemit a soft line beforeRETURNING, then calledemit_json_outputwithhas_content = true, which adds its own space. When the group stayed flat, that printed two spaces:These four call sites no longer ask for the extra space.
json_object,json_array,json_serialize,json_parse, theJsonAggConstructortail andjson_tabledon't emit a line beforeRETURNING, so they already used a single space and stay unchanged.json_existstakes noRETURNINGclause.Tests and snapshot changes
multi/alter_domain_layout.sql(every ALTER DOMAIN subtype, broken and flat) andmulti/json_returning.sql(flat and brokenRETURNINGacross the JSON functions). They were committed first with the output frommain, so the fix commits show the before/after.check_constraint_body*snapshots: only the ALTER DOMAIN statement changes (it is now indented).sqljson*andsqljson_queryfuncs*snapshots: changes are whitespace only (I checked this by collapsing whitespace on both sides). A few statements now fit within the line width and collapse onto one line.Risks
Output changes only. No snapshot has a mid-line double space before a JSON clause keyword any more. Out of scope: when a
json_value/json_querycall breaks, its clauses are still not indented relative to the opening parenthesis (see the long cases injson_returning).