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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timestampable models test fails in linux #1710
Comments
removing (or commenting) this portion of code (you can leave the extension Todo: Timestampable {
static var createdAtKey: WritableKeyPath<Todo, Date?> {
return \.createdAt
}
static var updatedAtKey: WritableKeyPath<Todo, Date?> {
return \.updatedAt
}
} |
What this boiled down for me is that Swift/Fluent/Vapor (not sure exactly which one) has a bug when using What it will do is, once you check the SQL logs, to instead of choosing the correct column it picks "the first one available". So it will try to assign I'm not in a position where I can debug this in detail yet but I may later today. As said I've experienced the same bug before and my solution often looks like this: QueryField(entity: Model.entity, name: "correctNameHere") Which is defeating the purpose of having the convenient way of writing that, however it does work. |
My guess is this is a bug in the |
@tanner0101 I've had the same bug in MySQL as well though - have there been updates addressing this some time recently? |
Hmm actually think it might be a much simpler problem. I'm seeing the response come back as: HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
content-length: 97
{"title":"My Todo!","createdAt":"2018-06-05T07:48:59Z","updatedAt":"2018-06-05T07:48:59Z","id":1} And @gperdomor is trying to decode this model using default JSONDecoder. /// A single entry of a Todo list.
final class Todo: PostgreSQLModel {
static let entity = "todos"
/// The unique identifier for this `Todo`.
var id: Int?
/// A title describing what this `Todo` entails.
var title: String
var createdAt: Date?
var updatedAt: Date?
var deletedAt: Date?
/// Creates a new `Todo`.
init(id: Int? = nil, title: String) {
self.id = id
self.title = title
}
} The dates are formatted ISO8601 which I don't think Linux supports in Swift 4.1. |
With Vapor 4 in Beta and no discussion for over a few months, I'm closing this issue. Feel free to re-open if there are still questions/issues unanswered. |
Test fails with
Timestampable
model in linuxSteps to reproduce
Download this source code, run
docker-compose build
and thendocker-compose test
todo-demo.zip
Expected behavior
The same behavior on Mac, tests green 馃槃
Actual behavior
Tests not pass:
<EXPR>:0: error: TodoTests.testGettingASingleTodoFromTheAPI : threw error "鈿狅笍 [DecodingError.typeMismatch: Value of type 'Double' required for key 'createdAt'.]"
Environment
The text was updated successfully, but these errors were encountered: