Skip to content

Conversation

@JasonShin
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings November 30, 2025 02:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for a custom database connection URL (DB_URL) as an alternative to specifying individual connection parameters (host, port, user, etc.). When DB_URL is provided, individual connection parameters become optional and can fall back to default values.

Key changes:

  • Added db_url field across configuration structures (CLI args, dotenv, and config structs)
  • Modified connection parameter validation to allow defaults when DB_URL is present
  • Updated credential string builders to prioritize DB_URL when available

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/common/cli.rs Added CLI argument for custom database URL
src/common/dotenv.rs Added support for reading DB_URL from environment variables
src/common/config.rs Modified configuration logic to make individual DB parameters optional when DB_URL is provided, and updated credential string builders
tests/sample/sample.queries.ts Added TypeScript query type definitions (appears unrelated to DB_URL feature)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to 48
#[serde(rename = "DB_HOST", default)]
pub db_host: String,
#[serde(rename = "DB_PORT")]
#[serde(rename = "DB_PORT", default)]
pub db_port: u16,
#[serde(rename = "DB_USER")]
#[serde(rename = "DB_USER", default)]
pub db_user: String,
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

Using default attribute on non-Optional fields with primitive types may cause deserialization issues. When DB_URL is provided, these fields should be Option<String> and Option<u16> respectively, or the struct should validate that either DB_URL or all individual parameters are present.

Copilot uses AI. Check for mistakes.
Comment on lines +325 to +323
db_host,
db_port,
db_user,
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

[nitpick] Removing .to_owned() calls here changes the ownership semantics. Since these are now owned values instead of references, this is correct, but the surrounding code at lines 328-329 still uses .to_owned() creating inconsistency. Consider applying the same pattern to db_pass and db_name for consistency.

Copilot uses AI. Check for mistakes.
Comment on lines 8 to 11
export interface ISampleSelectQueryQuery {
params: SampleSelectQueryParams;
result: ISampleSelectQueryResult;
}
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The interface name ISampleSelectQueryQuery contains redundant 'Query' suffix. Consider renaming to ISampleSelectQuery for clarity.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings November 30, 2025 08:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +237 to +241
let db_host = match (db_url.is_some(), db_host_chain()) {
(true, Some(v)) => v,
(true, None) => String::new(),
(false, Some(v)) => v,
(false, None) => panic!(
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

The pattern (db_url.is_some(), db_host_chain()) is repeated three times for db_host, db_port, and db_user. Consider extracting this logic into a helper function to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +258 to +260
(true, Some(v)) => v,
(true, None) => 0,
(false, Some(v)) => v,
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

Using 0 as a default port when db_url is provided but db_port is not may cause issues if the port value is used elsewhere in the code for validation or logging. Consider using a more explicit sentinel value or documenting this behavior, as port 0 is typically reserved and may not be a valid database port.

Suggested change
(true, Some(v)) => v,
(true, None) => 0,
(false, Some(v)) => v,
(true, Some(v)) => Some(v),
(true, None) => None,
(false, Some(v)) => Some(v),

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants