Skip to content

feat: add support for excluding SQL files from directory loading - #123

Merged
DevD4v3 merged 1 commit into
masterfrom
feature/exclude-sql-files
Jun 29, 2026
Merged

DevD4v3 merged 1 commit into
masterfrom
feature/exclude-sql-files

Conversation

@DevD4v3

@DevD4v3 DevD4v3 commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Motivation

While integrating YeSql into my CTF project, I needed to keep a schema.sql file alongside the query files.

The schema script is executed only once during application startup to create the database schema, but LoadFromDirectories() also loaded it into the ISqlCollection, where it served no purpose.

This change introduces an opt-in configuration method that allows specific SQL files to be excluded from directory loading without changing the existing directory structure.

Changes

  • Add YeSqlLoader.Exclude() to exclude SQL files from LoadFromDirectories().
  • Normalize file paths to file names before storing exclusions.
  • Store excluded file names in a HashSet<string> to prevent duplicates and provide efficient lookups.
  • Add XML documentation.
  • Add unit tests covering the new behavior.
  • Update the sample project.

Usage

ISqlCollection sqlStatements = new YeSqlLoader()
    .Exclude("client.sql", "employee.sql")
    .LoadFromDirectories("yesql");

Console.WriteLine(sqlStatements.TryGetStatement("GetClients", out var sql)
    ? sql
    : "'GetClients' is unavailable because it belongs to an excluded SQL file.");

Console.WriteLine(sqlStatements.TryGetStatement("GetEmployees", out sql)
    ? sql
    : "'GetEmployees' is unavailable because it belongs to an excluded SQL file.");

* Add YeSqlLoader.Exclude() to configure SQL files that should be ignored when calling LoadFromDirectories()
* Normalize file paths to file names so exclusions work with both relative and absolute paths
* Ignore duplicate excluded file names by storing them in a HashSet
* Add unit tests covering the new exclusion behavior and input validation
* Update the sample project to demonstrate excluding SQL files
@DevD4v3
DevD4v3 merged commit 66f68a7 into master Jun 29, 2026
1 check passed
@DevD4v3
DevD4v3 deleted the feature/exclude-sql-files branch June 29, 2026 01:36
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.

1 participant