Skip to content
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

feat(util/gconv): support automatic conversion of Y/N string to bool #4220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FSpark
Copy link

@FSpark FSpark commented Mar 24, 2025

In Oracle databases, it is very common to use CHAR(1) fields with 'Y' or 'N' to represent boolean values. This PR adds support for interpreting 'Y' as true and 'N' as false to improve compatibility and developer experience.

Note:
Should we also consider adding support for 'T'/'F' as boolean equivalents? This pattern is also occasionally used in some legacy systems.

@gqcn
Copy link
Member

gqcn commented Mar 25, 2025

@FSpark Thanks for your contribution. It indeed needs such implement for recognizing boolean value for oracle, but we should not convert string Y/N to true/false globally in package gconv. It is advised using ConvertValueForField/CheckLocalTypeForField/ConvertValueForLocal implements for such scenario. You can add such implements referring to https://github.com/gogf/gf/blob/dfe088f5cd8c126dee6982a75360e1bb9f522200/contrib/drivers/pgsql/pgsql_convert.go .

@gqcn gqcn added the #👍 label Mar 25, 2025
@houseme houseme requested a review from Copilot March 28, 2025 05:13
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 adds support for converting Oracle CHAR(1) boolean representations into Go booleans, specifically enhancing compatibility with legacy database systems.

  • Adds a new mapping for "n" to be interpreted as false.
  • Supports automatic conversion of 'Y/N' strings, as indicated by the PR title.
Comments suppressed due to low confidence (1)

util/gconv/internal/converter/converter.go:51

  • The PR title suggests support for both 'Y' and 'N' strings, yet this diff only adds a mapping for 'n'. Consider adding or verifying the presence of a corresponding mapping for 'y' to maintain symmetric behavior.
"n":     {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants