Skip to content

Quote column names + windows support#1354

Open
ajscholl wants to merge 2 commits into
mainfrom
quote-column-names
Open

Quote column names + windows support#1354
ajscholl wants to merge 2 commits into
mainfrom
quote-column-names

Conversation

@ajscholl

Copy link
Copy Markdown
Contributor

This PR improves the automatic quoting in the dbx package such that you can use column names like index without running into syntax errors. It also splits some functions such that there is a *_unix.go and *_windows.go file, making it possible to compile gosoline programs for windows as well.

Copilot AI left a comment

Copy link
Copy Markdown

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 Windows compilation support and improves SQL column name quoting in the gosoline framework. The changes enable the dbx package to correctly handle SQL reserved words (like index) as column names through automatic backtick quoting, and split OS-specific functionality into separate files with build tags to support Windows compilation.

Changes:

  • Added automatic column/table name quoting in dbx package using backticks for simple identifiers
  • Split Unix/Windows-specific code with appropriate build tags for kernel signal handling, exec error handling, and log status modules
  • Added integration test demonstrating reserved word handling with index column

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/dbx/expr.go Implemented quoteIfNeeded function with regex pattern to auto-quote simple identifiers; applied to column names in WHERE/SET clauses and table names; refactored comparison operators for clarity
pkg/dbx/select.go Applied quoting to table names and column names in FROM clauses
pkg/dbx/insert.go Applied quoting to table names; cleaned up unused variable and improved parameter naming
pkg/dbx/update.go Applied quoting to table and column names in UPDATE statements
pkg/dbx/delete.go Applied quoting to table names in DELETE statements
pkg/dbx/get.go Applied quoting to table names in GET queries
pkg/dbx/client_test.go Updated test expectations to include backtick-quoted identifiers in SQL
test/dbx/client_test.go Added Index field to test struct to verify reserved word handling
test/dbx/20240605153316_init.sql Added index column (a MySQL reserved word) to test table schema
pkg/kernel/kernel_windows.go Windows-specific interrupt signal handling (SIGINT only)
pkg/kernel/kernel_unix.go Unix-specific interrupt signal handling (SIGINT and SIGTERM)
pkg/kernel/kernel.go Refactored to use platform-specific interruptSignals variable
pkg/exec/error_windows.go Windows-specific error type checking using Windows error codes
pkg/exec/error_unix.go Unix-specific error type checking using Unix error codes
pkg/exec/error.go Refactored to use platform-specific error checking functions
pkg/log/status/module_windows.go No-op status module for Windows (SIGUSR1 not supported)
pkg/log/status/module_unix.go Added build tags for Unix platforms
pkg/log/status/module_unix_test.go Added build tags for Unix platforms

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

Comment thread pkg/dbx/expr.go
switch p := part.(type) {
case string:
sql += p
sql += quoteIfNeeded(p)

Copilot AI Jan 18, 2026

Copy link

Choose a reason for hiding this comment

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

Applying quoteIfNeeded in concatExpr changes its behavior for simple column identifiers. While the documented example shows SQL fragments like "COALESCE(full_name," which won't be affected by the regex pattern, users passing simple identifiers like "column_name" will now have them automatically quoted. This is a subtle breaking change. Consider whether this automatic quoting aligns with the intended use case of ConcatExpr, which appears to be for concatenating raw SQL fragments based on the documentation.

Suggested change
sql += quoteIfNeeded(p)
sql += p

Copilot uses AI. Check for mistakes.
@github-actions

Copy link
Copy Markdown

🚀 Docs Preview Deployed!

View the preview here: https://justtrackio.github.io/gosoline/pr-1354/

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