volatiletech / strmangle

Support library for sqlboiler
BSD 3-Clause "New" or "Revised" License
8 stars 13 forks source link

singularization rule for personas #3

Open farkmi opened 3 years ago

farkmi commented 3 years ago

Adds a singularization rule for personas -> persona.

sqlboiler (v4.5.0) otherwise produces code that results in build errors, e.g.

CREATE TABLE personas (
    id uuid NOT NULL,
    name text NOT NULL,
    created_at timestamptz NOT NULL,
    updated_at timestamptz NOT NULL,
    CONSTRAINT personas_pkey PRIMARY KEY (id)
);

results in errors in the generated model, as it does not correctly singularize the struct name:

Personas redeclared in this block (see details)compilerDuplicateDecl
personas.go(176, 6): Personas redeclared in this block
personas.go(25, 6): other declaration of Personas (this error)
type Personas struct {
[...]
func Personas(mods ...qm.QueryMod) personasQuery {

This can be mitigated with an alias configuration for that table, however it seems more reasonable to fix this directly in strmangle, analogous to previous issues, e.g. https://github.com/volatiletech/sqlboiler/issues/653