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

Error - unable to generate code for table: %s, primary key column: [%d] %s has unsupported type: %s / %s #152

Open
shinsuny opened this issue Feb 17, 2021 · 5 comments

Comments

@shinsuny
Copy link

gen --version
v0.9.27 (08/04/2020)

I am trying like:

gen --sqltype=mysql \
   	--connstr "correct_conn_str" \
   	--database some_db  \
   	--gorm \
   	--guregu \
   	--out ./out \
   	--generate-dao \
   	--overwrite

Then getting:

Error - unable to generate code for table: %s, primary key column: [%d] %s has unsupported type: %s / %s

Yes, my primary key column is a varbinary

Is there a way to fix this?
Thanks

@smallnest
Copy link
Owner

gen doesn't know how to map varbinary to a go type.

Maybe you should define your mapping.json just like:

{
      "sql_type": "date",
      "go_type": "time.Time",
      "json_type": "Text",
      "protobuf_type": "google.protobuf.Timestamp",
      "guregu_type": "*models.Time",
      "go_nullable_type": "time.Time",
      "swagger_type": "time.Time"
    }

@shinsuny
Copy link
Author

shinsuny commented Mar 8, 2021

@smallnest

After doing more research, it seems gen understands varbinary and converts it to []byte but problem occurred (Error thrown) when varbinary is a primary key.

@smallnest
Copy link
Owner

what error? paste the error stack please

@shinsuny
Copy link
Author

shinsuny commented Mar 8, 2021

I am getting like(As in the first comment)
Error - unable to generate code for table: %s, primary key column: [%d] %s has unsupported type: %s / %s

Sorry, I don't have stack ATM.

@smallnest
Copy link
Owner

smallnest commented Mar 8, 2021

I have added some code to support varbinary but have not test with a mysql database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants