novi / mysql-swift

A type safe MySQL client for Swift
MIT License
164 stars 40 forks source link

Add Decodable support for JSON columns #68

Closed florianreinhart closed 6 years ago

florianreinhart commented 6 years ago

This is a quick solution to add support for decoding JSON columns

novi commented 6 years ago

MYSQL_TYPE_JSON is not available on some versions of libmysql. We could have an option to use JSON type like vapor's. I suggest something -DWITHMYSQLJSON not -DNOMYSQLJSON.

florianreinhart commented 6 years ago

Oh yes, I forgot about that.

This was just a quick implementation to decode nested JSON objects in my code. It would also be nice to able to pass in a custom JSON decoder, e.g. if you have need to set the date decoding strategy.

I'd like to see a move away from QueryRowResultType to full-fledge Decodable support for this library, maybe for 1.0. What do you think?

novi commented 6 years ago

Custom JSON decoder is necessary in many(or may be some) cases. We would design an interface for that.

This MySQL library and its encoder are lasting since Swift 2.0. It is good timing to migrate QueryRowResultType to Swift.Decodable. And created milestone for 0.9.0 in #69.

novi commented 6 years ago

85 will fix this.