Godwin
Godwin

Reputation: 9907

Grails byte array and PostgreSQL

I'm trying to implement the Simple Avatar Uploader on my User domain class but I seem to have encountered a conflicting issue with grails implementation of byte[] and PostgreSQL. I have implemented it exactly as the plugin page suggests but on compilation I get the error:

Error: Error executing SQL ALTER TABLE user ADD avatar bytea(16384): ERROR: type modifier is not allowed for type "bytea"

I have found some help suggesting that PostgreSQL does not accept a size modifier but removing the maxSize: 16384 constraint only leads to the exact same error with a different size:

Error: Error executing SQL ALTER TABLE user ADD avatar bytea(255): ERROR: type modifier is not allowed for type "bytea"

So it seems that grails will automatically set the size to 255 if no maxSize is provided. Is there a way to override this? Or perhaps a more suitable data type for byte arrays?

Thanks!

Upvotes: 1

Views: 1081

Answers (1)

Godwin
Godwin

Reputation: 9907

Not sure if it was directly responsible or not but we are using Grails Database Migration and we solved the issue by editing the latest migration script changing the line

column(name: "avatar", type: "bytea(255)")

to

column(name: "avatar", type: "bytea")

Upvotes: 1

Related Questions