Skip to content

Uses raw databaseName for fetching state #107

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

Merged
merged 2 commits into from
Jul 1, 2025
Merged

Conversation

sdseaton
Copy link
Contributor

This pull request changes the handling of database names by removing escaping logic when loading the database state and introducing a new property for escaped names to allow access to the escaped name when necessary.

@Copilot Copilot AI review requested due to automatic review settings June 26, 2025 15:27
Copy link

@Copilot 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 refactors how database names are handled by removing the previous escaping logic when running queries and introducing a new property (EscapedName) in the Database model for cases where escaping is required.

  • Removed local escaping logic in KustoSchemaHandler and now uses the raw databaseName
  • Introduced Database.EscapedName for on-demand escaping when necessary

Reviewed Changes

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

File Description
KustoSchemaTools/Model/Database.cs Added a new property EscapedName computed using Name.BracketIfIdentifier()
KustoSchemaTools/KustoSchemaHandler.cs Replaced escaped database names with the raw databaseName in logs, handler creation, and diff generation
Comments suppressed due to low confidence (1)

KustoSchemaTools/KustoSchemaHandler.cs:41

  • The PR description introduces the EscapedName property for escaped identifiers. Please verify if using the raw databaseName in logging and factory calls is intentional, or if the EscapedName property should be used when an escaped identifier is required.
                Log.LogInformation($"Generating diff markdown for {Path.Combine(path, databaseName)} => {cluster}/{databaseName}");

foreach (var cluster in clusters.Connections)
{
Log.LogInformation($"Generating diff markdown for {Path.Combine(path, databaseName)} => {cluster}/{escapedDbName}");
Log.LogInformation($"Generating diff markdown for {Path.Combine(path, databaseName)} => {cluster}/{databaseName}");

Check warning

Code scanning / CodeQL

Use of default ToString() Warning

Default 'ToString()':
Cluster
inherits 'ToString()' from 'Object', and so is not suitable for printing.

Copilot Autofix

AI about 19 hours ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@sdseaton sdseaton changed the title Uses raw databaseName for running queries Uses raw databaseName for fetching state Jun 26, 2025
@@ -36,5 +37,6 @@ public class Database

public Dictionary<string, FollowerDatabase> Followers { get; set; } = new Dictionary<string, FollowerDatabase>();

public string EscapedName => Name.BracketIfIdentifier();
Copy link
Contributor

Choose a reason for hiding this comment

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

where this property is used?

foreach (var cluster in clusters.Connections)
{
Log.LogInformation($"Generating diff markdown for {Path.Combine(path, databaseName)} => {cluster}/{escapedDbName}");
Log.LogInformation($"Generating diff markdown for {Path.Combine(path, databaseName)} => {cluster}/{databaseName}");

Check notice

Code scanning / CodeQL

Call to System.IO.Path.Combine Note

Call to 'System.IO.Path.Combine'.

Copilot Autofix

AI about 19 hours ago

To fix the issue, replace the use of Path.Combine with Path.Join. The Path.Join method does not treat any of its arguments as absolute paths, ensuring that all arguments are concatenated as intended. This change will prevent the silent dropping of earlier arguments if a later argument is an absolute path.

Specifically:

  1. Replace the Path.Combine(path, databaseName) call on line 41 with Path.Join(path, databaseName).
  2. Ensure that the System.IO namespace is already imported (it is in this case).

Suggested changeset 1
KustoSchemaTools/KustoSchemaHandler.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/KustoSchemaTools/KustoSchemaHandler.cs b/KustoSchemaTools/KustoSchemaHandler.cs
--- a/KustoSchemaTools/KustoSchemaHandler.cs
+++ b/KustoSchemaTools/KustoSchemaHandler.cs
@@ -40,3 +40,3 @@
             {
-                Log.LogInformation($"Generating diff markdown for {Path.Combine(path, databaseName)} => {cluster}/{databaseName}");
+                Log.LogInformation($"Generating diff markdown for {Path.Join(path, databaseName)} => {cluster}/{databaseName}");
 
EOF
@@ -40,3 +40,3 @@
{
Log.LogInformation($"Generating diff markdown for {Path.Combine(path, databaseName)} => {cluster}/{databaseName}");
Log.LogInformation($"Generating diff markdown for {Path.Join(path, databaseName)} => {cluster}/{databaseName}");

Copilot is powered by AI and may make mistakes. Always verify output.
@sdseaton sdseaton merged commit 51a611e into main Jul 1, 2025
4 checks passed
@sdseaton sdseaton deleted the bugfix/escaped_db_name branch July 1, 2025 13:33
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