leafo / lapis

A web framework for Lua and OpenResty written in MoonScript
http://leafo.net/lapis/
MIT License
3.14k stars 247 forks source link

Add support for Blob types for Postgres. #730

Closed eko234 closed 3 years ago

eko234 commented 3 years ago

I'm trying to store a blob using Postgres but as i see there is no blob or bytea type, is it posible for you to implement that feature?, or how would you suggest to go about storing binary data?

leafo commented 3 years ago

Any types that don't have specific handlers are treated as Lua strings, which is exactly what you want for your blob type.

eko234 commented 3 years ago

I see, thanks again.

eko234 commented 3 years ago

I realized that my question is really about migrations, how do i write a migration to create a field that stores a blob?

eko234 commented 3 years ago

I tried altering the postgresql field and set it to bytea and then tried inserting a record with a blob in the form of a string but it didn't worked either, I think it has something to do with escaping in the blob/string.

eko234 commented 3 years ago

it's because of the null bytes represented in the string that postgres throws errors... still don'w know how to work around it.