-
Notifications
You must be signed in to change notification settings - Fork 550
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
UUID used as a primary key causes panic when loading #1381
Comments
Since you're using UUIDs, I would suggest doing a type replacement to use [[types]]
tables = ['events', 'schedules']
[types.match]
name = "id"
[types.replace]
type = "[16]byte" Until better detection of the DB type is done to use arrays instead of slices, this would be the best solution. |
Thanks, I was wondering if there was a way to do that, but there is! |
@stephenafamo create event: pdbmodel: unable to insert into events: sql: converting argument $1 type: unsupported type [16]uint8, a array Is there anything else I can try? |
Perhaps you can try an actual UUID type? [[types]]
tables = ['events', 'schedules']
[types.match]
name = "id"
[types.replace]
type = "uuid.UUID"
[types.imports]
third_party = ['"github.com/google/uuid"'] |
I created a custom UUID type that implemented |
Glad it worked. Both |
hi, I have many tables use UUID, and these are different field name, can you suggest some method to generate it? |
Or is it possible for us to optimize the primary key of the binary field? |
The best suggestion I have is for you to write a small script to generate the config. |
If you're having a generation problem please answer these questions before submitting your issue. Thanks!
What version of SQLBoiler are you using (
sqlboiler --version
)?v4.16.2
What is your database and version (eg. Postgresql 10)
MySQL 8.0
If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)
If this happened at runtime what code produced the issue? (if not applicable leave blank)
What is the output of the command above with the
-d
flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)
Further information. What did you do, what did you expect?
I am using UUID as a PK, and the generated code is as follows:
As you can see in the code above, the
ID
column uses the[]byte
type.However, this leads to a problem in the code as follows:
Here, the type of the
ID
value is[]byte
, but a slice in Golang is not hashable. Therefore, the following error occurs:#1337
This issue is suspected to have arisen from the above PR. If you use version
v4.15.0
, this problem does not occur. It's necessary to solve the performance issue withLoad
, but it would be good if it could be used without any problems even when using UUID as a PK.The text was updated successfully, but these errors were encountered: