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

foreign key types in !table are not supported by codegen transforms #106

Open
ghost opened this issue May 14, 2020 · 7 comments
Open

foreign key types in !table are not supported by codegen transforms #106

ghost opened this issue May 14, 2020 · 7 comments
Labels
P0 Highest priority: important and urgent

Comments

@ghost
Copy link

ghost commented May 14, 2020

sysl:

PoOrder:
    !table Assessment:
        assessmentId <: int:
            @label = "Assessment ID"
    !table AssessmentNote:
        assessmentId <: Assessment.assessmentId:
            @label = "Assessment ID"

attempting to run this through the sysl codegen will error out on the Assessment.assessmentId "type".

@ChloePlanet ChloePlanet added the P0 Highest priority: important and urgent label May 18, 2020
@tiagralee tiagralee added the WIP label May 18, 2020
@tiagralee
Copy link
Contributor

Hi @anz-gordonj7 , the : after the type doesn't look right to me,
I found a reference example as below, you can also try add a [~pk] after the primary key
https://github.com/anz-bank/sysl/blob/master/demo/petshop/petshop.sysl
let me know if this helps.

PoOrder:
    !table Assessment:
        assessmentId <: int [~pk]
            @label = "Assessment ID"
    !table AssessmentNote:
        assessmentId <: Assessment.assessmentId
            @label = "Assessment ID"

@ghost
Copy link
Author

ghost commented May 19, 2020

@tiagralee hi, no the sysl is perfectl valid, codegen fails though, try to run it like "sysl gen --root . --root-transform . --transform transforms/svc_types.sysl --grammar grammars/go.gen.g --start goFile "

I think petshop.sysl has the same problem actually

@tiagralee
Copy link
Contributor

@anz-gordonj7 Thanks for clarify, I'll take a look.

@tiagralee
Copy link
Contributor

Hi @anz-gordonj7 , do we want codegen to support data models in !table? got two approach to solve this.

  1. bypass !table when codegen for types (if we don't need data models to be generated)
  2. make the type transform support cross referencing across types

@ghost
Copy link
Author

ghost commented May 21, 2020

We need the go code to generate the types correctly, for that I guess it just means we need the foreign key field to just generate as an int, we dont need the automatic linking (we just need types, not a database)

@tiagralee
Copy link
Contributor

Thanks @anz-gordonj7 , got it.

@anzdaddy
Copy link
Member

There is an existing implementation of relation model codegen for Go on an unmerged branch: https://github.com/anz-bank/sysl/tree/anzdaddy/relgom

@tiagralee tiagralee removed the WIP label May 25, 2020
@tiagralee tiagralee removed their assignment May 25, 2020
@tiagralee tiagralee removed their assignment Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 Highest priority: important and urgent
Projects
None yet
Development

No branches or pull requests

4 participants