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 insert giving default value #540

Merged

Conversation

matthewmcgarvey
Copy link
Member

Fixes #539

Does not filter out unchanged attributes, only nils, on inserting. This allows creating a model with the same value as the default.

Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@matthewmcgarvey matthewmcgarvey merged commit ada8b02 into luckyframework:master Nov 18, 2020
@matthewmcgarvey matthewmcgarvey deleted the insert-default-values branch November 18, 2020 23:52
@@ -421,6 +421,14 @@ describe "Avram::SaveOperation" do
end
end

it "allows supplying a value that matches the default" do
result = Company::SaveOperation.create!(sales: 0_i64, earnings: 0_i64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt this be a float?

result = Company::SaveOperation.create!(sales: 0_i64, earnings: 0_f64)

Copy link
Member Author

@matthewmcgarvey matthewmcgarvey Nov 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oya, I guess you're right. The type extensions have methods for doing the conversion, luckily!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. I am surprised that worked but it makes sense.

@jkthorne jkthorne mentioned this pull request Nov 24, 2020
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.

Insert only sends changed values
3 participants