sqlboiler
sqlboiler copied to clipboard
Fix output filenames that contain a forward slash or backslash
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"
)
@stephenafamo: This PR together with volatiletech/strmangle#18 would add support for table names containing slashes