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

Fix output filenames that contain a forward slash or backslash #1402

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

MJacred
Copy link
Contributor

@MJacred MJacred commented Jul 24, 2024

Example table

CREATE TABLE IF NOT EXISTS `Slash/Test` (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,

    `my_en/um` ENUM('test/1', '/test2', 'test3'),

    PRIMARY KEY (id)
);

Sqlboiler attempts to create a file called "Slash/Test.go", which it fails to do - and should not do. This fix changes the output to "Slash_Test.go".

NOTE: this output also requires volatiletech/strmangle#17 and volatiletech/strmangle#18

// SlashTest is an object representing the database table.
type SlashTest struct {
	ID     uint                `csv:"id" hash:"id" boil:"id" json:"id" toml:"id" yaml:"id"`
	MyEnUm SlashTestNullMyEnUm `csv:"my_en/um" hash:"my_en/um" boil:"my_en/um" json:"my_en/um,omitempty" toml:"my_en/um" yaml:"my_en/um,omitempty"`

	R *slashTestR `csv:"-" hash:"-" boil:"-" json:"-" toml:"-" yaml:"-"`
	L slashTestL  `csv:"-" hash:"-" boil:"-" json:"-" toml:"-" yaml:"-"`
}

// and in boil_types.go

type SlashTestMyEnUm string

// Enum values for SlashTestMyEnUm
const (
	SlashTestMyEnUmTest1 SlashTestMyEnUm = "test/1"
	SlashTestMyEnUmTest2 SlashTestMyEnUm = "/test2"
	SlashTestMyEnUmTest3 SlashTestMyEnUm = "test3"
)

@MJacred
Copy link
Contributor Author

MJacred commented Jul 24, 2024

@stephenafamo: This PR together with volatiletech/strmangle#18 would add support for table names containing slashes

@stephenafamo stephenafamo merged commit 9eaa10e into volatiletech:master Oct 23, 2024
2 checks passed
@MJacred MJacred deleted the fix_filename_gen branch October 23, 2024 11:47
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