You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/08/01 09:49:20 UTC

[GitHub] [incubator-devlake] narrowizard opened a new issue, #2652: [Bug][DAL] Dalgorm.GetPrimaryKeyFields cannot return primarykey of type time.Time

narrowizard opened a new issue, #2652:
URL: https://github.com/apache/incubator-devlake/issues/2652

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### What happened
   
   I want to get primary key of my model, using `Dalgorm.GetPrimaryKeyFields` method, but it always lost the field of type time.Time.  
   ### my model with 3 primary keys
   ![nrzvsyBBbE](https://user-images.githubusercontent.com/11383928/182120599-79c002a6-69e1-4eac-a0c7-3316635c80e7.jpg)
   ### only get two string column as primary keys
   ![SToBUOGkd6](https://user-images.githubusercontent.com/11383928/182120742-e42d0cec-df79-4474-a944-afef837b6cb6.jpg)
   
   
   ### What you expected to happen
   
   `Dalgorm.GetPrimaryKeyFields` should return all primary keys of model.
   
   ### How to reproduce
   
   1. Define a model with any field of type time.Time
   2. Set the time.Time field as primary key with gorm tag `gorm:"primaryKey"`
   3. call `Dalgorm.GetPrimaryKeyFields` 
   
   ### Anything else
   
   With a deep looking for, `GetPrimaryKeyFields` will walk all fields for target model with `utils.WalkFields`. And  `utils.WalkFields` treat `time.Time` as a struct, so it walks into `time.Time`. It causes the problem.
   
   https://github.com/apache/incubator-devlake/blob/3a0f52eec956c2bd98ab196335fcfd0ec096cc01/impl/dalgorm/dalgorm.go#L167
   
   ### Version
   
   main
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh closed issue #2652: [Bug][DAL] Dalgorm.GetPrimaryKeyFields cannot return primarykey of type time.Time

Posted by GitBox <gi...@apache.org>.
klesh closed issue #2652: [Bug][DAL] Dalgorm.GetPrimaryKeyFields cannot return primarykey of type time.Time
URL: https://github.com/apache/incubator-devlake/issues/2652


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org