dart_postgresql icon indicating copy to clipboard operation
dart_postgresql copied to clipboard

bytea is not implemented

Open jonaskello opened this issue 10 years ago • 1 comments

I want to store binary data in a postgres database. For space saving I don't want to store it as a text field (base64 encoded). So I created a column of type bytea (which seemed like the correct type, although I have not used postgres a lot so not sure). Next I tried to execute an INSERT command with a parameter as a Uint8List but it threw an exception "Postgresql array types not implemented yet.".

I could do some work on this and create a pull request but I would need some pointers on how it should be implemented. Specifically about the function String encodeArray(List value) in type_converter.dart. I understand it needs to encode the incoming List to a string, but not sure of the format it should return.

jonaskello avatar May 01 '15 15:05 jonaskello

I'm happy to take patches ;)

Without large changes to the library, the binary data will be sent across the wire as base64 anyway. So you will not get a performance benefit from using a bytea instead of base64 in a string.

One problem is that postgresql also supports array types. So List<int> should be interpreted as the postgresql type Integer[]. A Uint8List is a List<int>, so to be consistent should probably be treated the same.

So perhaps bytea data should only be used when declared explicitly. i.e.

conn.execute("insert into foo values (@1:bytea)", [bytes]);

xxgreg avatar May 01 '15 22:05 xxgreg