-
Notifications
You must be signed in to change notification settings - Fork 108
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
Generate Code Across Multiple Schema #291
Comments
Yeah, jet generator only introspects single schema. I did a quick test with types from different schema (enum and foreign key) and it seems to work. The only thing noticed is that enum is of type string, but that can be fixed by customizing the generator. |
That would be amazing! Looking forward to this missing feature being added! |
I was wondering if had any thoughts when this would be picked up? While this is pending a proper fix, I was wondering what you thought about doing something like: for schema in a b c ; do jet -dsn="postgres://ht_controller_user:secret@127.0.0.1:5432/funcap_controller?sslmode=disable" -schema=$i -path=./.gen ; done; Do you think that is safe enough assuming no table collisions? Though I'd prefer not to have to manage this myself there's enough that Jet provides that I'd love to use it. So doing something like: SET search_path TO myschemaName; prior to running the command should work I believe. Any thoughts? |
I think you misunderstood me. I don't see any meaningful issues with using Jet in a multi-schema environment. The only problem I encounter is that if an enum is used in a different schema from the schema where it is defined, it will appear in model types as a string. This can be easily overcome by simple type cast or customizing the generator.
There shouldn't be any collisions, because different schema will be generated in different folders.
What's the goal of setting a search path. Are schema |
Enum casting isn't an issue, though any references on custom generator would be great. in my example, a,b,c and are different schemas. So what I was trying to get to, if the Generator runs and is aware that 3 schemas exists, then you could write the generator to discover the data types across the 3 namespaces and generate the correct go struct for it to use. If you're running the generator independently, then it doesn't have vision on the three schemas so it can only do the best it can with the information available, which I assume one behavior is the enum being cast to string as you pointed out. I think the enum behavior is still a blocker for me to use it, so having a release at some point would be good (when you're ready to do so ), but if the folder division works, I can give this a go and see. The DSL of Jet is really appealing combined with the generated code based on a running database. <3 |
https://github.com/go-jet/jet/wiki/Generator#generator-customization |
Is your feature request related to a problem? Please describe.
Currently in order to use Jet across multiple schemas, you have to invoke it multiple times which is not great from a usability perspective, but also the code generated is unaware of the other schemas. There are also use cases where you may have a FKEY constraint pointing to a different schema that (may?) breaks code generation.
I'm currently blocked by 290 and can't confirm this but I assume there's issues in general simply because the introspection does not explore the full datamodel when invoked.
Describe the solution you'd like
I would like to be able to point to a list of schemas and tables ideally that are of interest and have Jet generate code for them.
The text was updated successfully, but these errors were encountered: