-
Notifications
You must be signed in to change notification settings - Fork 126
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
Displayer for QueryRowsResult #1138
base: main
Are you sure you want to change the base?
Conversation
c8ad86d
to
ddf3d5d
Compare
3a3f682
to
e15634e
Compare
e15634e
to
e822850
Compare
|
54ad40d
to
7b10b8b
Compare
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.
💯 This is a really great job done! In the aspect of usability, I'm very satisfied.
🔧 There are a few items to be addressed, though, mainly about:
- efficiency: I believe we can get rid of String allocations on the way to display,
- more idiomatic code,
- division into modules.
scylla/src/response/query_result.rs
Outdated
} | ||
} | ||
|
||
/// A utility struct for displaying rows received from the database in a [`QueryRowsResult`]. |
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.
📌 As I noted elsewhere, we should consider making this work both with QueryRowsResult
and with TypedRowStream
.
7b10b8b
to
7687302
Compare
222febc
to
549fd82
Compare
impl fmt::Display for WrapperDisplay<'_, CqlDate> { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
// example of formating date 2021-12-31 | ||
let magic_constant = 2055453495; // it is number of days from -5877641-06-23 to -250000-01-01 | ||
// around -250000-01-01 is the limit of naive date | ||
|
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.
❓ Please explain in detail what the "magic constant" is and why it is correct in your opinion.
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.
I believe it is correct because the dates printed by the displayer are the same as those inserted into the database, this constant allows shifting the date calculation to a valid range, thus preventing from_ymd_opt()
from returning None
. The date -5877641-06-23 is the reference point for CqlDate
.
549fd82
to
9b05d0e
Compare
rebased on main |
addressed comments |
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.
💯 Looks good!
Could you please squash the 3 latter commits into the respective former 2? So that nothing is introduced in a bad way in one commit only to be fixed in another.
🔧 There are new merge conflicts; when squashing the commits I asked you for, please remember to rebase on main. |
369b40c
to
20d1534
Compare
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.
💯 🎉 Looks good to me! Thank you for the contribution!
20d1534
to
cbad25f
Compare
…qlsh` and examples of usage
57d9a2f
to
475ab0d
Compare
This PR adds Displayer for QueryRowsResult trying to mimic
cqlsh
way of displaying tables, but there are some differences:cqlsh
displays this type in an unclear way,for more details look in the comments.list
,map
,set
,tuple
,udt
), I use quotes only fortext
as I think putting other types in quotes might be confusing.Fixes: #999
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.