Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: addformat ReQL command#7066

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gabor-boros merged 7 commits intomainfromgabor/add-reql-fmt
Aug 24, 2025
Merged

feat: addformat ReQL command#7066

gabor-boros merged 7 commits intomainfromgabor/add-reql-fmt
Aug 24, 2025

Conversation

@gabor-boros
Copy link
Member

@gabor-borosgabor-boros commentedMay 8, 2022
edited by srh
Loading

Description

This PRresolves#3353 by adding the mentionedr.format command. The command formats the template string, passed as the first parameter, using the object provided as the second parameter.

Related PRs

Limitations

  • The object must havestring keys andstring values.

Questions

  • Should we supportint anddouble in the object? If yes, what would be the expected way of lexical casting of doubles to strings withouth adding extra trailing zeros or truncating the doubles?

Leftovers

  • Cut a new2.4.x branch before merging and rename the current one tomain

The drivers shouldn't releaseformat support until 2.5.0.

Other (maintained) drivers:

  • Implementformat in the Go driver (cc:@CMogilko)
  • Implementformat in the Typescript driver (cc:@atassis)

@gabor-borosgabor-boros added this to the2.5.0 milestoneMay 8, 2022
@gabor-borosgabor-boros requested a review fromsrhMay 8, 2022 09:21
@gabor-borosgabor-boros self-assigned thisMay 8, 2022
@gabor-borosgabor-boros changed the titleGabor/add reql fmtfeat: addfmt ReQL commandMay 8, 2022
@srh
Copy link
Contributor

srh commentedMay 8, 2022

Is it going to ber.fmt orr.format?

I would expect it to support non-string values and user.coerceTo('string').

Copy link
Contributor

@srhsrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There are some bugs, and I think the treatment of format strings with unmatched curly braces is bad.

@srh
Copy link
Contributor

srh commentedMay 8, 2022

Is it going to be r.fmt or r.format?

You wrote format or FORMAT the whole time in the code, which is why I'm asking. I think r.format would be fine.

@gabor-boros
Copy link
MemberAuthor

Thank you for the review,@srh . I'll go through the suggestions in the upcoming days. Also, I'll use the r.format version instead of r.fmt. That seems a bit more correct to me.

@gabor-boros
Copy link
MemberAuthor

gabor-boros commentedMay 10, 2022
edited
Loading

@srh except coercing all comments are addressed. The error message wording is probably not the best, but I'm opened for any suggestions.

Is it going to be r.fmt or r.format?

Although the original proposal wasfmt, I thinkformat would be a bit better.

Regarding the coercing

As I figured out, we could probably use theminidriver to evaluate the following, but I'm struggling how to properly do that. Do you have any suggestions? Nevermind. I figured it out.

datum_t field = datum.get_field(datum_string_t{param_name});r.expr(field).coerce_to("STRING")

Update: I'm going to update the PR tomorrow with the latest changes and adjusted polyglot tests

@gabor-borosgabor-boros requested a review fromsrhMay 10, 2022 20:59
@gabor-borosgabor-boros changed the titlefeat: addfmt ReQL commandfeat: addformat ReQL commandMay 11, 2022
@gabor-boros
Copy link
MemberAuthor

gabor-boros commentedMay 11, 2022
edited
Loading

Now, this is ready for review.
Update: ReQL tests are obviously failing as they have no driver implementation yet.

@gabor-borosgabor-boros requested a review fromsrhMay 20, 2022 07:18
@srh
Copy link
Contributor

srh commentedMay 21, 2022

We might also want to reserve a character for use in format strings for use in specifying how the data is formatted. C# uses, and:, while Rust uses:. It might be that: is used in some field names. Maybe there is a better character to use.

We might also want to reserve. to allowfield.subfield syntax in the future.

Copy link
Contributor

@srhsrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Const reference nitpicking.

@srh
Copy link
Contributor

srh commentedMay 30, 2022

In terms of keeping characters for formatting, I would personally prefer the colon approach or percent sign. These two characters are rarely used in document keys -- I hope -- and both are used by other languages like Python (%), Rust (:), Java (%), etc.

What do you think nested fields might look like?

Maybe we should reserve an escape or quoting character that could be used for field names.

@gabor-boros
Copy link
MemberAuthor

@srh

What do you think nested fields might look like?
Maybe we should reserve an escape or quoting character that could be used for field names.

I had some time today to think about it, though I couldn't come up with a better idea. I think there are two questions:

  • What character(s) do we want to reserve for later use for formatting?
  • Do we want to support nested field access? If yes, how would we access the nested field?

"What character(s) do we want to reserve for later use for formatting?"

The original proposal was to have a string replacement like this:

// Replace the placeholder with string representationr.format("Simple formatting: {x}",{"x": "})

To define formatting, we could use the%,:, or, sign, but using that could make the placeholder a bit unreadable:

// Format the replacement as a floating point number v1r.format("Temperature: {temp%f.2}",{temp:32.123})// Format the replacement as a floating point number v2r.format("Temperature: {temp:f.2}",{temp:32.123})// Format the replacement as a floating point number v3r.format("Temperature: {temp,f.2}",{temp:32.123})

Out of the three the third variant, using,, maybe the most readable. Although I personally prefer% it is more important to keep the placeholder readable, so I'd say to reserve the, character.

"Do we want to support nested field access? If yes, how would we access the nested field?"

If I understand correctly, this would be the usage example (assuming the subfield access character is.):

// Replace the placeholder with string representationr.format("Simple formatting: {x.y}",{x:{y:1}})

Well, I wouldnot support this. It could bring too many edge cases to the table. Consider the following example:

r.format("Simple formatting: {x.y}",{"x.y":1})

In this case, the key has the access character (.) in its name, furthermore, the value is not an object, but a number. Or even worse:

r.format("Simple formatting: {x.y}",{"x.y":{y:1}})

What would we render here? The key isx.y, but the value ofx.y has a keyy as well.

I would simply say that nested field's shouldn't be allowed as of now. If someone brings a proposal for solving all issues mentioned above, we could consider that, but I don't have a good proposal for solving the issue.


I went ahead and reserved the, character to reduce the number of iterations, though I'm opened for suggestions.

@gabor-borosgabor-borosforce-pushed thegabor/add-reql-fmt branch 2 times, most recently from8e79795 to121957dCompareJune 9, 2022 16:43
@gabor-borosgabor-borosforce-pushed thegabor/add-reql-fmt branch 6 times, most recently from779b734 tobfcddfdCompareJuly 4, 2022 13:34
@gabor-boros
Copy link
MemberAuthor

gabor-boros commentedAug 18, 2022
edited
Loading

The PR is rebased; I'll finish the PR after the next 2.4.x release. Basically, the test-runner and related python code must be bumped to work nicely with Python3 and we are good to go.

@gabor-boros
Copy link
MemberAuthor

@srh If I would want to fix the Python tests to work with the new driver implementation and Python 3, I would at least 4x the PRs size with somewhat irrelevant changes. How about the following?

  • I move the second commit (6746820) to a separate PR where I update the repo to use Python 3
  • I create a newdefault branch from the current v2.4.x and call itmain
  • Then I merge this PR intomain which will not affect the new 2.4.x release.

We already discussed the second one, but wanted to bring into your attention again as I've seen your plans to release a new 2.4.x version.

@srh
Copy link
Contributor

srh commentedAug 25, 2022

@gabor-boros I am hoping to get FreeBSD-related compilation fixes merged before forking the branches.

@gabor-boros
Copy link
MemberAuthor

@srh 👌I'll wait for that to not interfere

@srhsrh changed the base branch fromv2.4.x tomainDecember 15, 2023 23:03
@srh
Copy link
Contributor

srh commentedDec 15, 2023

Just reminding myself: after we break off the Python/test code changes and merge these, we will want to

  • make driver changes
  • update the JS driver in the admin UI inold_admin in a later PR

Add basic string formatting to ReQL and bump polyglot test target tonewer target versions.Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
@gabor-boros
Copy link
MemberAuthor

@srh Finally all the dependencies of this PR are done:

Two notes:

  • the Python driver got a huge refactor (if you want to take a look, feel free to do so, but it is huge).
  • the Java driver is not updated, on demand I can do that if nobody wants to (cc:@NotJustAnna maybe?)

At this point, I think we can merge this and all related PRs and decide what else to go intov2.5.0. What do you think?

@srh
Copy link
Contributor

srh commentedAug 24, 2025

Sure!

@gabor-borosgabor-boros merged commit8de19b3 intomainAug 24, 2025
36 of 40 checks passed
@gabor-borosgabor-boros deleted the gabor/add-reql-fmt branchAugust 24, 2025 14:44
@github-project-automationgithub-project-automationbot moved this fromIn Review toDone inRelease 2.5.0Aug 24, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@srhsrhsrh approved these changes

Assignees

@gabor-borosgabor-boros

Projects

Status: Done

Milestone

2.5.x

Development

Successfully merging this pull request may close these issues.

ReQL proposal: string templating

3 participants

@gabor-boros@srh

[8]ページ先頭

©2009-2025 Movatter.jp