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 save model with empty array #221

Closed
97mik opened this issue Nov 13, 2018 · 0 comments
Closed

Can't save model with empty array #221

97mik opened this issue Nov 13, 2018 · 0 comments
Assignees
Labels
bug Something isn't working
Projects
Milestone

Comments

@97mik
Copy link

97mik commented Nov 13, 2018

I have a Fluent MySQL model:

final class SomeModel: MySQLModel {
    var id: Int?
    var someArray: [Int]

    init(id: Int? = nil, someArray: [Int]) {
        self.someArray = someArray
    }  
}

And when I am trying to save model with not empty array:

SomeModel(someArray: [1, 2]).save(on: req)

It is works.
But when I am trying to save same model with empty array (not nil):

SomeModel(someArray: []).save(on: req)

Then I get crash in MySQLDataEncoder.swift file, at 11 line, with error message: "Unexpectedly found nil while unwrapping an Optional value".
And I found that the same issue was in postgresql: vapor/postgres-kit#80

@tanner0101 tanner0101 transferred this issue from vapor/fluent-mysql-driver Dec 5, 2018
@tanner0101 tanner0101 added the bug Something isn't working label Dec 5, 2018
@tanner0101 tanner0101 self-assigned this Dec 5, 2018
@tanner0101 tanner0101 added this to the 12-5-18 milestone Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Vapor 3
  
Awaiting triage
Development

No branches or pull requests

2 participants