- Notifications
You must be signed in to change notification settings - Fork1.9k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
srh commentedMay 8, 2022
Is it going to be I would expect it to support non-string values and use |
srh left a comment
There was a problem hiding this 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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
srh commentedMay 8, 2022
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 commentedMay 8, 2022
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 commentedMay 10, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@srh except coercing all comments are addressed. The error message wording is probably not the best, but I'm opened for any suggestions.
Although the original proposal was Regarding the coercing
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-boros commentedMay 11, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Now, this is ready for review. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 We might also want to reserve |
srh left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Const reference nitpicking.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
srh commentedMay 30, 2022
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 commentedJun 5, 2022
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:
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 // 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
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 ( r.format("Simple formatting: {x.y}",{"x.y":{y:1}}) What would we render here? The key is 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 |
8e79795 to121957dCompare779b734 tobfcddfdComparebfcddfd to6746820Comparegabor-boros commentedAug 18, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 commentedAug 22, 2022
@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?
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 commentedAug 25, 2022
@gabor-boros I am hoping to get FreeBSD-related compilation fixes merged before forking the branches. |
gabor-boros commentedAug 26, 2022
@srh 👌I'll wait for that to not interfere |
srh commentedDec 15, 2023
Just reminding myself: after we break off the Python/test code changes and merge these, we will want to
|
a26c3ab to691e231CompareAdd 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>
691e231 toba40a6fCompareSigned-off-by: Gabor Boros <gabor.brs@gmail.com>
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
6135acb to4cbd73cCompareSigned-off-by: Gabor Boros <gabor.brs@gmail.com>
d023b45 tod0b2d67CompareSigned-off-by: Gabor Boros <gabor.brs@gmail.com>
gabor-boros commentedAug 20, 2025
@srh Finally all the dependencies of this PR are done:
Two notes:
At this point, I think we can merge this and all related PRs and decide what else to go into |
srh commentedAug 24, 2025
Sure! |
8de19b3 intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Description
This PRresolves#3353 by adding the mentioned
r.formatcommand. The command formats the template string, passed as the first parameter, using the object provided as the second parameter.Related PRs
formatReQL command docs#1332Limitations
The object must havestringkeys andstringvalues.Questions
Should we supportintanddoublein 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
2.4.xbranch before merging and rename the current one tomainThe drivers shouldn't release
formatsupport until 2.5.0.formatcommand rethinkdb-javascript#14formatrethinkdb-ruby#28formatin the Java driver (cc: @adriantodt)Other (maintained) drivers:
formatin the Go driver (cc:@CMogilko)formatin the Typescript driver (cc:@atassis)