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 +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.
Copilot AI review requested due to automatic review settings December 27, 2025 04:21
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 5 out of 5 changed files in this pull request and generated 2 comments.


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

Copilot AI review requested due to automatic review settings December 27, 2025 04:34
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 8 out of 8 changed files in this pull request and generated 4 comments.


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

let demo_dir = tempdir()?;
let demo_path = demo_dir.path();
let sql_file_path = demo_path.join("test-query.sql");
let sample_query_path = demo_path.join("test-query.queries.ts");
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

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

The variable sample_query_path is declared but never used in this test. Consider removing it to avoid confusion.

Suggested change
let sample_query_path = demo_path.join("test-query.queries.ts");

Copilot uses AI. Check for mistakes.
let demo_dir = tempdir()?;
let demo_path = demo_dir.path();
let sql_file_path = demo_path.join("test-query.sql");
let sample_query_path = demo_path.join("test-query.queries.ts");
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

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

The variable sample_query_path is declared but never used in this test. Consider removing it to avoid confusion.

Suggested change
let sample_query_path = demo_path.join("test-query.queries.ts");

Copilot uses AI. Check for mistakes.

let db_port = match (db_url.is_some(), db_port_chain()) {
(true, Some(v)) => v,
(true, None) => 0,
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

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

Setting db_port to 0 when db_url is provided but no port chain value exists could cause issues if the DB_URL is malformed or missing. Consider validating that db_url is actually valid before allowing zero as a fallback value.

Copilot uses AI. Check for mistakes.

let db_user = match (db_url.is_some(), db_user_chain()) {
(true, Some(v)) => v,
(true, None) => String::new(),
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

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

Setting db_user to an empty string when db_url is provided but no user chain value exists could cause issues if the DB_URL is malformed or missing. Consider validating that db_url is actually valid before allowing empty fallback values.

Copilot uses AI. Check for mistakes.
@JasonShin JasonShin merged commit b783b3e into main Dec 27, 2025
54 of 55 checks passed
@JasonShin JasonShin deleted the support-db-url branch December 27, 2025 04:43
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