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

Can't call Create(...) using types other than int, int64, UUID or string for primary key #605

Open
mfinley3 opened this issue Oct 29, 2020 · 0 comments
Labels
s: triage Some tests need to be run to confirm the issue

Comments

@mfinley3
Copy link

mfinley3 commented Oct 29, 2020

Description

Not sure if I am missing something but it appears I cannot call Create(...) with types other than the ones mentioned above.
I'd like to be able to. I have an ID type that wraps a few fields, one being a uuid. I'd like to use this type and store the uuid it wraps, as the primary key.

I have both func (id *ID) Scan(src interface{}) error and func (id ID) Value() (driver.Value, error) implemented and they work for Find(), All(), etc... just not Create().

Reasoning for the ID type that is wrapped with other fields is to use a graphql node interface to look up nodes of differing types across a federated schema. This reduces the number of queries that need to written by utilizing a single node(id: ID!): Nodequery. So using just UUID, string, etc isn't really an option for me.

Steps to Reproduce the Problem

  1. Create a table with a pk
  2. Create an ID type that implements both Scan and Value. Making sure the Value function satisfies the tables pk type
  3. Use that ID type as the "db: id" field in a model
  4. Attempt to Create() that resource

Expected Behavior

I'd expexct Create() insert the value into the database using my ID type.

Actual Behavior

I get an error: "can not use ID as a primary key type!"

Info

I'm using pop through buffalo. Right from my go.mod: github.com/gobuffalo/pop/v5 v5.3.0
Related Buffalo pop code: https://github.com/gobuffalo/pop/blob/master/dialect_common.go#L45-L98

@sio4 sio4 added the s: triage Some tests need to be run to confirm the issue label Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: triage Some tests need to be run to confirm the issue
Projects
None yet
Development

No branches or pull requests

2 participants