Code Monkey home page Code Monkey logo

Comments (8)

stephenafamo avatar stephenafamo commented on June 11, 2024

What does the generated model look like?

from sqlboiler.

MJacred avatar MJacred commented on June 11, 2024

@stephenafamo: I updated the example for better clarity and added the generated model

from sqlboiler.

stephenafamo avatar stephenafamo commented on June 11, 2024

The issue is your config. You're missing something with the TOML syntax and you're using double square brackets where single square brackets should be used.

add-enum-types = true

[[types]]
  [types.match]
    name = "my_enum"
    # tables = ["TableA"]

  [types.replace]
    type = "models_types.MyEnumOverride"
  
  [types.imports]
    third_party = ['"test.com/test/models_types"']

It would be a cleaner experience to replace their types with 1 self-created one…

Side note, you can just replace one of the enums with the second auto generated one so that you don't have to maintain the values yourself πŸ€·πŸΎβ€β™‚οΈ

from sqlboiler.

MJacred avatar MJacred commented on June 11, 2024

you're using double square brackets where single square brackets should be used

That's it. Thanks!

One problem left, though: sqlboiler still auto-generates type TableAMyEnum string into boil_types.go

you can just replace one of the enums with the second auto generated one

Indeed

from sqlboiler.

stephenafamo avatar stephenafamo commented on June 11, 2024

One problem left, though: sqlboiler still auto-generates type TableAMyEnum string into boil_types.go

Not really an issue since there is no way for SQLBoiler to be sure that you do not intend to use the type somewhere else.

from sqlboiler.

MJacred avatar MJacred commented on June 11, 2024

Not really an issue since there is no way for SQLBoiler to be sure that you do not intend to use the type somewhere else.

If sqlboiler creates a type specifically for that field in that table and I tell sqlboiler to replace it in the generated model, then it makes no sense to keep it.
So that reasoning makes little sense to me. But if you must insist, I propose to add a flag to "skip fully replaced (enum) types"

from sqlboiler.

stephenafamo avatar stephenafamo commented on June 11, 2024

I can see why this would be useful.

If you can send in a PR with this flag, I'll be happy to review and merge.

from sqlboiler.

MJacred avatar MJacred commented on June 11, 2024

Thank you. I'll see to it. If you have some useful pointers (like where the replacement takes place), I'd appreciate it a lot!

from sqlboiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.