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

allow definition of primary keys directly on kallax.Model tags #187

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

erizocosmico
Copy link
Contributor

@erizocosmico erizocosmico commented Jun 27, 2017

Fixes #186

Changes introduced

  • Embedded fields now are directly inlined during the processing instead of delegating that to the generation. That's because of technical reasons related to this PR.
  • PK can be defined now in the kallax.Model struct tags.
  • Other minor changes I came across when developing this feature.

Example usage

type User struct {
  kallax.Model `table:"users" pk:"id,autoincr"`
  ID int64
  Name string
}

Caveats

pk struct tags could be removed from regular fields and keep it all in the model. We could mark as deprecated the previous behavior and remove it on kallax v2.

Docs

Follow-up PR with docs will be made once this is merged, in case something changes during the review.

@codecov
Copy link

codecov bot commented Jun 27, 2017

Codecov Report

Merging #187 into master will increase coverage by 0.21%.
The diff coverage is 95.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #187      +/-   ##
==========================================
+ Coverage   78.95%   79.17%   +0.21%     
==========================================
  Files          19       19              
  Lines        3592     3644      +52     
==========================================
+ Hits         2836     2885      +49     
- Misses        544      545       +1     
- Partials      212      214       +2
Impacted Files Coverage Δ
generator/processor.go 88.73% <100%> (ø) ⬆️
generator/template.go 92.81% <100%> (-0.02%) ⬇️
generator/types.go 86.93% <95.38%> (+0.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e544e6...880d2b0. Read the comment docs.

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
@erizocosmico erizocosmico force-pushed the feature/pk-in-model branch from 7623acd to 880d2b0 Compare June 27, 2017 12:56
@erizocosmico erizocosmico merged commit a7eb23f into src-d:master Jun 28, 2017
@erizocosmico erizocosmico deleted the feature/pk-in-model branch June 28, 2017 09:01
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

Successfully merging this pull request may close these issues.

3 participants