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

refactor: replace String with Tenant #15119

Merged
merged 6 commits into from
Mar 29, 2024

Conversation

drmingdrmer
Copy link
Member

@drmingdrmer drmingdrmer commented Mar 28, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

refactor: replace String with Tenant

Replacing all String with Tenant introduces a lot changes.
These changes will be split into several PRs.
This is one of them.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Refactoring

Related Issues


This change is Reviewable

Replacing all String with Tenant introduces a lot changes.
These changes will be split into several PRs.
This is one of them.

- Part of databendlabs#14719
@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Mar 28, 2024
@drmingdrmer drmingdrmer marked this pull request as ready for review March 28, 2024 15:17
@@ -3611,18 +3612,30 @@ pub fn create_database_option(i: Input) -> IResult<CreateDatabaseOption> {
rule! {
FROM ~ SHARE ~ #ident ~ "." ~ #ident
},
|(_, _, tenant, _, share_name)| {
|(_x, _y, tenant, _z, share_name)| {
Copy link
Contributor

Choose a reason for hiding this comment

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

why xyz?

Comment on lines +3617 to +3618
// TODO: non-safe new() that does not return an error
tenant: Tenant::new(tenant.to_string()),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use map_res to return an error.

Comment on lines +3629 to +3638
if let CreateDatabaseOption::FromShare(ident) = &opt {
if ident.tenant.name().is_empty() {
return Err(nom::Err::Error(Error::from_error_kind(
i,
ErrorKind::Other("tenant is empty string"),
)));
}
}

Ok((i, opt))
Copy link
Contributor

Choose a reason for hiding this comment

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

Use map_res instead.

@drmingdrmer
Copy link
Member Author

@andylokandy
Thank you for your advices. I'm gonna fix these issues in next PR

@drmingdrmer drmingdrmer merged commit 742dfef into databendlabs:main Mar 29, 2024
75 checks passed
@drmingdrmer drmingdrmer deleted the 35-key-tenant branch March 29, 2024 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-refactor this PR changes the code base without new features or bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants