Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a different font and/or color for the syntactic markers #4132

Open
pkoppstein opened this issue Nov 23, 2024 · 5 comments · Fixed by #4264
Open

Use a different font and/or color for the syntactic markers #4132

pkoppstein opened this issue Nov 23, 2024 · 5 comments · Fixed by #4264
Labels
enhancement Small improvement in the documentation, e.g., documenting some slighly unexpected behavior

Comments

@pkoppstein
Copy link

https://duckdb.org/docs/data/json/creating_json.html gives the synopsis:

json_object([key, value, ...])

but the example lower down is:

SELECT json_object('duck', 42);

In fact, DuckDB v1.1.4-dev2210 does not accept the form given in the synopsis:

SELECT json_object(['duck', 42]);
Invalid Input Error:
json_object() requires an even number of arguments

Note also:

SELECT json_object(['duck'], [42]) as "not what we want";
┌──────────────────┐
│ not what we want │
│       json       │
├──────────────────┤
│ {"[duck]":[42]}  │
└──────────────────┘
@soerenwolfers
Copy link
Collaborator

soerenwolfers commented Dec 3, 2024

The square brackets in the function signature indicate optional arguments. The ellipsis in the square brackets indicates that the function is variadic.

See the function json_array just above.

Agree the notation for function signatures is currently far from ideal, but it's consistent.

@soerenwolfers soerenwolfers closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2024
@pkoppstein
Copy link
Author

@soerenwolfers - Sorry for the noise. Any chance of turning this "Issue" into an enhancement request for the documentation to use a different font and/or color for the syntactic markers?

@szarnyasg szarnyasg reopened this Dec 3, 2024
@szarnyasg szarnyasg added the enhancement Small improvement in the documentation, e.g., documenting some slighly unexpected behavior label Dec 3, 2024
@szarnyasg szarnyasg changed the title documentation for json_object(): synopsis is incorrect Use a different font and/or color for the syntactic markers Dec 3, 2024
@szarnyasg
Copy link
Collaborator

Any chance of turning this "Issue" into an enhancement request for the documentation to use a different font and/or color for the syntactic markers?

Sure, we can think about those. I adjusted the title/labels accordingly.

szarnyasg added a commit to szarnyasg/duckdb-web that referenced this issue Dec 4, 2024
@szarnyasg
Copy link
Collaborator

I took a look at this issue again and I adjusted the related JSON function examples in a PR, so I'll close this.

@pkoppstein
Copy link
Author

@szarnyasg wrote:

I took a look at this issue again

There's nothing quite like simplicity :-)

The one thing that's not immediately clear, though, is that both functions can be called without any arguments. So, for your consideration...

json_array(any, ...) | Create a JSON array from the value(s), if any, in the argument list.

json_object(key, value, ...) | Create a JSON object from the key-value pair(s), if any, in the argument list. Requires an even number of arguments.

@szarnyasg szarnyasg reopened this Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Small improvement in the documentation, e.g., documenting some slighly unexpected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants