vapor-community / node

A formatted data encapsulation meant to facilitate the transformation from one object to another
MIT License
25 stars 20 forks source link

Fuzzy get fails for [UInt8] #86

Open vzsg opened 7 years ago

vzsg commented 7 years ago

This is an older issue I forgot to report, but still happening with the latest versions of the framework. It's easiest to reproduce with Fluent, but the underlying issue is here.

Consider an entity that has a Bytes property inside, and its init(row:) initializer.

The linked file works, but if line 16 was written naively as one would expect to work:

content = try row.get("content")

A cryptic error is thrown instead:

[Node Error: Unable to convert 'Node(wrapped: [91, 49, 48, 48, 44, 49, 49, 55, 44, 49, 48, 57, 44, 49, 48, 57, 44, 49, 50, 49, 44, 52, 56, 44, 52, 56, 44, 52, 57, 93], context: MySQL.MySQLContext)' to 'UInt8' for path ''] [Identifier: Node.NodeError.unableToConvert]

Which suggests that for some dark reason, the function tried to convert the bytes SD into a single byte.

tanner0101 commented 7 years ago

@LoganWright any ideas here?

I vaguely remember this being related to an ambiguity that we couldn't resolve when determining if we should init a single object or an array of objects.

let user: User = try row.get("user")
let user: [User] = try row.get("users")